Guest User

[FS] Speedometer v2.0 EN

a guest
Jun 9th, 2015
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 26.66 KB | None | 0 0
  1. // SPEEDOMETER CREATED BY Atom (Scott_Walker)
  2. // version 2.0
  3.  
  4. // Copyright
  5.  
  6. #include <a_samp>
  7.  
  8.  
  9. #define GasMax          100                 // Fuel capacity
  10. #define RunOutTime      12000               // Fuel spending timer
  11. #define RefuelWait      8000                // Gas statio refill time
  12. #define CAR_AMOUNT      1000                // Vehicle amount on server
  13. #define D_FuelStation   4564                // 4564 defines ID of that dialog
  14.  
  15. #define SCM     SendClientMessage           // shortcuts
  16. #define SCMTA   SendClientMessageToAll      // shortcuts
  17. #define GPN     GetPlayerName               // shortcuts
  18. #define SPD     ShowPlayerDialog            // shortcuts
  19. #define DSL     DIALOG_STYLE_LIST           // shortcuts
  20. #define DSI     DIALOG_STYLE_INPUT          // shortcuts
  21. #define DSM     DIALOG_STYLE_MSGBOX         // shortcuts
  22.  
  23. #define COLOR_SPEEDOBLUE        0x0098FFFF  // Blue color for health bar
  24. #define COLOR_SPEEDOGREEN       0x32CD32FF  // Green color for fuel bar
  25. #define COLOR_RED               0xCC0000FF  // Red color for TOTALED vehicle
  26.  
  27. ////////////////////////////////////////////////////////////////////////////////
  28. //                  Variables
  29. ////////////////////////////////////////////////////////////////////////////////
  30. new Gas[CAR_AMOUNT];
  31. new Text: Atomspeedtankline[MAX_PLAYERS];
  32. new Text: Atomkmph[MAX_PLAYERS];
  33. new Text: Atomkmphs;
  34. new Text: Atomvehiclename[MAX_PLAYERS];
  35. new Text: Atompowerline[MAX_PLAYERS];
  36. new Text: Atompowerlines;
  37. new Text: Atompowerlinestext;
  38. new Text: Atomspeedtankstext;
  39. new Text: Atomspeedtank;
  40. new Text: Atombox;
  41. new FORTIMER;
  42. new Float:Velocity [3];
  43. new gGas[MAX_PLAYERS];
  44. new NoFuel[MAX_PLAYERS];
  45. new totaledveh[MAX_VEHICLES];
  46. new refueling[MAX_PLAYERS];
  47. new checkgastimer;
  48. new stoppedvehtimer;
  49. new FuelStation[MAX_PLAYERS];
  50. new MoneyForFuel[MAX_PLAYERS];
  51. new totaled[MAX_PLAYERS];
  52. new Vehicles[212][]=
  53. {
  54. {"Landstalker"},
  55. {"Bravura"},
  56. {"Buffalo"},
  57. {"Linerunner"},
  58. {"Perrenial"},
  59. {"Sentinel"},
  60. {"Dumper"},
  61. {"Firetruck"},
  62. {"Trashmaster"},
  63. {"Stretch"},
  64. {"Manana"},
  65. {"Infernus"},
  66. {"Voodoo"},
  67. {"Pony"},
  68. {"Mule"},
  69. {"Cheetah"},
  70. {"Ambulance"},
  71. {"Leviathan"},
  72. {"Moonbeam"},
  73. {"Esperanto"},
  74. {"Taxi"},
  75. {"Washington"},
  76. {"Bobcat"},
  77. {"Mr. Whoopee"},
  78. {"BF.Injection"},
  79. {"Hunter"},
  80. {"Premier"},
  81. {"Enforcer"},
  82. {"Securicar"},
  83. {"Banshee"},
  84. {"Predator"},
  85. {"Bus"},
  86. {"Rhino"},
  87. {"Barracks"},
  88. {"Hotknife"},
  89. {"Article Trailer"},
  90. {"Previon"},
  91. {"Coach"},
  92. {"Cabbie"},
  93. {"Stallion"},
  94. {"Rumpo"},
  95. {"RC Bandit"},
  96. {"Romero"},
  97. {"Packer"},
  98. {"Monster"},
  99. {"Admiral"},
  100. {"Squalo"},
  101. {"Seasparrow"},
  102. {"Pizzaboy"},
  103. {"Tram"},
  104. {"Article Trailer2"},
  105. {"Turismo"},
  106. {"Speeder"},
  107. {"Reefer"},
  108. {"Tropic"},
  109. {"Flatbed"},
  110. {"Yankee"},
  111. {"Caddy"},
  112. {"Solair"},
  113. {"Berkley's RC Van"},
  114. {"Skimmer"},
  115. {"PCJ-600"},
  116. {"Faggio"},
  117. {"Freeway"},
  118. {"RC Baron"},
  119. {"RC Raider"},
  120. {"Glendale"},
  121. {"Oceanic"},
  122. {"Sanchez"},
  123. {"Sparrow"},
  124. {"Patriot"},
  125. {"Quad"},
  126. {"Coastguard"},
  127. {"Dinghy"},
  128. {"Hermes"},
  129. {"Sabre"},
  130. {"Rustler"},
  131. {"ZR-350"},
  132. {"Walton"},
  133. {"Regina"},
  134. {"Comet"},
  135. {"BMX"},
  136. {"Burrito"},
  137. {"Camper"},
  138. {"Marquis"},
  139. {"Baggage"},
  140. {"Dozer"},
  141. {"Maverick"},
  142. {"News Chopper"},
  143. {"Rancher"},
  144. {"FBI Rancher"},
  145. {"Virgo"},
  146. {"Greenwood"},
  147. {"Jetmax"},
  148. {"Hotring"},
  149. {"Sandking"},
  150. {"Blista Compact"},
  151. {"PD Maverick"},
  152. {"Boxville"},
  153. {"Benson"},
  154. {"Mesa"},
  155. {"RC Goblin"},
  156. {"Hotring Racer A"},
  157. {"Hotring Racer B"},
  158. {"Bloodring Banger"},
  159. {"Rancher"},
  160. {"Super GT"},
  161. {"Elegant"},
  162. {"Journey"},
  163. {"Bike"},
  164. {"MountainBike"},
  165. {"Beagle"},
  166. {"Cropdust"},
  167. {"Stunt"},
  168. {"Tanker"},
  169. {"Roadtrain"},
  170. {"Nebula"},
  171. {"Majestic"},
  172. {"Buccaneer"},
  173. {"Shamal"},
  174. {"Hydra"},
  175. {"FCR-900"},
  176. {"NRG-500"},
  177. {"HPV1000"},
  178. {"Cement Truck"},
  179. {"Tow Truck"},
  180. {"Fortune"},
  181. {"Cadrona"},
  182. {"FBI Truck"},
  183. {"Willard"},
  184. {"Forklift"},
  185. {"Tractor"},
  186. {"Combine"},
  187. {"Feltzer"},
  188. {"Remington"},
  189. {"Slamvan"},
  190. {"Blade"},
  191. {"Freight"},
  192. {"Streak"},
  193. {"Vortex"},
  194. {"Vincent"},
  195. {"Bullet"},
  196. {"Clover"},
  197. {"Sadler"},
  198. {"Firetruck"},
  199. {"Hustler"},
  200. {"Intruder"},
  201. {"Primo"},
  202. {"Cargobob"},
  203. {"Tampa"},
  204. {"Sunrise"},
  205. {"Merit"},
  206. {"Utility"},
  207. {"Nevada"},
  208. {"Yosemite"},
  209. {"Windsor"},
  210. {"Monster A"},
  211. {"Monster B"},
  212. {"Uranus"},
  213. {"Jester"},
  214. {"Sultan"},
  215. {"Stratum"},
  216. {"Elegy"},
  217. {"Raindance"},
  218. {"RC Tiger"},
  219. {"Flash"},
  220. {"Tahoma"},
  221. {"Savanna"},
  222. {"Bandito"},
  223. {"Freight Flat"},
  224. {"Streak Carriage"},
  225. {"Kart"},{"Mower"},
  226. {"Dunerider"},
  227. {"Sweeper"},
  228. {"Broadway"},
  229. {"Tornado"},
  230. {"AT-400"},
  231. {"DFT-30"},
  232. {"Huntley"},
  233. {"Stafford"},
  234. {"BF-400"},
  235. {"Newsvan"},
  236. {"Tug"},
  237. {"Article Trailer 3"},
  238. {"Emperor"},
  239. {"Wayfarer"},
  240. {"Euros"},
  241. {"Mobile Hotdog"},
  242. {"Club"},
  243. {"Freight Carriage"},
  244. {"Trailer 3"},
  245. {"Andromada"},
  246. {"Dodo"},
  247. {"RC Cam"},
  248. {"Launch"},
  249. {"Police Car"},
  250. {"Police Car"},
  251. {"Police Car"},
  252. {"Police Ranger"},
  253. {"Picador"},
  254. {"SWAT Van"},
  255. {"Alpha"},
  256. {"Phoenix"},
  257. {"Glendale"},
  258. {"Sadler"},
  259. {"Luggage Trailer A"},
  260. {"Luggage Trailer B"},
  261. {"Stair Trailer"},
  262. {"Boxville"},
  263. {"Farm Plow"},
  264. {"Utility Trailer"}
  265. };
  266. ////////////////////////////////////////////////////////////////////////////////
  267. //                  Forwards
  268. ////////////////////////////////////////////////////////////////////////////////
  269. forward CheckGas(playerid);
  270. forward Fillup();
  271. forward AtomSpeedometer(playerid);
  272. forward IsAtGasStation(playerid);
  273. forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
  274. ////////////////////////////////////////////////////////////////////////////////
  275. //                  Publics
  276. ////////////////////////////////////////////////////////////////////////////////
  277. public OnFilterScriptInit()
  278. {
  279.     FORTIMER = SetTimer("AtomSpeedometer",400,1);
  280.     checkgastimer = SetTimer("CheckGas", RunOutTime, 1);
  281.     stoppedvehtimer = SetTimer("StoppedVehicle", RunOutTime, 1);
  282.     SetTimer("Speed",1500,1);
  283.  
  284.     /////////////////////////////////////////////////////////////////
  285.     //              Textdraws
  286.     /////////////////////////////////////////////////////////////////
  287.     Atombox = TextDrawCreate(558.000000,365,"_");
  288.     TextDrawLetterSize(Atombox,0.5,9.000000);
  289.     TextDrawUseBox(Atombox,1);
  290.     TextDrawBoxColor(Atombox,0x00000060);
  291.     TextDrawTextSize(Atombox,650,450);
  292.  
  293.     Atomkmphs = TextDrawCreate(615.000000, 425.000000, "km/h");
  294.     TextDrawBackgroundColor(Atomkmphs, 255);
  295.     TextDrawFont(Atomkmphs, 3);
  296.     TextDrawLetterSize(Atomkmphs, 0.200000, 1.000000);
  297.     TextDrawColor(Atomkmphs, 0xFFFFFFFF);
  298.     TextDrawSetOutline(Atomkmphs, 1);
  299.  
  300.     Atomspeedtankstext = TextDrawCreate(561.500000,365.000000,"fuel");
  301.     TextDrawBackgroundColor(Atomspeedtankstext, 255);
  302.     TextDrawFont(Atomspeedtankstext, 3);
  303.     TextDrawLetterSize(Atomspeedtankstext, 0.200000, 1.000000);
  304.     TextDrawColor(Atomspeedtankstext, 0xFFFFFFFF);
  305.     TextDrawSetOutline(Atomspeedtankstext, 1);
  306.  
  307.     Atompowerlinestext = TextDrawCreate(561.500000,385.000000,"power");
  308.     TextDrawBackgroundColor(Atompowerlinestext, 255);
  309.     TextDrawFont(Atompowerlinestext, 3);
  310.     TextDrawLetterSize(Atompowerlinestext, 0.200000, 1.000000);
  311.     TextDrawColor(Atompowerlinestext, 0xFFFFFFFF);
  312.     TextDrawSetOutline(Atompowerlinestext, 1);
  313.  
  314.     Atompowerlines = TextDrawCreate(559.500000,396.500000,"_");
  315.     TextDrawUseBox(Atompowerlines,1);
  316.     TextDrawBoxColor(Atompowerlines,0x000000ff);
  317.     TextDrawTextSize(Atompowerlines,635.500000,1.000000);
  318.     TextDrawAlignment(Atompowerlines,0);
  319.     TextDrawBackgroundColor(Atompowerlines,0x000000ff);
  320.     TextDrawFont(Atompowerlines,3);
  321.     TextDrawLetterSize(Atompowerlines,0.199999,0.600000);
  322.     TextDrawColor(Atompowerlines,0xffffffff);
  323.     TextDrawSetOutline(Atompowerlines,1);
  324.  
  325.     Atomspeedtank = TextDrawCreate(559.500000,376.500000,"_");
  326.     TextDrawUseBox(Atomspeedtank,1);
  327.     TextDrawBoxColor(Atomspeedtank,0x000000ff);
  328.     TextDrawTextSize(Atomspeedtank,635.500000,1.000000);
  329.     TextDrawAlignment(Atomspeedtank,0);
  330.     TextDrawBackgroundColor(Atomspeedtank,0x000000ff);
  331.     TextDrawFont(Atomspeedtank,3);
  332.     TextDrawLetterSize(Atomspeedtank,0.199999,0.600000);
  333.     TextDrawColor(Atomspeedtank,0xffffffff);
  334.     TextDrawSetOutline(Atomspeedtank,1);
  335.  
  336.     for(new i=0; i<GetMaxPlayers(); i++)
  337.     {
  338.         Atompowerline[i] = TextDrawCreate(560.000000,397.500000,"_");
  339.         TextDrawUseBox(Atompowerline[i],1);
  340.         TextDrawBoxColor(Atompowerline[i],COLOR_SPEEDOBLUE);
  341.         TextDrawAlignment(Atompowerline[i],0);
  342.         TextDrawBackgroundColor(Atompowerline[i],0x000000ff);
  343.         TextDrawFont(Atompowerline[i],3);
  344.         TextDrawLetterSize(Atompowerline[i],1.000000,0.3);
  345.         TextDrawColor(Atompowerline[i],0xffffffff);
  346.         TextDrawSetOutline(Atompowerline[i],1);
  347.  
  348.         Atomspeedtankline[i] = TextDrawCreate(560.000000,377.50000,"_");
  349.         TextDrawUseBox(Atomspeedtankline[i],1);
  350.         TextDrawBoxColor(Atomspeedtankline[i],COLOR_SPEEDOGREEN);
  351.         TextDrawAlignment(Atomspeedtankline[i],0);
  352.         TextDrawBackgroundColor(Atomspeedtankline[i],0x000000ff);
  353.         TextDrawFont(Atomspeedtankline[i],3);
  354.         TextDrawLetterSize(Atomspeedtankline[i],1.000000,0.3);
  355.         TextDrawColor(Atomspeedtankline[i],0xffffffff);
  356.         TextDrawSetOutline(Atomspeedtankline[i],1);
  357.  
  358.         Atomkmph[i] = TextDrawCreate(565.000000, 400.000000, "_");
  359.         TextDrawBackgroundColor(Atomkmph[i], 255);
  360.         TextDrawFont(Atomkmph[i], 3);
  361.         TextDrawLetterSize(Atomkmph[i], 0.800000, 4.000000);
  362.         TextDrawColor(Atomkmph[i], 0xFFFFFFFF);
  363.         TextDrawSetOutline(Atomkmph[i], 1);
  364.  
  365.         Atomvehiclename[i] = TextDrawCreate(565.000000, 435.000000, "_");
  366.         TextDrawBackgroundColor(Atomvehiclename[i], 255);
  367.         TextDrawFont(Atomvehiclename[i], 2);
  368.         TextDrawLetterSize(Atomvehiclename[i], 0.200000, 1.000000);
  369.         TextDrawColor(Atomvehiclename[i], 0xFFFFFFFF);
  370.         TextDrawSetOutline(Atomvehiclename[i], 1);
  371.     }
  372. /////////////////////////////////////////////////////////////////////////////
  373.  
  374.     for(new v=0;v<CAR_AMOUNT;v++)
  375.     {
  376.         Gas[v] = GasMax;
  377.         new engine, lights, alarm, doors, bonnet, boot, objective;
  378.         GetVehicleParamsEx(v,engine,lights, alarm, doors, bonnet, boot, objective);
  379.         SetVehicleParamsEx(v, 0, lights, alarm, doors, bonnet, boot, objective); // ONLY the engine param was changed (to 1)
  380.     }
  381.  
  382.     print("\n--------------------------------------");
  383.     print(" Speedometer by Atom uploaded");
  384.     print("--------------------------------------\n");
  385.     return 1;
  386. }
  387.  
  388. public OnFilterScriptExit()
  389. {
  390.     return 1;
  391. }
  392.  
  393. public OnGameModeInit()
  394. {
  395.     // Don't use these lines if it's a filterscript
  396.     return 1;
  397. }
  398.  
  399. public OnGameModeExit()
  400. {
  401.     KillTimer(checkgastimer);
  402.     KillTimer(stoppedvehtimer);
  403.     KillTimer(FORTIMER);
  404.     return 1;
  405. }
  406.  
  407. public OnPlayerConnect(playerid)
  408. {
  409.     gGas[playerid] = 0;
  410.     return 1;
  411. }
  412.  
  413. public OnPlayerCommandText(playerid, cmdtext[])
  414. {
  415.     if (strcmp("/fill", cmdtext, true, 10))
  416.     {
  417.         new string[128];
  418.         new engine, lights, alarm, doors, bonnet, boot, objective;
  419.         if(IsPlayerConnected(playerid))
  420.         {
  421.             if(IsAtGasStation(playerid))
  422.             {
  423.                 new vehicle = GetPlayerVehicleID(playerid);
  424.                 if(Gas[vehicle] <= 99)
  425.                 {
  426.                     MoneyForFuel[playerid] = GasMax - Gas[vehicle];
  427.                     format(string, sizeof(string),"{C9FFAB}Enter price to refill.\nMaximum amount of price is %d.", MoneyForFuel[playerid]);
  428.                     SPD(playerid,D_FuelStation,DSI,"Gas tank refill",string,"Pick","Quit");
  429.                     GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  430.                     SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, objective); // ONLY the engine param was changed (to 1)
  431.                 }
  432.                 else
  433.                 {
  434.                     GameTextForPlayer(playerid,"~g~~n~~n~~n~~n~~n~Tank is full.",3000,3);
  435.                 }
  436.             }
  437.             else
  438.             {
  439.                 SendClientMessage(playerid,-1,"{C3C3C3}You are not on a gas station.");
  440.             }
  441.         }
  442.         else SCM(playerid, -1, "{FFAF00}NR{FFFFFF}: Command /fill do not exist.");
  443.         return 1;
  444.     }
  445.     return 1;
  446. }
  447.  
  448. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  449. {
  450.     return 1;
  451. }
  452.  
  453. public OnPlayerExitVehicle(playerid, vehicleid)
  454. {
  455.     return 1;
  456. }
  457.  
  458. public OnPlayerStateChange(playerid, newstate, oldstate)
  459. {
  460.     return 1;
  461. }
  462.  
  463. public OnPlayerEnterCheckpoint(playerid)
  464. {
  465.     return 1;
  466. }
  467.  
  468. public OnPlayerLeaveCheckpoint(playerid)
  469. {
  470.     return 1;
  471. }
  472.  
  473. public OnPlayerEnterRaceCheckpoint(playerid)
  474. {
  475.     return 1;
  476. }
  477.  
  478. public OnPlayerLeaveRaceCheckpoint(playerid)
  479. {
  480.     return 1;
  481. }
  482.  
  483. public OnRconCommand(cmd[])
  484. {
  485.     return 1;
  486. }
  487.  
  488. public OnPlayerRequestSpawn(playerid)
  489. {
  490.     return 1;
  491. }
  492.  
  493. public OnObjectMoved(objectid)
  494. {
  495.     return 1;
  496. }
  497.  
  498. public OnPlayerObjectMoved(playerid, objectid)
  499. {
  500.     return 1;
  501. }
  502.  
  503. public OnPlayerPickUpPickup(playerid, pickupid)
  504. {
  505.     return 1;
  506. }
  507.  
  508. public OnVehicleMod(playerid, vehicleid, componentid)
  509. {
  510.     return 1;
  511. }
  512.  
  513. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  514. {
  515.     return 1;
  516. }
  517.  
  518. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  519. {
  520.     return 1;
  521. }
  522.  
  523. public OnPlayerSelectedMenuRow(playerid, row)
  524. {
  525.     return 1;
  526. }
  527.  
  528. public OnPlayerExitedMenu(playerid)
  529. {
  530.     return 1;
  531. }
  532.  
  533. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  534. {
  535.     return 1;
  536. }
  537.  
  538. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  539. {
  540.     new vehicle = GetPlayerVehicleID(playerid);
  541.     new engine, lights, alarm, doors, bonnet, boot, objective;
  542.     if(IsPlayerInAnyVehicle(playerid))
  543.     {
  544.         if(newkeys == KEY_NO)
  545.         {
  546.             if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && Bike(vehicle))
  547.             {
  548.                 new Float: health;
  549.                 GetVehicleHealth(vehicle, health);
  550.                 GetVehicleParamsEx(vehicle,engine,lights, alarm, doors, bonnet, boot, objective);
  551.                 if(engine == 0)
  552.                 {
  553.                     if(health <= 350)
  554.                     {
  555.                         SendClientMessage(playerid,-1,"{F3FF02}Obavijest{FFFFFF}: Vehicle is too damaged, you can not start it.");
  556.                     }
  557.                     else if(Gas[vehicle] < 3)
  558.                     {
  559.                         SendClientMessage(playerid,-1,"{F3FF02}Obavijest{FFFFFF}: You can not start the vehicle, gas tank is empty.");
  560.                     }
  561.                     else
  562.                     {
  563.                         SendClientMessage(playerid,-1,"{F3FF02}Note{FFFFFF}: You started the vehicle engine.");
  564.                         GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  565.                         SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, objective);
  566.                     }
  567.                 }
  568.                 else
  569.                 {
  570.                     SendClientMessage(playerid,-1,"{F3FF02}Note{FFFFFF}: You turned off the vehicle engine.");
  571.                     SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, objective);
  572.                 }
  573.             }
  574.         }
  575.     }
  576.     return 1;
  577. }
  578.  
  579. public OnRconLoginAttempt(ip[], password[], success)
  580. {
  581.     return 1;
  582. }
  583.  
  584. public OnPlayerUpdate(playerid)
  585. {
  586.     return 1;
  587. }
  588.  
  589. public OnPlayerStreamIn(playerid, forplayerid)
  590. {
  591.     return 1;
  592. }
  593.  
  594. public OnPlayerStreamOut(playerid, forplayerid)
  595. {
  596.     return 1;
  597. }
  598.  
  599. public OnVehicleStreamIn(vehicleid, forplayerid)
  600. {
  601.     return 1;
  602. }
  603.  
  604. public OnVehicleStreamOut(vehicleid, forplayerid)
  605. {
  606.     return 1;
  607. }
  608.  
  609. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  610. {
  611.     new string[2048];
  612.     new engine, lights, alarm, doors, bonnet, boot, objective;
  613.     new vehicle = GetPlayerVehicleID(playerid);
  614.     new money = GetPlayerMoney(playerid);
  615.     switch(dialogid)
  616.     {
  617.         case D_FuelStation:
  618.         {
  619.             if(response)
  620.             {
  621.                 MoneyForFuel[playerid] = GasMax - Gas[vehicle];
  622.                 if(strval(inputtext) > 0 && strval(inputtext) <= MoneyForFuel[playerid])
  623.                 {
  624.                     if(money > MoneyForFuel[playerid])
  625.                     {
  626.                         GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  627.                         SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, objective); // ONLY the engine param was changed (to 1)
  628.                         GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~Gas tank refilling...",3000,3);
  629.                         SetTimer("Fillup",RefuelWait,0);
  630.                         refueling[playerid] = 1;
  631.                         FuelStation[playerid] = strval(inputtext);
  632.                     }
  633.                     else
  634.                     {
  635.                         format(string,sizeof(string),"{C9FFAB}You do not have enough money, you need $%d",MoneyForFuel[playerid]);
  636.                         SCM(playerid,-1,string);
  637.                     }
  638.                 }
  639.                 else
  640.                 {
  641.                     format(string, sizeof(string),"{C9FFAB}You entered too large amount.\n\nEnter price to refill.\nMaximum amount of price is %d.", MoneyForFuel[playerid]);
  642.                     SPD(playerid,D_FuelStation,DSI,"Gas tank refill",string,"Pick","Quit");
  643.                 }
  644.             }
  645.             else
  646.             {
  647.                 GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  648.                 SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, objective); // ONLY the engine param was changed (to 1)
  649.             }
  650.         }
  651.     }
  652.     return 1;
  653. }
  654.  
  655. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  656. {
  657.     return 1;
  658. }
  659. public Fillup()
  660. {
  661.     for(new i=0; i<GetMaxPlayers(); i++)
  662.     {
  663.         new string[128];
  664.         new vehicle = GetPlayerVehicleID(i);
  665.         if(refueling[i] == 1)
  666.         {
  667.             Gas[vehicle] += FuelStation[i];
  668.             format(string,sizeof(string),"{C9FFAB}Your vehicle is filled, price: %d$",FuelStation[i]);
  669.             SCM(i,-1,string);
  670.             GivePlayerMoney(i, - FuelStation[i]);
  671.             refueling[i] = 0;
  672.             new engine, lights, alarm, doors, bonnet, boot, objective;
  673.             GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  674.             SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, objective); // ONLY the engine param was changed (to 1)
  675.         }
  676.     }
  677.     return 1;
  678. }
  679. public CheckGas(playerid)
  680. {
  681.     new engine, lights, alarm, doors, bonnet, boot, objective;
  682.     for(new i=0; i<GetMaxPlayers(); i++)
  683.     {
  684.         new vehicle = GetPlayerVehicleID(i);
  685.         if(GetPlayerState(i) == PLAYER_STATE_DRIVER && Bike(vehicle))
  686.         {
  687.             GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  688.             if(engine == 1)
  689.             {
  690.                 if(Gas[vehicle] >= 5)
  691.                 {
  692.                     if(Gas[vehicle] <= 13)
  693.                     {
  694.                         PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
  695.                         if(gGas[i] == 0)
  696.                         {
  697.                             GameTextForPlayer(i,"~r~~n~~n~~n~~n~~n~~n~~n~~n~~n~Low Gas",5000,3);
  698.                         }
  699.                     }
  700.                     Gas[vehicle]--;
  701.                 }
  702.                 else
  703.                 {
  704.                     NoFuel[i] = 1;
  705.                     SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, objective); // ONLY the engine param was changed (to 1)
  706.                     GameTextForPlayer(i,"~r~~n~~n~~n~~n~~n~~n~~n~~n~~n~Low Gas",1500,3);
  707.                 }
  708.             }
  709.         }
  710.     }
  711.     return 1;
  712. }
  713. public AtomSpeedometer(playerid)
  714. {
  715.     for(new i=0; i<GetMaxPlayers(); i++)
  716.     {
  717.         if(IsPlayerConnected(i))
  718.         {
  719.             if(IsPlayerInAnyVehicle(i))
  720.             {
  721.                 new vehicle = GetPlayerVehicleID(i);
  722.                 if(GetPlayerState(i) == PLAYER_STATE_DRIVER && Bike(vehicle))
  723.                 {
  724.                     new Float: health;
  725.                     GetVehicleHealth(GetPlayerVehicleID(i), health);
  726.                     if(health <= 350)
  727.                     {
  728.                         if(IsPlayerAdmin(i))
  729.                         {
  730.                             TextDrawTextSize(Atompowerline[i],578.750000,0.000000);
  731.                             SetVehicleHealth(vehicle,1000);
  732.                             RepairVehicle(vehicle);
  733.                         }
  734.                         else
  735.                         {
  736.                             TextDrawTextSize(Atompowerline[i],578.750000,0.000000);
  737.                             GameTextForPlayer(i,"~w~Press~n~~r~F / enter~n~~w~to leave the vehicle~n~~n~~n~~n~~n~~n~~n~~r~TOTALED",5000,3);
  738.                             SetVehicleHealth(vehicle,350);
  739.                             TextDrawBoxColor(Atompowerline[i],COLOR_RED);
  740.                             totaled[i] = 1;
  741.                             new engine, lights, alarm, doors, bonnet, boot, objective;
  742.                             GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  743.                             SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, objective); // ugasen motor
  744.                             totaledveh[vehicle] = 1;
  745.                         }
  746.                     }
  747.                     else if(health >= 1000)
  748.                     {
  749.                         TextDrawTextSize(Atompowerline[i],635.00000,0.000000);
  750.                         TextDrawBoxColor(Atompowerline[i],COLOR_SPEEDOBLUE);
  751.                     }
  752.                     else
  753.                     {
  754.                         TextDrawBoxColor(Atompowerline[i],COLOR_SPEEDOBLUE);
  755.                         TextDrawTextSize(Atompowerline[i],floatadd(560.0, floatdiv(health, 13.333333)),0.000000);
  756.                     }
  757.                     if(Gas[vehicle] <= 13)
  758.                     {
  759.                         TextDrawTextSize(Atomspeedtankline[i],560.000000,0.000000);
  760.                         TextDrawBoxColor(Atomspeedtankline[i],COLOR_RED);
  761.                     }
  762.                     else if(Gas[vehicle] >= 100)
  763.                     {
  764.                         TextDrawTextSize(Atomspeedtankline[i],635.00000,0.000000);
  765.                         TextDrawBoxColor(Atomspeedtankline[i],COLOR_SPEEDOGREEN);
  766.                     }
  767.                     else
  768.                     {
  769.                         TextDrawTextSize(Atomspeedtankline[i],floatadd(560.0, floatdiv(Gas[vehicle], 1.3333333333)),0.000000);
  770.                         TextDrawBoxColor(Atomspeedtankline[i],COLOR_SPEEDOGREEN);
  771.                     }
  772.                     new velocityAtom[64],speed = GetSpeed(i);
  773.                     format(velocityAtom,64,"%d", speed);
  774.                     TextDrawSetString(Atomkmph[i], velocityAtom);
  775.                     new modelAtom[16];
  776.                     format(modelAtom,16,"%s", Vehicles[GetVehicleModel(GetPlayerVehicleID(i)) - 400]);
  777.                     TextDrawSetString(Atomvehiclename[i], modelAtom);
  778.                     TextDrawShowForPlayer(i, Atompowerline[i]);
  779.                     TextDrawShowForPlayer(i, Atompowerlines);
  780.                     TextDrawShowForPlayer(i, Atomkmph[i]);
  781.                     TextDrawShowForPlayer(i, Atomkmphs);
  782.                     TextDrawShowForPlayer(i, Atombox);
  783.                     TextDrawShowForPlayer(i, Atompowerlinestext);
  784.                     TextDrawShowForPlayer(i, Atomspeedtank);
  785.                     TextDrawShowForPlayer(i, Atomspeedtankstext);
  786.                     TextDrawShowForPlayer(i, Atomvehiclename[i]);
  787.                     TextDrawShowForPlayer(i, Atomspeedtankline[i]);
  788.                 }
  789.             }
  790.             else
  791.             {
  792.                 TextDrawHideForPlayer(i, Atompowerline[i]);
  793.                 TextDrawHideForPlayer(i, Atompowerlines);
  794.                 TextDrawHideForPlayer(i, Atomkmph[i]);
  795.                 TextDrawHideForPlayer(i, Atomkmphs);
  796.                 TextDrawHideForPlayer(i, Atombox);
  797.                 TextDrawHideForPlayer(i, Atompowerlinestext);
  798.                 TextDrawHideForPlayer(i, Atomspeedtank);
  799.                 TextDrawHideForPlayer(i, Atomspeedtankstext);
  800.                 TextDrawHideForPlayer(i, Atomvehiclename[i]);
  801.                 TextDrawHideForPlayer(i, Atomspeedtankline[i]);
  802.             }
  803.         }
  804.     }
  805.     return 1;
  806. }
  807.  
  808. public IsAtGasStation(playerid)
  809. {
  810.     if(IsPlayerConnected(playerid))
  811.     {
  812.         if(PlayerToPoint(6.0,playerid,1004.0070,-939.3102,42.1797) || PlayerToPoint(6.0,playerid,1944.3260,-1772.9254,13.3906))
  813.         {//LS
  814.             return 1;
  815.         }
  816.         else if(PlayerToPoint(6.0,playerid,-90.5515,-1169.4578,2.4079) || PlayerToPoint(6.0,playerid,-1609.7958,-2718.2048,48.5391))
  817.         {//LS
  818.             return 1;
  819.         }
  820.         else if(PlayerToPoint(6.0,playerid,-2029.4968,156.4366,28.9498) || PlayerToPoint(8.0,playerid,-2408.7590,976.0934,45.4175))
  821.         {//SF
  822.             return 1;
  823.         }
  824.         else if(PlayerToPoint(5.0,playerid,-2243.9629,-2560.6477,31.8841) || PlayerToPoint(8.0,playerid,-1676.6323,414.0262,6.9484))
  825.         {//Between LS and SF
  826.             return 1;
  827.         }
  828.         else if(PlayerToPoint(6.0,playerid,2202.2349,2474.3494,10.5258) || PlayerToPoint(10.0,playerid,614.9333,1689.7418,6.6968))
  829.         {//LV
  830.             return 1;
  831.         }
  832.         else if(PlayerToPoint(8.0,playerid,-1328.8250,2677.2173,49.7665) || PlayerToPoint(6.0,playerid,70.3882,1218.6783,18.5165))
  833.         {//LV
  834.             return 1;
  835.         }
  836.         else if(PlayerToPoint(8.0,playerid,2113.7390,920.1079,10.5255) || PlayerToPoint(6.0,playerid,-1327.7218,2678.8723,50.0625))
  837.         {//LV
  838.             return 1;
  839.         }
  840.         else if(PlayerToPoint(8.0,playerid,656.4265,-559.8610,16.5015) || PlayerToPoint(6.0,playerid,656.3797,-570.4138,16.5015))
  841.         {//Dillimore
  842.             return 1;
  843.         }
  844.         else if(PlayerToPoint(8.0,playerid,125.2434463501, -1935.9764404297, 2.6310691833496) || PlayerToPoint(8.0,playerid,133.91174316406, -1941.7890625, 2.6310691833496))
  845.         {//Pumpa za Helice
  846.             return 1;
  847.         }
  848.         else if(PlayerToPoint(8.0,playerid,1004.1514892578, -936.96557617188, 47.211837768555))
  849.         {//Pumpa za Helice
  850.             return 1;
  851.         }
  852.         else if(PlayerToPoint(8.0,playerid,2638.9402345345, 1106.41373453456, 10.543724234534))
  853.         {//LV
  854.             return 1;
  855.         }
  856.         else if(PlayerToPoint(8.0,playerid,-1471.315834534, 1864.20734534538, 32.359456456649))
  857.         {//LV
  858.             return 1;
  859.         }
  860.         else if(PlayerToPoint(8.0,playerid,1593.8060574677, 2199.42504563487, 10.547347895345))
  861.         {//LV
  862.             return 1;
  863.         }
  864.     }
  865.     return 0;
  866. }
  867. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  868. {
  869.     if(IsPlayerConnected(playerid))
  870.     {
  871.         new Float:oldposx, Float:oldposy, Float:oldposz;
  872.         new Float:tempposx, Float:tempposy, Float:tempposz;
  873.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  874.         tempposx = (oldposx -x);
  875.         tempposy = (oldposy -y);
  876.         tempposz = (oldposz -z);
  877.         //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  878.         if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  879.         {
  880.             return 1;
  881.         }
  882.     }
  883.     return 0;
  884. }
  885. stock Bike(veh)
  886. {
  887.     new no[] = { 481,509,510 };
  888.     for(new e = 0; e < sizeof(no); e++)
  889.     {
  890.         if(GetVehicleModel(veh) == no[e]) return 0;
  891.     }
  892.     return 1;
  893. }
  894. stock Auti(veh)
  895. {
  896.     new car[] = { 400,401,402,404,405,409,410,411,412,413,414,415,416,418,419,420,421,422,426,429,436,438,439,440,442,445,451,458,459,466,467,470,474,475,477,479,480,482,483,489,490,491,492,494,495,496,498,499,500,502,503,504,505,506,507,516,517,518,526,527,529,533,534,535,536,540,541,542,543,545,546,547,549,550,551,552,554,555,558,559,560,561,562,565,566,567,575,576,579,580,582,585,587,589,596,597,598,599,600,602,603,604,605 };
  897.     for(new e = 0; e < sizeof(car); e++)
  898.     {
  899.         if(GetVehicleModel(veh) == car[e]) return 0;
  900.     }
  901.     return 1;
  902. }
  903. stock Brodovi(veh)
  904. {
  905.     new car[] = { 430,446,452,453,454,472,473,484,493,508,514,515,595 };
  906.     for(new e = 0; e < sizeof(car); e++)
  907.     {
  908.         if(GetVehicleModel(veh) == car[e]) return 0;
  909.     }
  910.     return 1;
  911. }
  912. stock Motori(veh)
  913. {
  914.     new car[] = { 448,461,462,463,468,471,521,522,523,528,531,532,568,571,581,586 };
  915.     for(new e = 0; e < sizeof(car); e++)
  916.     {
  917.         if(GetVehicleModel(veh) == car[e]) return 0;
  918.     }
  919.     return 1;
  920. }
  921. stock Kamioni(veh)
  922. {
  923.     new car[] = { 403,406,407,408,423,424,427,428,431,432,433,434,437,443,444,455,456,457,478,485,486,524,525,537,538,543,556,557,568,573,574,578,583,588,601,609 };
  924.     for(new e = 0; e < sizeof(car); e++)
  925.     {
  926.         if(GetVehicleModel(veh) == car[e]) return 0;
  927.     }
  928.     return 1;
  929. }
  930. stock Letjelice(veh)
  931. {
  932.     new car[] = { 417,425,447,460,469,476,487,488,497,511,512,513,519,520,548,553,563,577,592,593 };
  933.     for(new e = 0; e < sizeof(car); e++)
  934.     {
  935.         if(GetVehicleModel(veh) == car[e]) return 0;
  936.     }
  937.     return 1;
  938. }
  939. stock GetSpeed (playerid, mod = 1)
  940. {
  941.     GetVehicleVelocity ( GetPlayerVehicleID ( playerid ) , Velocity [ 0 ] , Velocity [ 1 ] , Velocity [ 2 ] ) ;
  942.     return IsPlayerInAnyVehicle ( playerid ) ? floatround ( ( ( floatsqroot ( ( ( Velocity [ 0 ] * Velocity [ 0 ] ) + ( Velocity [ 1 ] * Velocity [ 1 ] ) + ( Velocity [ 2 ] * Velocity [ 2 ] ) ) ) * ( !mod ? 105.0 : 170.0 ) ) ) * 1 ) : 0;
  943. }
Advertisement
Add Comment
Please, Sign In to add comment