Advertisement
Guest User

Velocímetro v1.0.

a guest
Apr 4th, 2013
1,235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.07 KB | None | 0 0
  1. #include <a_samp>
  2. #include <progress3>
  3. #include <zcmd>
  4. //=====================//
  5. #define HOLDING(%0) \
  6. ((newkeys & (%0)) == (%0))
  7. #define RELEASED(%0) \
  8. (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  9. //=====================//
  10.  
  11. new Text:Vehiculo[MAX_PLAYERS],
  12. Text:Velocidad[MAX_PLAYERS],
  13. Text:Espacio[MAX_PLAYERS],
  14. Text:Espacio2[MAX_PLAYERS],
  15. Text:Gasolina[MAX_PLAYERS],
  16. Text:Espacio3[MAX_PLAYERS],
  17. Text:Espacio4[MAX_PLAYERS],
  18. Text:Estado[MAX_PLAYERS],
  19. Text:Espacio5[MAX_PLAYERS],
  20. Text:Espacio6[MAX_PLAYERS],
  21. Text:Espacio7[MAX_PLAYERS],
  22. PlayerBar:Velocidadbar[MAX_PLAYERS],
  23. PlayerBar:Gasolinabar[MAX_PLAYERS],
  24. PlayerBar:Estadobar[MAX_PLAYERS],
  25. TimerVelocidad,
  26. Gas[MAX_VEHICLES],
  27. GasBajo,
  28. Rellenando[MAX_PLAYERS] = 0,
  29. RellenoTimer[MAX_PLAYERS],
  30. PlayerBar:MotorBar[MAX_PLAYERS],
  31. vMotor[MAX_VEHICLES],
  32. Enciende[MAX_PLAYERS],
  33. Apagar[MAX_PLAYERS],
  34. MotorAuto[MAX_VEHICLES];
  35. forward GasolinaBaja();
  36. forward TiempoRelleno(playerid);
  37.  
  38.  
  39. new Vehicles[][] =
  40. {
  41. "Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster",
  42. "Stretch","Manana","Infernus","Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto",
  43. "Taxi","Washington","Bobcat","Mr Whoopee","BF Injection","Hunter","Premier","Enforcer","Securicar","Banshee",
  44. "Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie","Stallion","Rumpo",
  45. "RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer",
  46. "Turismo","Speeder","Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van","Skimmer",
  47. "PCJ-600","Faggio","Freeway","RC Baron","RC Raider","Glendale","Oceanic","Sanchez","Sparrow","Patriot",
  48. "Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR3 50","Walton","Regina","Comet","BMX",
  49. "Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo",
  50. "Greenwood","Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson","Mesa",
  51. "RC Goblin","Hotring Racer A","Hotring Racer B","Bloodring Banger","Rancher","Super GT","Elegant",
  52. "Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain","Nebula","Majestic",
  53. "Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona",
  54. "FBI Truck","Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight",
  55. "Streak","Vortex","Vincent","Bullet","Clover","Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob",
  56. "Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster A","Monster B","Uranus",
  57. "Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight",
  58. "Trailer","Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford",
  59. "BF-400","Newsvan","Tug","Trailer A","Emperor","Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C",
  60. "Andromada","Dodo","RC Cam","Launch","Policia LV","Policia SF","Policia LS)","Police Ranger",
  61. "Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B",
  62. "Stair Trailer","Boxville","Farm Plow","Utility Trailer"
  63. };
  64.  
  65. public OnFilterScriptInit()
  66. {
  67. TimerVelocidad = SetTimer("Actualizar", 250, true);
  68. for(new i=0;i<MAX_VEHICLES;i++)
  69. {
  70. Gas[i] = 100;
  71. }
  72. Create3DTextLabel("Gasolinería\nUsa /refuel para llenar el tanque de gasolina del auto.", 0xFF8000FF, 2147.3618, 2750.9824, 10.8203, 7.0, 0, 0);
  73. return 1;
  74. }
  75.  
  76. public OnFilterScriptExit()
  77. {
  78. KillTimer(TimerVelocidad);
  79. KillTimer(GasBajo);
  80. return 1;
  81. }
  82.  
  83.  
  84. CMD:refuel(playerid, params[])
  85. {
  86. if(!IsPlayerInRangeOfPoint(playerid, 5.0, 2147.3618, 2750.9824, 10.8203)) return SendClientMessage(playerid, 0x00FFFFFF, "No estás cerca de la estación de gasolina. Usa /gasolineria para seguir el checkpoint.");
  87. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0x00FF00FF, "No estás en un vehículo.");
  88. if(Rellenando[playerid]) return SendClientMessage(playerid, 0x00FF00FF, "Ya estás rellenando.");
  89. if(GetPlayerMoney(playerid) - 80 < 0) return SendClientMessage(playerid, 0x00FFFFFF, "No tienes suficiente dinero.");
  90. GivePlayerMoney(playerid, -80);
  91. SetCameraBehindPlayer(playerid);
  92. TogglePlayerControllable(playerid, 0);
  93. Rellenando[playerid] = 1;
  94. TextDrawSetString(Gasolina[playerid], "Rellenando...");
  95. RellenoTimer[playerid] = SetTimerEx("TiempoRelleno", 4500, false, "i", playerid);
  96. return 1;
  97. }
  98.  
  99. CMD:gasolineria(playerid, params[])
  100. {
  101. SendClientMessage(playerid, -1, "Se ha marcado en el mini-mapa el checkpoint ubicado en la gasolinería.");
  102. SetPlayerCheckpoint(playerid, 2147.3618, 2750.9824, 10.8203, 3.0);
  103. return 1;
  104. }
  105.  
  106. public OnPlayerEnterCheckpoint(playerid)
  107. {
  108. DisablePlayerCheckpoint(playerid);
  109. return 1;
  110. }
  111.  
  112. forward PlayerVelo(playerid);
  113. public PlayerVelo(playerid)
  114. {
  115. Vehiculo[playerid] = TextDrawCreate(500.000000, 342.000000, "Vehiculo: Vergamovil");
  116. TextDrawBackgroundColor(Vehiculo[playerid], 255);
  117. TextDrawFont(Vehiculo[playerid], 1);
  118. TextDrawLetterSize(Vehiculo[playerid], 0.310000, 1.000000);
  119. TextDrawColor(Vehiculo[playerid], -1);
  120. TextDrawSetOutline(Vehiculo[playerid], 0);
  121. TextDrawSetProportional(Vehiculo[playerid], 1);
  122. TextDrawSetShadow(Vehiculo[playerid], 1);
  123. TextDrawUseBox(Vehiculo[playerid], 1);
  124. TextDrawBoxColor(Vehiculo[playerid], 103);
  125. TextDrawTextSize(Vehiculo[playerid], 614.000000, 1.000000);
  126.  
  127. Velocidad[playerid] = TextDrawCreate(500.000000, 357.000000, "Velocidad: 130 km/h");
  128. TextDrawBackgroundColor(Velocidad[playerid], 255);
  129. TextDrawFont(Velocidad[playerid], 1);
  130. TextDrawLetterSize(Velocidad[playerid], 0.310000, 1.000000);
  131. TextDrawColor(Velocidad[playerid], -1);
  132. TextDrawSetOutline(Velocidad[playerid], 0);
  133. TextDrawSetProportional(Velocidad[playerid], 1);
  134. TextDrawSetShadow(Velocidad[playerid], 1);
  135. TextDrawUseBox(Velocidad[playerid], 1);
  136. TextDrawBoxColor(Velocidad[playerid], 103);
  137. TextDrawTextSize(Velocidad[playerid], 614.000000, 1.000000);
  138.  
  139. Espacio[playerid] = TextDrawCreate(500.000000, 372.000000, " ");
  140. TextDrawBackgroundColor(Espacio[playerid], 255);
  141. TextDrawFont(Espacio[playerid], 1);
  142. TextDrawLetterSize(Espacio[playerid], 0.310000, 1.000000);
  143. TextDrawColor(Espacio[playerid], -1);
  144. TextDrawSetOutline(Espacio[playerid], 0);
  145. TextDrawSetProportional(Espacio[playerid], 1);
  146. TextDrawSetShadow(Espacio[playerid], 1);
  147. TextDrawUseBox(Espacio[playerid], 1);
  148. TextDrawBoxColor(Espacio[playerid], 103);
  149. TextDrawTextSize(Espacio[playerid], 614.000000, 1.000000);
  150.  
  151. Espacio2[playerid] = TextDrawCreate(500.000000, 378.000000, " ");
  152. TextDrawBackgroundColor(Espacio2[playerid], 255);
  153. TextDrawFont(Espacio2[playerid], 1);
  154. TextDrawLetterSize(Espacio2[playerid], 0.310000, 1.000000);
  155. TextDrawColor(Espacio2[playerid], -1);
  156. TextDrawSetOutline(Espacio2[playerid], 0);
  157. TextDrawSetProportional(Espacio2[playerid], 1);
  158. TextDrawSetShadow(Espacio2[playerid], 1);
  159. TextDrawUseBox(Espacio2[playerid], 1);
  160. TextDrawBoxColor(Espacio2[playerid], 103);
  161. TextDrawTextSize(Espacio2[playerid], 614.000000, 1.000000);
  162.  
  163. Gasolina[playerid] = TextDrawCreate(500.000000, 384.000000, "Gasolina: 100%");
  164. TextDrawBackgroundColor(Gasolina[playerid], 255);
  165. TextDrawFont(Gasolina[playerid], 1);
  166. TextDrawLetterSize(Gasolina[playerid], 0.310000, 1.000000);
  167. TextDrawColor(Gasolina[playerid], -1);
  168. TextDrawSetOutline(Gasolina[playerid], 0);
  169. TextDrawSetProportional(Gasolina[playerid], 1);
  170. TextDrawSetShadow(Gasolina[playerid], 1);
  171. TextDrawUseBox(Gasolina[playerid], 1);
  172. TextDrawBoxColor(Gasolina[playerid], 103);
  173. TextDrawTextSize(Gasolina[playerid], 614.000000, 1.000000);
  174.  
  175. Espacio3[playerid] = TextDrawCreate(500.000000, 399.000000, " ");
  176. TextDrawBackgroundColor(Espacio3[playerid], 255);
  177. TextDrawFont(Espacio3[playerid], 1);
  178. TextDrawLetterSize(Espacio3[playerid], 0.310000, 1.000000);
  179. TextDrawColor(Espacio3[playerid], -1);
  180. TextDrawSetOutline(Espacio3[playerid], 0);
  181. TextDrawSetProportional(Espacio3[playerid], 1);
  182. TextDrawSetShadow(Espacio3[playerid], 1);
  183. TextDrawUseBox(Espacio3[playerid], 1);
  184. TextDrawBoxColor(Espacio3[playerid], 103);
  185. TextDrawTextSize(Espacio3[playerid], 614.000000, 1.000000);
  186.  
  187. Espacio4[playerid] = TextDrawCreate(500.000000, 405.000000, " ");
  188. TextDrawBackgroundColor(Espacio4[playerid], 255);
  189. TextDrawFont(Espacio4[playerid], 1);
  190. TextDrawLetterSize(Espacio4[playerid], 0.310000, 1.000000);
  191. TextDrawColor(Espacio4[playerid], -1);
  192. TextDrawSetOutline(Espacio4[playerid], 0);
  193. TextDrawSetProportional(Espacio4[playerid], 1);
  194. TextDrawSetShadow(Espacio4[playerid], 1);
  195. TextDrawUseBox(Espacio4[playerid], 1);
  196. TextDrawBoxColor(Espacio4[playerid], 103);
  197. TextDrawTextSize(Espacio4[playerid], 614.000000, 1.000000);
  198.  
  199. Estado[playerid] = TextDrawCreate(500.000000, 411.000000, "Estado: 1000");
  200. TextDrawBackgroundColor(Estado[playerid], 255);
  201. TextDrawFont(Estado[playerid], 1);
  202. TextDrawLetterSize(Estado[playerid], 0.310000, 1.000000);
  203. TextDrawColor(Estado[playerid], -1);
  204. TextDrawSetOutline(Estado[playerid], 0);
  205. TextDrawSetProportional(Estado[playerid], 1);
  206. TextDrawSetShadow(Estado[playerid], 1);
  207. TextDrawUseBox(Estado[playerid], 1);
  208. TextDrawBoxColor(Estado[playerid], 103);
  209. TextDrawTextSize(Estado[playerid], 614.000000, 1.000000);
  210.  
  211. Espacio5[playerid] = TextDrawCreate(500.000000, 426.000000, " ");
  212. TextDrawBackgroundColor(Espacio5[playerid], 255);
  213. TextDrawFont(Espacio5[playerid], 1);
  214. TextDrawLetterSize(Espacio5[playerid], 0.310000, 1.000000);
  215. TextDrawColor(Espacio5[playerid], -1);
  216. TextDrawSetOutline(Espacio5[playerid], 0);
  217. TextDrawSetProportional(Espacio5[playerid], 1);
  218. TextDrawSetShadow(Espacio5[playerid], 1);
  219. TextDrawUseBox(Espacio5[playerid], 1);
  220. TextDrawBoxColor(Espacio5[playerid], 103);
  221. TextDrawTextSize(Espacio5[playerid], 614.000000, 1.000000);
  222.  
  223. Espacio6[playerid] = TextDrawCreate(500.000000, 432.000000, " ");
  224. TextDrawBackgroundColor(Espacio6[playerid], 255);
  225. TextDrawFont(Espacio6[playerid], 1);
  226. TextDrawLetterSize(Espacio6[playerid], 0.310000, 1.000000);
  227. TextDrawColor(Espacio6[playerid], -1);
  228. TextDrawSetOutline(Espacio6[playerid], 0);
  229. TextDrawSetProportional(Espacio6[playerid], 1);
  230. TextDrawSetShadow(Espacio6[playerid], 1);
  231. TextDrawUseBox(Espacio6[playerid], 1);
  232. TextDrawBoxColor(Espacio6[playerid], 103);
  233. TextDrawTextSize(Espacio6[playerid], 614.000000, 1.000000);
  234.  
  235. Espacio7[playerid] = TextDrawCreate(500.000000, 438.000000, " ");
  236. TextDrawBackgroundColor(Espacio7[playerid], 255);
  237. TextDrawFont(Espacio7[playerid], 1);
  238. TextDrawLetterSize(Espacio7[playerid], 0.310000, 1.000000);
  239. TextDrawColor(Espacio7[playerid], -1);
  240. TextDrawSetOutline(Espacio7[playerid], 0);
  241. TextDrawSetProportional(Espacio7[playerid], 1);
  242. TextDrawSetShadow(Espacio7[playerid], 1);
  243. TextDrawUseBox(Espacio7[playerid], 1);
  244. TextDrawBoxColor(Espacio7[playerid], 103);
  245. TextDrawTextSize(Espacio7[playerid], 614.000000, 1.000000);
  246.  
  247. Velocidadbar[playerid] = CreatePlayerProgressBar(playerid, 504.00, 375.00, 97.50, 3.20, 0x85DFFFFF, 100.0);
  248. Gasolinabar[playerid] = CreatePlayerProgressBar(playerid, 504.00, 401.00, 98.50, 3.20, 0xD2FF9DFF, 100.0);
  249. Estadobar[playerid] = CreatePlayerProgressBar(playerid, 504.00, 429.00, 98.50, 3.20, 0x9EEBCFFF, 100.0);
  250. MotorBar[playerid] = CreatePlayerProgressBar(playerid, 287.00, 197.00, 55.50, 3.20, 0xFFFFFFFF, 100.0);
  251. return 1;
  252. }
  253.  
  254. forward BorrarPlayerVelo(playerid);
  255. public BorrarPlayerVelo(playerid)
  256. {
  257. TextDrawHideForPlayer(playerid, Vehiculo[playerid]);
  258. TextDrawHideForPlayer(playerid, Velocidad[playerid]);
  259. TextDrawHideForPlayer(playerid, Espacio[playerid]);
  260. TextDrawHideForPlayer(playerid, Espacio2[playerid]);
  261. TextDrawHideForPlayer(playerid, Gasolina[playerid]);
  262. TextDrawHideForPlayer(playerid, Espacio3[playerid]);
  263. TextDrawHideForPlayer(playerid, Espacio4[playerid]);
  264. TextDrawHideForPlayer(playerid, Estado[playerid]);
  265. TextDrawHideForPlayer(playerid, Espacio5[playerid]);
  266. TextDrawHideForPlayer(playerid, Espacio6[playerid]);
  267. TextDrawHideForPlayer(playerid, Espacio7[playerid]);
  268. HidePlayerProgressBar(playerid, Velocidadbar[playerid]);
  269. HidePlayerProgressBar(playerid, Estadobar[playerid]);
  270. HidePlayerProgressBar(playerid, Gasolinabar[playerid]);
  271. return 1;
  272. }
  273.  
  274. public GasolinaBaja()
  275. {
  276. for(new i=0;i<MAX_PLAYERS;i++)
  277. {
  278. if(Rellenando[i]) continue;
  279. new vehicleid = GetPlayerVehicleID(i);
  280. Gas[vehicleid] = Gas[vehicleid] -1;
  281. if(GetPlayerVehicleSeat(i) == 0)
  282. {
  283. if(Gas[vehicleid] < 1)
  284. {
  285. Gas[vehicleid] = 0;
  286. RemovePlayerFromVehicle(i);
  287. GameTextForPlayer(i,"~r~Estás sin ~w~gasolina~r~.",5000,4);
  288. }
  289. }
  290. }
  291. return 1;
  292. }
  293.  
  294. public TiempoRelleno(playerid)
  295. {
  296. new vehicleid = GetPlayerVehicleID(playerid);
  297. Gas[vehicleid] = Gas[vehicleid] = 100;
  298. Rellenando[playerid] = 0;
  299. for(new i=0; i<MAX_PLAYERS; i++)
  300. {
  301. TogglePlayerControllable(i, 1);
  302. }
  303. TextDrawSetString(Gasolina[playerid], "~r~~h~Gasolina: ~w~100 Litros");
  304. return 1;
  305. }
  306.  
  307. public OnPlayerSpawn(playerid)
  308. {
  309. new vehicleid = GetPlayerVehicleID(playerid);
  310. MotorAuto[vehicleid] = 0;
  311. return 1;
  312. }
  313.  
  314. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  315. {
  316. if(MotorAuto[vehicleid] == 1)
  317. {
  318. TogglePlayerControllable(playerid, 1);
  319. SendClientMessage(playerid, 0x808000FF, "El motor del auto está encedido, para apagarlo haz click.");
  320. }
  321. return 1;
  322. }
  323.  
  324. public OnPlayerConnect(playerid)
  325. {
  326. return CallLocalFunction("PlayerVelo", "d", playerid), 1;
  327. }
  328.  
  329. forward Actualizar();
  330. public Actualizar()
  331. {
  332. new
  333. i = GetMaxPlayers()-1,
  334. szString[4][48],
  335. Float:EstadoV,
  336. vehicleid,
  337. VelocidadVeh;
  338. while(--i > -1)
  339. {
  340. if(!IsPlayerInAnyVehicle(i)) continue;
  341. else {
  342. vehicleid = GetPlayerVehicleID(i);
  343. GetVehicleHealth(vehicleid, EstadoV);
  344. VelocidadVeh = GetSpeed(i);
  345.  
  346. format(szString[1], 48,"~b~~h~Vehiculo: ~w~%s",Vehicles[GetVehicleModel(vehicleid)-400]);
  347. format(szString[0], 48,"~g~~h~Velocidad: ~w~%d Km/h", VelocidadVeh);
  348. format(szString[2], 48,"~y~~h~Estado: ~w~%0.0f%%",EstadoV/10);
  349. format(szString[3], 48,"~r~~h~Gasolina: ~w~%i Litros",Gas[vehicleid]);
  350. //======================================================================================//
  351. TextDrawSetString(Vehiculo[i], szString[1]), TextDrawSetString(Velocidad[i], szString[0]);
  352. TextDrawSetString(Estado[i], szString[2]), TextDrawSetString(Gasolina[i], szString[3]);
  353. TextDrawShowForPlayer(i, Vehiculo[i]), TextDrawShowForPlayer(i, Velocidad[i]),
  354. TextDrawShowForPlayer(i, Espacio[i]), TextDrawShowForPlayer(i, Espacio2[i]),
  355. TextDrawShowForPlayer(i, Gasolina[i]), TextDrawShowForPlayer(i, Espacio3[i]),
  356. TextDrawShowForPlayer(i, Espacio4[i]), TextDrawShowForPlayer(i, Estado[i]),
  357. TextDrawShowForPlayer(i, Espacio5[i]), TextDrawShowForPlayer(i, Espacio6[i]),
  358. TextDrawShowForPlayer(i, Espacio7[i]);
  359. //=========================================================//
  360. SetPlayerProgressBarMaxValue(i, Velocidadbar[i], 300.0);
  361. SetPlayerProgressBarValue(i, Velocidadbar[i], VelocidadVeh);
  362. UpdatePlayerProgressBar(i, Velocidadbar[i]);
  363. //=========================================================//
  364. SetPlayerProgressBarMaxValue(i, Estadobar[i], 100);
  365. SetPlayerProgressBarValue(i, Estadobar[i], EstadoV/10);
  366. UpdatePlayerProgressBar(i, Estadobar[i]);
  367. //=========================================================//
  368. SetPlayerProgressBarMaxValue(i, Gasolinabar[i], 100);
  369. SetPlayerProgressBarValue(i, Gasolinabar[i], Gas[vehicleid]);
  370. UpdatePlayerProgressBar(i, Gasolinabar[i]);
  371.  
  372. }
  373. }
  374. return 1;
  375. }
  376.  
  377. stock GetSpeed(playerid, mode = 1)
  378. {
  379. new Float:Velocidade [3];
  380. GetVehicleVelocity(GetPlayerVehicleID(playerid),Velocidade[0],Velocidade[1],Velocidade [2]);
  381. return IsPlayerInAnyVehicle(playerid)?floatround(((floatsqroot(((Velocidade[0]*Velocidade[0])+(Velocidade[1]*Velocidade[1])+(Velocidade[2]*Velocidade[2])))*(!mode?105.0:170.0)))*1):0;
  382. }
  383.  
  384. public OnPlayerStateChange(playerid, newstate, oldstate)
  385. {
  386. if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
  387. {
  388. if(MotorAuto[playerid] == 0)
  389. {
  390. TogglePlayerControllable(playerid, 0);
  391. SendClientMessage(playerid, 0xFF0080FF, "El motor del auto está apagado, manten pulsado el click para encenderlo.");
  392. }
  393. Actualizar();
  394. ShowPlayerProgressBar(playerid, Velocidadbar[playerid]);
  395. ShowPlayerProgressBar(playerid, Gasolinabar[playerid]);
  396. ShowPlayerProgressBar(playerid, Estadobar[playerid]);
  397. }
  398. else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
  399. {
  400. BorrarPlayerVelo(playerid);
  401. }
  402. return 1;
  403. }
  404.  
  405. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  406. {
  407. new vehid = GetPlayerVehicleID(playerid);
  408. if(HOLDING(KEY_FIRE))
  409. {
  410. if(IsPlayerInAnyVehicle(playerid))
  411. {
  412. if(MotorAuto[vehid] == 0)
  413. {
  414. GameTextForPlayer(playerid, "~r~Encendiendo...",4000,3);
  415. Enciende[playerid] = SetTimerEx("Prende", 1000, 1, "d", playerid);
  416. }
  417. else
  418. {
  419. Apagar[playerid] = SetTimerEx("Apaga", 1500, false, "d", playerid);
  420. GameTextForPlayer(playerid, "~b~Apagando...", 1000, 3);
  421. }
  422. }
  423. }
  424. else if(RELEASED(KEY_FIRE))
  425. {
  426. new vid = GetPlayerVehicleID(playerid);
  427. if(MotorAuto[vid] == 0)
  428. {
  429. SetPlayerProgressBarValue(playerid, MotorBar[playerid], 0);
  430. vMotor[vid] =(0);
  431. UpdatePlayerProgressBar(playerid, MotorBar[playerid]);
  432. KillTimer(Enciende[playerid]);
  433. }
  434. }
  435. return 1;
  436. }
  437.  
  438. forward Apaga(playerid);
  439. public Apaga(playerid)
  440. {
  441. new vid = GetPlayerVehicleID(playerid);
  442. new enginem, lights, alarm, doors, bonnet, boot, objective;
  443. GetVehicleParamsEx(GetPlayerVehicleID(playerid),enginem, lights, alarm, doors, bonnet, boot, objective);
  444. SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
  445. GameTextForPlayer(playerid, "~w~Motor ~r~Apagado", 1000, 3);
  446. MotorAuto[vid] = 0;
  447. return 1;
  448. }
  449.  
  450. forward Prende(playerid);
  451. public Prende(playerid)
  452. {
  453. new i = playerid;
  454. if(IsPlayerInAnyVehicle(i))
  455. {
  456. if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
  457. {
  458. new vehicleid = GetPlayerVehicleID(i);
  459. vMotor[vehicleid] += (25);
  460. ShowPlayerProgressBar(i, MotorBar[i]);
  461. SetPlayerProgressBarValue(i, MotorBar[i], vMotor[vehicleid]);
  462. UpdatePlayerProgressBar(i, MotorBar[i]);
  463. if(vMotor[vehicleid] >= 100)
  464. {
  465. GasBajo = SetTimer("GasolinaBaja", 4200 ,true);
  466. new vid = GetPlayerVehicleID(playerid);
  467. new enginem, lights, alarm, doors, bonnet, boot, objective;
  468. GetVehicleParamsEx(GetPlayerVehicleID(playerid),enginem, lights, alarm, doors, bonnet, boot, objective);
  469. SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);//deja el auto con las luces encendidas, motor, etc.
  470. GameTextForPlayer(playerid, "~r~Motor ~y~Encendido", 1000, 3);
  471. MotorAuto[vid] = 1;
  472. vMotor[vehicleid] =(0);
  473. HidePlayerProgressBar(playerid, MotorBar[playerid]);
  474. SetPlayerProgressBarValue(i, MotorBar[playerid], 0);
  475. TogglePlayerControllable(playerid, 1);
  476. KillTimer(Enciende[playerid]);
  477. }
  478. }
  479. }
  480. return 1;
  481. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement