Adoniiz

aJumpCar normal english

Jan 2nd, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define Rojo 0xFF0000FF
  4. #define VerdeC 0x00FF00FF
  5.  
  6. new Float:Jumping[MAX_PLAYERS];
  7.  
  8.  
  9. public OnFilterScriptInit()
  10. {
  11. for (new i = 0; i < MAX_PLAYERS; i++)
  12. {
  13. if (IsPlayerConnected(i) && !IsPlayerNPC(i))
  14. {
  15. Jumping[i] = 0.2;
  16. }
  17. }
  18. return 1;
  19. }
  20.  
  21. public OnFilterScriptExit()
  22. {
  23. return 1;
  24. }
  25.  
  26. public OnPlayerConnect(playerid)
  27. {
  28. Jumping[playerid] = 0.2;
  29. return 1;
  30. }
  31. public OnPlayerCommandText(playerid, cmdtext[])
  32. {
  33. new cmd[128], idx;
  34. cmd = strtok(cmdtext, idx);
  35.  
  36. if(strcmp(cmd,"/jumpcar", true) == 0)
  37. {
  38. new string[128], tmp[128]; tmp = strtok(cmdtext, idx);
  39. if(!IsNumeric2(tmp)) return SendClientMessage(playerid, Rojo, "Use: /jumpcar [0.0 - 0.5]");
  40. new Float:jumping = floatstr(tmp);
  41. if(jumping < 0.0 || jumping > 0.5) return SendClientMessage(playerid, Rojo, "Use: /jumpcar [0.0 - 0.5]");
  42. Jumping[playerid] = jumping;
  43. format(string,128, "* You put your car jump in %0.2f", Jumping[playerid]);
  44. SendClientMessage(playerid, VerdeC, string);
  45. return 1;
  46. }
  47.  
  48. return 0;
  49. }
  50.  
  51.  
  52. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  53. {
  54. if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  55. {
  56. if (newkeys & KEY_CROUCH)
  57. {
  58. new Float:x, Float:y, Float:z;
  59. GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
  60. SetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z + Jumping[playerid]);
  61. return 1;
  62. }
  63. }
  64. return 1;
  65. }
  66. IsNumeric2(const string[])
  67. {
  68. // Is Numeric Check 2
  69. // ------------------
  70. // By DracoBlue... handles negative numbers
  71.  
  72. new length=strlen(string);
  73. if (length==0) return false;
  74. for (new i = 0; i < length; i++)
  75. {
  76. if((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+' && string[i]!='.') // Not a number,'+' or '-' or '.'
  77. || (string[i]=='-' && i!=0) // A '-' but not first char.
  78. || (string[i]=='+' && i!=0) // A '+' but not first char.
  79. ) return false;
  80. }
  81. if (length==1 && (string[0]=='-' || string[0]=='+' || string[0]=='.')) return false;
  82. return true;
  83. }
  84. stock strtok(const string[], &index)
  85. {
  86. new length = strlen(string);
  87. while ((index < length) && (string[index] <= ' '))
  88. {
  89. index++;
  90. }
  91.  
  92. new offset = index;
  93. new result[20];
  94. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  95. {
  96. result[index - offset] = string[index];
  97. index++;
  98. }
  99. result[index - offset] = EOS;
  100. return result;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment