Advertisement
Ranko_

Menjac System By: Ranko

Oct 14th, 2018
1,371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.18 KB | None | 0 0
  1. //==============================================================================
  2. // SYSTEM Menjac
  3. // SCRIPTED BY Ranko
  4. // VERSION v1.0
  5. //==============================================================================
  6.  
  7. #define FILTERSCRIPT
  8.  
  9. #include <a_samp>
  10.  
  11. #define PRESSED(%0) \
  12. (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  13.  
  14. #define SpeedCheck(%0,%1,%2,%3,%4) floatround(floatsqroot(%4?(%0*%0+%1*%1+%2*%2):(%0*%0+%1*%1) ) *%3*1.6)
  15.  
  16. new BrzinaLimit[MAX_PLAYERS];
  17. new Brzina[MAX_VEHICLES];
  18. new Text:Brzinatxd[MAX_PLAYERS];
  19.  
  20. #define MAX_BRZINA 5
  21. #define VOZILO_BRZINA 31
  22.  
  23. #if defined FILTERSCRIPT
  24.  
  25. public OnFilterScriptInit()
  26. {
  27. print("\n--------------------------------------");
  28. print(" Menjanje brzina by Ranko ");
  29. print("--------------------------------------\n");
  30. return 1;
  31. }
  32.  
  33. public OnFilterScriptExit()
  34. {
  35. print("\n--------------------------------------");
  36. print(" Menjanje brzina by Ranko ");
  37. print("--------------------------------------\n");
  38. return 1;
  39. }
  40.  
  41. #else
  42.  
  43. main()
  44. {
  45. return 1;
  46. }
  47.  
  48. #endif
  49.  
  50. public OnGameModeInit()
  51. {
  52. return 1;
  53. }
  54.  
  55. public OnGameModeExit()
  56. {
  57. return 1;
  58. }
  59.  
  60. public OnPlayerRequestClass(playerid, classid)
  61. {
  62. return 1;
  63. }
  64.  
  65. public OnPlayerConnect(playerid)
  66. {
  67. Brzinatxd[playerid] = TextDrawCreate(558.5,333,"_");
  68. TextDrawFont(Brzinatxd[playerid], 3);
  69. TextDrawLetterSize(Brzinatxd[playerid], 0.53, 1.20);
  70. TextDrawColor(Brzinatxd[playerid], -16776961);
  71. TextDrawBackgroundColor(Brzinatxd[playerid], 51);
  72. TextDrawSetOutline(Brzinatxd[playerid], 0);
  73. TextDrawSetProportional(Brzinatxd[playerid], 1);
  74. TextDrawSetShadow(Brzinatxd[playerid], 1);
  75. BrzinaLimit[playerid] = 0;
  76. return 1;
  77. }
  78.  
  79. public OnPlayerDisconnect(playerid, reason)
  80. {
  81. TextDrawDestroy(Brzinatxd[playerid]);
  82. BrzinaLimit[playerid] = 0;
  83. return 1;
  84. }
  85.  
  86. public OnPlayerSpawn(playerid)
  87. {
  88. BrzinaLimit[playerid] = 0;
  89. return 1;
  90. }
  91.  
  92. public OnPlayerDeath(playerid, killerid, reason)
  93. {
  94. BrzinaLimit[playerid] = 0;
  95. return 1;
  96. }
  97.  
  98. public OnVehicleSpawn(vehicleid)
  99. {
  100. Brzina[vehicleid] = 0;
  101. return 1;
  102. }
  103.  
  104. public OnVehicleDeath(vehicleid, killerid)
  105. {
  106. Brzina[vehicleid] = 0;
  107. return 1;
  108. }
  109.  
  110. public OnPlayerText(playerid, text[])
  111. {
  112. return 1;
  113. }
  114.  
  115. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  116. {
  117. BrzinaLimit[playerid] = Brzina[vehicleid] * 20;
  118. if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
  119. {
  120. BrzinaLimit[playerid] = 999;
  121. }
  122. return 1;
  123. }
  124.  
  125. public OnPlayerExitVehicle(playerid, vehicleid)
  126. {
  127. BrzinaLimit[playerid] = 0;
  128. return 1;
  129. }
  130.  
  131. public OnPlayerStateChange(playerid, newstate, oldstate)
  132. {
  133. return 1;
  134. }
  135.  
  136. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  137. {
  138. if (PRESSED(KEY_YES)) // Brzina visa
  139. {
  140. if(!IsPlayerInAnyVehicle(playerid)) return 1;
  141. new string[128];
  142. if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510) return 1;
  143. if(Brzina[GetPlayerVehicleID(playerid)] <= MAX_BRZINA)
  144. {
  145. Brzina[GetPlayerVehicleID(playerid)] ++;
  146. format(string, sizeof(string), "Brzina: %d", Brzina[GetPlayerVehicleID(playerid)]);
  147. TextDrawSetString(Brzinatxd[playerid], string);
  148. TextDrawShowForPlayer(playerid, Brzinatxd[playerid]);
  149. }
  150. else
  151. {
  152. }
  153. }
  154. if (PRESSED(KEY_NO)) // Brzina manja
  155. {
  156. new string[128];
  157. if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510) return 1;
  158. if(Brzina[GetPlayerVehicleID(playerid)] > -1)
  159. {
  160. Brzina[GetPlayerVehicleID(playerid)] --;
  161. format(string, sizeof(string), "Brzina: %d", Brzina[GetPlayerVehicleID(playerid)]);
  162. if(Brzina[GetPlayerVehicleID(playerid)] == -1)
  163. {
  164. }
  165. TextDrawSetString(Brzinatxd[playerid], string);
  166. TextDrawShowForPlayer(playerid, Brzinatxd[playerid]);
  167. }
  168. }
  169. return 1;
  170. }
  171. stock ModifyVehicleSpeed(vehicleid,mph)
  172. {
  173. new Float:Vx,Float:Vy,Float:Vz,Float:DV,Float:multiple;
  174. GetVehicleVelocity(vehicleid,Vx,Vy,Vz);
  175. DV = floatsqroot(Vx*Vx + Vy*Vy + Vz*Vz);
  176. if(DV > 0)
  177. {
  178. multiple = ((mph + DV * 100) / (DV * 100));
  179. return SetVehicleVelocity(vehicleid,Vx*multiple,Vy*multiple,Vz*multiple);
  180. }
  181. return 0;
  182. }
  183. stock IsVehicleDrivingBackwards(vehicleid)
  184. {
  185. new
  186. Float:Float[3]
  187. ;
  188. if(GetVehicleVelocity(vehicleid, Float[1], Float[2], Float[0]))
  189. {
  190. GetVehicleZAngle(vehicleid, Float[0]);
  191. if(Float[0] < 90)
  192. {
  193. if(Float[1] > 0 && Float[2] < 0) return true;
  194. }
  195. else if(Float[0] < 180)
  196. {
  197. if(Float[1] > 0 && Float[2] > 0) return true;
  198. }
  199. else if(Float[0] < 270)
  200. {
  201. if(Float[1] < 0 && Float[2] > 0) return true;
  202. }
  203. else if(Float[1] < 0 && Float[2] < 0) return true;
  204. }
  205. return false;
  206. }
  207. stock GetVehicleSpeed(vehicleid, get3d)
  208. {
  209. new Float:x, Float:y, Float:z;
  210. GetVehicleVelocity(vehicleid, x, y, z);
  211. return SpeedCheck(x, y, z, 100.0, get3d);
  212. }
  213.  
  214. IsAPlane(carid)
  215. {
  216. switch(GetVehicleModel(carid)) {
  217. case 592, 577, 511, 512, 593, 520, 553, 476, 519, 460, 513, 548, 425, 417, 487, 488, 497, 563, 447, 469: return 1;
  218. }
  219. return 0;
  220. }
  221.  
  222. public OnPlayerUpdate(playerid)
  223. {
  224. new string[128];
  225. BrzinaLimit[playerid] = Brzina[GetPlayerVehicleID(playerid)] * VOZILO_BRZINA;
  226. if(Brzina[GetPlayerVehicleID(playerid)] == -1)
  227. {
  228. BrzinaLimit[playerid] = 0;
  229. }
  230. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  231. {
  232. new a, b, c;
  233. GetPlayerKeys(playerid, a, b ,c);
  234. if(IsVehicleDrivingBackwards(GetPlayerVehicleID(playerid)))
  235. {
  236. if(Brzina[GetPlayerVehicleID(playerid)] == -1)
  237. {
  238. return 1;
  239. }
  240. else
  241. {
  242. ModifyVehicleSpeed(GetPlayerVehicleID(playerid), - GetVehicleSpeed(GetPlayerVehicleID(playerid), 0));
  243. }
  244. }
  245. if(a == 8 && GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) > BrzinaLimit[playerid])
  246. {
  247. if(IsVehicleDrivingBackwards(GetPlayerVehicleID(playerid)))
  248. {
  249. if(Brzina[GetPlayerVehicleID(playerid)] != -1) return ModifyVehicleSpeed(GetPlayerVehicleID(playerid), - GetVehicleSpeed(GetPlayerVehicleID(playerid), 0));
  250. }
  251. if(!IsVehicleDrivingBackwards(GetPlayerVehicleID(playerid)))
  252. {
  253. if(Brzina[GetPlayerVehicleID(playerid)] == -1) return ModifyVehicleSpeed(GetPlayerVehicleID(playerid), - GetVehicleSpeed(GetPlayerVehicleID(playerid), 0));
  254. }
  255. new newspeed = GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) - BrzinaLimit[playerid];
  256. ModifyVehicleSpeed(GetPlayerVehicleID(playerid), -newspeed);
  257. }
  258. if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 510 || !IsAPlane(GetPlayerVehicleID(playerid)))
  259. {
  260. if(IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid))
  261. {
  262. TextDrawShowForPlayer(playerid,Brzinatxd[playerid]);
  263. format(string,sizeof(string),"Brzina: %d",Brzina[GetPlayerVehicleID(playerid)]);
  264. if(Brzina[GetPlayerVehicleID(playerid)] == -1)
  265. {
  266. format(string,sizeof(string),"Brzina: R");
  267. }
  268. TextDrawSetString(Brzinatxd[playerid],string);
  269. }
  270. }
  271. else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510 || !IsAPlane(GetPlayerVehicleID(playerid)))
  272. {
  273. BrzinaLimit[playerid] = 999;
  274. }
  275. return 1;
  276. }
  277. if(!IsPlayerInAnyVehicle(playerid))
  278. {
  279. TextDrawHideForPlayer(playerid,Brzinatxd[playerid]);
  280. }
  281. return 1;
  282. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement