Advertisement
Guest User

Fixed speedbost

a guest
Aug 29th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.86 KB | None | 0 0
  1.  
  2.  
  3. #include <a_samp>
  4. #define FILTERSCRIPT
  5. #define red 0xF60000AA
  6. #define GREEN 0x21DD00FF
  7. #define PRESSED(%0) \
  8. (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  9. #define COLOR_MESSAGE_YELLOW 0xFFDD00AA
  10. //------------------------------------------------------------------------------
  11. new Float:SpeedBoostMultiplier[MAX_PLAYERS];
  12.  
  13. // -----------------------------------------------------------------------------
  14.  
  15. public OnFilterScriptInit()
  16. {
  17. print("\n-------------------------------------------------");
  18. print(" Speed Boost With Car Fly Has been loaded by Boom");
  19. print("-------------------------------------------------\n");
  20.  
  21. for (new i = 0; i < MAX_PLAYERS; i++)
  22. {
  23. if (IsPlayerConnected(i) && !IsPlayerNPC(i))
  24. {
  25. SpeedBoostMultiplier[i] = 3.0;
  26. }
  27. }
  28.  
  29. return 1;
  30. }
  31.  
  32. // -----------------------------------------------------------------------------
  33.  
  34. public OnFilterScriptExit()
  35. {
  36. print("\n------------------------------------------------");
  37. print(" Unloaded SpeedBoost with CarFly By Boom Successfully");
  38. print("------------------------------------------------\n");
  39. return 1;
  40. }
  41.  
  42. // -----------------------------------------------------------------------------
  43.  
  44. public OnPlayerCommandText(playerid, cmdtext[])
  45. {
  46. new cmd[256];
  47. new idx;
  48.  
  49. cmd = strtok(cmdtext, idx);
  50. if (strcmp(cmd, "/SpeedBoostSetup", true) == 0 || strcmp(cmd, "/sb", true) == 0)
  51. {
  52. new strBoostMultiplier[256];
  53. new strTempString[256];
  54. strBoostMultiplier = strtok(cmdtext, idx);
  55.  
  56. if (!strlen(strBoostMultiplier))
  57. {
  58. return 1;
  59. }
  60.  
  61. if (!IsNumeric2(strBoostMultiplier))
  62. {
  63. return 1;
  64. }
  65.  
  66. new Float:BoostMultiplier = floatstr(strBoostMultiplier);
  67.  
  68. if (BoostMultiplier < 1.0 || BoostMultiplier > 1.4)
  69. {
  70. SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "*** Error: You can just change it for 0.1 to 1.4");
  71. return 1;
  72. }
  73.  
  74. SpeedBoostMultiplier[playerid] = BoostMultiplier;
  75.  
  76. format(strTempString,sizeof(strTempString), "*** You set your speed boost multiplier to %0.2f", SpeedBoostMultiplier[playerid]);
  77. SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, strTempString);
  78.  
  79. return 1;
  80. }
  81. return 0;
  82. }
  83.  
  84. // -----------------------------------------------------------------------------
  85.  
  86. public OnPlayerConnect(playerid)
  87. {
  88. SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "to use the speedboost press LMB, to use the carfly press + or 2");
  89. SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "use /sb to set yout speedboost");
  90. // (the previous player may of changed it)
  91. SpeedBoostMultiplier[playerid] = 2.0; //Its 2.0 you can also doing 3.0 and change it
  92. return 1;
  93. }
  94.  
  95. // -----------------------------------------------------------------------------
  96.  
  97. stock strtok(const string[], &index)
  98. {
  99. new length = strlen(string);
  100. while ((index < length) && (string[index] <= ' '))
  101. {
  102. index++;
  103. }
  104.  
  105. new offset = index;
  106. new result[20];
  107. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  108. {
  109. result[index - offset] = string[index];
  110. index++;
  111. }
  112. result[index - offset] = EOS;
  113. return result;
  114. }
  115.  
  116. // -----------------------------------------------------------------------------
  117.  
  118. IsNumeric2(const string[])
  119. {
  120. new length=strlen(string);
  121. if (length==0) return false;
  122. for (new i = 0; i < length; i++)
  123. {
  124. if((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+' && string[i]!='.') // Not a number,'+' or '-' or '.'
  125. || (string[i]=='-' && i!=0) // A '-' but not first char.
  126. || (string[i]=='+' && i!=0) // A '+' but not first char.
  127. ) return false;
  128. }
  129. if (length==1 && (string[0]=='-' || string[0]=='+' || string[0]=='.')) return false;
  130. return true;
  131. }
  132.  
  133. // -----------------------------------------------------------------------------
  134.  
  135. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  136. {
  137. if(newkeys == KEY_CROUCH)
  138. {
  139. if(IsPlayerInAnyVehicle(playerid))
  140. {
  141. {
  142. RepairVehicle(GetPlayerVehicleID(playerid));
  143. }
  144. }
  145. }
  146. if (PRESSED(KEY_FIRE))
  147. {
  148. new
  149. vehicleid = GetPlayerVehicleID(playerid);
  150. if (vehicleid)
  151. {
  152. AddVehicleComponent(vehicleid, 1010);
  153. }
  154. }
  155. if(newkeys & KEY_FIRE && IsPlayerInAnyVehicle(playerid))
  156. {
  157. if(!IsNosVehicle(GetPlayerVehicleID(playerid))) return
  158. AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
  159. PlayerPlaySound(playerid, 1133 ,0, 0, 0);
  160. }
  161. if(newkeys & KEY_SUBMISSION && IsPlayerInAnyVehicle(playerid))
  162. {
  163. if(IsPlayerInAnyVehicle(playerid))
  164. {
  165. new Float:x, Float:y, Float:z;
  166. GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
  167. SetVehicleVelocity(GetPlayerVehicleID(playerid) ,x ,y ,z+0.3);
  168. }
  169. }
  170. if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  171. {
  172. if (newkeys & KEY_FIRE)
  173. {
  174. new Float:vx, Float:vy, Float:vz;
  175. GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
  176.  
  177. if (floatabs(vx) < 3 && floatabs(vy) < 3 && floatabs(vz) < 3)
  178. {
  179. SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * SpeedBoostMultiplier[playerid], vy * SpeedBoostMultiplier[playerid], vz * SpeedBoostMultiplier[playerid]);
  180. }
  181. return 1;
  182. }
  183. }
  184. return 1;
  185. }
  186. IsNosVehicle(vehicleid)
  187. {
  188. #define NO_NOS_VEHICLES 52
  189.  
  190. new InvalidNosVehicles[NO_NOS_VEHICLES] =
  191. {
  192. 581,523,462,521,463,522,461,448,468,586,417,425,469,487,512,520,563,593,
  193. 509,481,510,472,473,493,520,595,484,430,453,432,476,497,513,533,577,
  194. 452,446,447,454,590,569,537,538,570,449,519,460,488,511,519,548,592
  195. };
  196.  
  197. for(new i = 0; i < NO_NOS_VEHICLES; i++)
  198. {
  199. if(GetVehicleModel(vehicleid) == InvalidNosVehicles[i])
  200. {
  201. return false;
  202. }
  203. }
  204. return true;
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement