Guest User

Untitled

a guest
Feb 6th, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 55.03 KB | None | 0 0
  1. #include < a_samp >
  2. #include < dof2 >
  3. #include < zcmd >
  4.  
  5. #define ForEach(%0,%1) \
  6. for(new %0 = 0; %0 != %1; %0++) if(IsPlayerConnected(%0) && !IsPlayerNPC(%0))
  7.  
  8. #define Loop(%0,%1) \
  9. for(new %0 = 0; %0 != %1; %0++)
  10.  
  11. #define IsOdd(%1) \
  12. ((%1) & 1)
  13.  
  14. #define ConvertTime(%0,%1,%2,%3,%4) \
  15. new \
  16. Float: %0 = floatdiv(%1, 60000) \
  17. ;\
  18. %2 = floatround(%0, floatround_tozero); \
  19. %3 = floatround(floatmul(%0 - %2, 60), floatround_tozero); \
  20. %4 = floatround(floatmul(floatmul(%0 - %2, 60) - %3, 1000), floatround_tozero)
  21.  
  22. #define function%0(%1) \
  23. forward%0(%1); public%0(%1)
  24.  
  25. #define DIRETORIO_CORRIDAS "/Corridas/%s.ini"
  26. #define DIRETORIO_NOME_CORRIDAS "/Corridas/%s.txt"
  27.  
  28. #define DEBUG_CORRIDA 1
  29. #define TAMANHO_CHECKPOINTS 8
  30. #define CONTAGEM_START 30
  31. #define MAX_CHECKPOINTS 800
  32. #define MAX_CORRIDAS 500
  33. #define MAX_CORRIDA_TEMPO 6000
  34.  
  35. #define CINZA 0xAFAFAFAA
  36. #define VERDE 0x9FFF00FF
  37. #define VERMELHO 0xE60000FF
  38. #define AMARELO 0xFFFF00AA
  39. #define BRANCO 0xFFFFFFAA
  40.  
  41. new
  42. vNames[212][] =
  43. {
  44.  
  45. {
  46. "Landstalker"},
  47. {
  48. "Bravura"},
  49. {
  50. "Buffalo"},
  51. {
  52. "Linerunner"},
  53. {
  54. "Perrenial"},
  55. {
  56. "Sentinel"},
  57. {
  58. "Dumper"},
  59. {
  60. "Firetruck"},
  61. {
  62. "Trashmaster"},
  63. {
  64. "Stretch"},
  65. {
  66. "Manana"},
  67. {
  68. "Infernus"},
  69. {
  70. "Voodoo"},
  71. {
  72. "Pony"},
  73. {
  74. "Mule"},
  75. {
  76. "Cheetah"},
  77. {
  78. "Ambulance"},
  79. {
  80. "Leviathan"},
  81. {
  82. "Moonbeam"},
  83. {
  84. "Esperanto"},
  85. {
  86. "Taxi"},
  87. {
  88. "Washington"},
  89. {
  90. "Bobcat"},
  91. {
  92. "Mr Whoopee"},
  93. {
  94. "BF Injection"},
  95. {
  96. "Hunter"},
  97. {
  98. "Premier"},
  99. {
  100. "Enforcer"},
  101. {
  102. "Securicar"},
  103. {
  104. "Banshee"},
  105. {
  106. "Predator"},
  107. {
  108. "Bus"},
  109. {
  110. "Rhino"},
  111. {
  112. "Barracks"},
  113. {
  114. "Hotknife"},
  115. {
  116. "Trailer 1"},
  117. {
  118. "Previon"},
  119. {
  120. "Coach"},
  121. {
  122. "Cabbie"},
  123. {
  124. "Stallion"},
  125. {
  126. "Rumpo"},
  127. {
  128. "RC Bandit"},
  129. {
  130. "Romero"},
  131. {
  132. "Packer"},
  133. {
  134. "Monster"},
  135. {
  136. "Admiral"},
  137. {
  138. "Squalo"},
  139. {
  140. "Seasparrow"},
  141. {
  142. "Pizzaboy"},
  143. {
  144. "Tram"},
  145. {
  146. "Trailer 2"},
  147. {
  148. "Turismo"},
  149. {
  150. "Speeder"},
  151. {
  152. "Reefer"},
  153. {
  154. "Tropic"},
  155. {
  156. "Flatbed"},
  157. {
  158. "Yankee"},
  159. {
  160. "Caddy"},
  161. {
  162. "Solair"},
  163. {
  164. "Berkley's RC Van"},
  165. {
  166. "Skimmer"},
  167. {
  168. "PCJ-600"},
  169. {
  170. "Faggio"},
  171. {
  172. "Freeway"},
  173. {
  174. "RC Baron"},
  175. {
  176. "RC Raider"},
  177. {
  178. "Glendale"},
  179. {
  180. "Oceanic"},
  181. {
  182. "Sanchez"},
  183. {
  184. "Sparrow"},
  185. {
  186. "Patriot"},
  187. {
  188. "Quad"},
  189. {
  190. "Coastguard"},
  191. {
  192. "Dinghy"},
  193. {
  194. "Hermes"},
  195. {
  196. "Sabre"},
  197. {
  198. "Rustler"},
  199. {
  200. "ZR-350"},
  201. {
  202. "Walton"},
  203. {
  204. "Regina"},
  205. {
  206. "Comet"},
  207. {
  208. "BMX"},
  209. {
  210. "Burrito"},
  211. {
  212. "Camper"},
  213. {
  214. "Marquis"},
  215. {
  216. "Baggage"},
  217. {
  218. "Dozer"},
  219. {
  220. "Maverick"},
  221. {
  222. "News Chopper"},
  223. {
  224. "Rancher"},
  225. {
  226. "FBI Rancher"},
  227. {
  228. "Virgo"},
  229. {
  230. "Greenwood"},
  231. {
  232. "Jetmax"},
  233. {
  234. "Hotring"},
  235. {
  236. "Sandking"},
  237. {
  238. "Blista Compact"},
  239. {
  240. "Police Maverick"},
  241. {
  242. "Boxville"},
  243. {
  244. "Benson"},
  245. {
  246. "Mesa"},
  247. {
  248. "RC Goblin"},
  249. {
  250. "Hotring Racer A"},
  251. {
  252. "Hotring Racer B"},
  253. {
  254. "Bloodring Banger"},
  255. {
  256. "Rancher"},
  257. {
  258. "Super GT"},
  259. {
  260. "Elegant"},
  261. {
  262. "Journey"},
  263. {
  264. "Bike"},
  265. {
  266. "Mountain Bike"},
  267. {
  268. "Beagle"},
  269. {
  270. "Cropdust"},
  271. {
  272. "Stunt"},
  273. {
  274. "Tanker"},
  275. {
  276. "Roadtrain"},
  277. {
  278. "Nebula"},
  279. {
  280. "Majestic"},
  281. {
  282. "Buccaneer"},
  283. {
  284. "Shamal"},
  285. {
  286. "Hydra"},
  287. {
  288. "FCR-900"},
  289. {
  290. "NRG-500"},
  291. {
  292. "HPV1000"},
  293. {
  294. "Cement Truck"},
  295. {
  296. "Tow Truck"},
  297. {
  298. "Fortune"},
  299. {
  300. "Cadrona"},
  301. {
  302. "FBI Truck"},
  303. {
  304. "Willard"},
  305. {
  306. "Forklift"},
  307. {
  308. "Tractor"},
  309. {
  310. "Combine"},
  311. {
  312. "Feltzer"},
  313. {
  314. "Remington"},
  315. {
  316. "Slamvan"},
  317. {
  318. "Blade"},
  319. {
  320. "Freight"},
  321. {
  322. "Streak"},
  323. {
  324. "Vortex"},
  325. {
  326. "Vincent"},
  327. {
  328. "Bullet"},
  329. {
  330. "Clover"},
  331. {
  332. "Sadler"},
  333. {
  334. "Firetruck LA"},
  335. {
  336. "Hustler"},
  337. {
  338. "Intruder"},
  339. {
  340. "Primo"},
  341. {
  342. "Cargobob"},
  343. {
  344. "Tampa"},
  345. {
  346. "Sunrise"},
  347. {
  348. "Merit"},
  349. {
  350. "Utility"},
  351. {
  352. "Nevada"},
  353. {
  354. "Yosemite"},
  355. {
  356. "Windsor"},
  357. {
  358. "Monster A"},
  359. {
  360. "Monster B"},
  361. {
  362. "Uranus"},
  363. {
  364. "Jester"},
  365. {
  366. "Sultan"},
  367. {
  368. "Stratum"},
  369. {
  370. "Elegy"},
  371. {
  372. "Raindance"},
  373. {
  374. "RC Tiger"},
  375. {
  376. "Flash"},
  377. {
  378. "Tahoma"},
  379. {
  380. "Savanna"},
  381. {
  382. "Bandito"},
  383. {
  384. "Freight Flat"},
  385. {
  386. "Streak Carriage"},
  387. {
  388. "Kart"},
  389. {
  390. "Mower"},
  391. {
  392. "Duneride"},
  393. {
  394. "Sweeper"},
  395. {
  396. "Broadway"},
  397. {
  398. "Tornado"},
  399. {
  400. "AT-400"},
  401. {
  402. "DFT-30"},
  403. {
  404. "Huntley"},
  405. {
  406. "Stafford"},
  407. {
  408. "BF-400"},
  409. {
  410. "Newsvan"},
  411. {
  412. "Tug"},
  413. {
  414. "Trailer 3"},
  415. {
  416. "Emperor"},
  417. {
  418. "Wayfarer"},
  419. {
  420. "Euros"},
  421. {
  422. "Hotdog"},
  423. {
  424. "Club"},
  425. {
  426. "Freight Carriage"},
  427. {
  428. "Trailer 3"},
  429. {
  430. "Andromada"},
  431. {
  432. "Dodo"},
  433. {
  434. "RC Cam"},
  435. {
  436. "Launch"},
  437. {
  438. "Police Car (LSPD)"},
  439. {
  440. "Police Car (SFPD)"},
  441. {
  442. "Police Car (LVPD)"},
  443. {
  444. "Police Ranger"},
  445. {
  446. "Picador"},
  447. {
  448. "S.W.A.T. Van"},
  449. {
  450. "Alpha"},
  451. {
  452. "Phoenix"},
  453. {
  454. "Glendale"},
  455. {
  456. "Sadler"},
  457. {
  458. "Luggage Trailer A"},
  459. {
  460. "Luggage Trailer B"},
  461. {
  462. "Stair Trailer"},
  463. {
  464. "Boxville"},
  465. {
  466. "Farm Plow"},
  467. {
  468. "Utility Trailer"}
  469. },
  470. ConstruindoCorrida,
  471. ConstrucaoCorridaTipo,
  472. ConstrucaoVeiculo,
  473. ConstrucaoVeiculoCriado,
  474. ConstrucaoModeloID,
  475. NomeConstrucao[30],
  476. bool: BuildTakeVehPos,
  477. BuildVehPosCount,
  478. bool: BuildTakeCheckpoints,
  479. ConstruirCheckPointCount,
  480. RaceBusy = 0x00,
  481. NomeCorrida[30],
  482. VeiculoCorrida,
  483. CorridaTipo,
  484. TotalCP,
  485. Float: CoordVehCorrida[2][4],
  486. Float: CPCoords[MAX_CHECKPOINTS][4],
  487. CriarVehCorrida[MAX_PLAYERS],
  488. Index,
  489. PlayersCount[2],
  490. CountTimer,
  491. CountAmount,
  492. bool: NaCorrida[MAX_PLAYERS],
  493. CorridaTick,
  494. CorridaIniciada,
  495. CPProgesso[MAX_PLAYERS],
  496. Posicao,
  497. FinishCount,
  498. JoinCount,
  499. rCounter,
  500. CorridaTempo,
  501. Text: CorridaInfo[MAX_PLAYERS],
  502. InfoTimer[MAX_PLAYERS],
  503. Colocacao[MAX_PLAYERS],
  504. NomeCorridas[MAX_CORRIDAS][128],
  505. TotalCorridas,
  506. bool: CorrridasAutomaticas,
  507. TempoProgresso;
  508. new CarGod[MAX_VEHICLES];
  509.  
  510. public OnFilterScriptInit()
  511. {
  512. print("\n--------------------------------------");
  513. print(" Sistema de corrida carregado com sucesso");
  514. print("--------------------------------------\n");
  515. return 1;
  516. }
  517. public OnFilterScriptExit()
  518. {
  519. ConstrucaoVeiculoCriado = (ConstrucaoVeiculoCriado == 0x01) ? (DestroyVehicle(ConstrucaoVeiculo), ConstrucaoVeiculoCriado = 0x00) : (DestroyVehicle(ConstrucaoVeiculo), ConstrucaoVeiculoCriado = 0x00);
  520. KillTimer(rCounter);
  521. KillTimer(CountTimer);
  522. Loop(i, MAX_PLAYERS)
  523. {
  524.  
  525. DisablePlayerRaceCheckpoint(i);
  526. TextDrawDestroy(CorridaInfo[i]);
  527. DestroyVehicle(CriarVehCorrida[i]);
  528. NaCorrida[i] = false;
  529. KillTimer(InfoTimer[i]);
  530. }
  531. JoinCount = 0;
  532. FinishCount = 0;
  533. TempoProgresso = 0;
  534. CorrridasAutomaticas = false;
  535. DOF2_Exit();
  536. return 1;
  537. }
  538.  
  539. CMD:construircorrida(playerid, params[])
  540. {
  541. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, VERMELHO, "[x] Voce Nao é Um Administrador(a) RCON!");
  542. if(ConstruindoCorrida != 0) return SendClientMessage(playerid, VERMELHO, "» Voce esta em Modo de Construção !");
  543. if(RaceBusy == 0x01) return SendClientMessage(playerid, VERMELHO, "[x] Espere primeiro até a corrida termina!");
  544. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, VERMELHO, "[x] Por favor, deixe o seu veículo Primeiro!");
  545. ConstruindoCorrida = playerid+1;
  546. ShowDialog(playerid, 599);
  547. return 1;
  548. }
  549. CMD:iniciarcorrida(playerid, params[])
  550. {
  551. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, VERMELHO, "[x] Voce Nao é Um Administrador(a) RCON!");
  552. if(CorrridasAutomaticas == true) return SendClientMessage(playerid, VERMELHO, "[x] Não é possível. Corrida automática está ativada !");
  553. if(ConstruindoCorrida != 0) return SendClientMessage(playerid, VERMELHO, "[x] Há alguém a construção de uma corrida!");
  554. if(RaceBusy == 0x01 || CorridaIniciada == 1) return SendClientMessage(playerid, VERMELHO, "[x] Há uma Corrida atualmente. Espera primeiro até corrida terminar !");
  555. if(isnull(params)) return SendClientMessage(playerid, VERMELHO, "Use /iniciarcorrida [Nome-Da-Corrida]");
  556. LoadRace(playerid, params);
  557. return 1;
  558. }
  559. CMD:pararcorrida(playerid, params[])
  560. {
  561. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, VERMELHO, "[x] Voce Nao é Um Administrador(a) RCON!");
  562. if(RaceBusy == 0x00 || CorridaIniciada == 0) return SendClientMessage(playerid, VERMELHO, "[x] Não há nenhuma corrida para parar ");
  563. SendClientMessageToAll(VERMELHO, ">> O(a) Administrador(a) Fechou a Corrida Atual!!");
  564. SetPlayerPos(playerid, 1242.3445,-1815.5928,14.7578);
  565. return StopRace();
  566. }
  567. CMD:entrarcorrida(playerid, params[])
  568. {
  569. if(CorridaIniciada == 1) return SendClientMessage(playerid, VERMELHO, "Corrida já começou! Espera primeiro até o Fim da corrida!");
  570. if(RaceBusy == 0x00) return SendClientMessage(playerid, VERMELHO, "[x] Não há nenhuma corrida para participar!");
  571. if(NaCorrida[playerid] == true) return SendClientMessage(playerid, VERMELHO, "[x] Você já se juntou a uma corrida!");
  572. if(IsPlayerInAnyVehicle(playerid)) return SetTimerEx("SetupRaceForPlayer", 2500, 0, "e", playerid), RemovePlayerFromVehicle(playerid), NaCorrida[playerid] = true;
  573. SetupRaceForPlayer(playerid);
  574. NaCorrida[playerid] = true;
  575. CarGod[GetPlayerVehicleID(playerid)] = true;
  576. return 1;
  577. }
  578. CMD:autocorrida(playerid, params[])
  579. {
  580. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, VERMELHO, "[x] Voce Nao é Um Administrador(a) RCON!");
  581. if(RaceBusy == 0x01 || CorridaIniciada == 1) return SendClientMessage(playerid, VERMELHO, "[x] Há uma Corrida atualmente. Espera primeiro até corrida termina!");
  582. if(CorrridasAutomaticas == true) return SendClientMessage(playerid, VERMELHO, "[x] Já está ativado!");
  583. CarregarNomeCorridas();
  584. CarregarCorridasAutomaticas(NomeCorridas[random(TotalCorridas)]);
  585. CorrridasAutomaticas = true;
  586. SendClientMessage(playerid, VERDE, ">> Você iniciou a corrida Automatica. O filterscript vai começar uma corrida aleatória sempre que a corrida anterior acabar!");
  587. return 1;
  588. }
  589. CMD:pararautocorrida(playerid, params[])
  590. {
  591. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, VERMELHO, "[x] Voce Nao é Um Administrador(a) RCON!");
  592. if(CorrridasAutomaticas == false) return SendClientMessage(playerid, VERMELHO, "[x] Já está ativado!");
  593. CorrridasAutomaticas = false;
  594. return 1;
  595. }
  596. CMD:desistir(playerid, params[])
  597. {
  598. if(NaCorrida[playerid] == true)
  599. {
  600. CarGod[GetPlayerVehicleID(playerid)] = false;
  601. JoinCount--;
  602. NaCorrida[playerid] = false;
  603. DestroyVehicle(CriarVehCorrida[playerid]);
  604. DisablePlayerRaceCheckpoint(playerid);
  605. TextDrawHideForPlayer(playerid, CorridaInfo[playerid]);
  606. CPProgesso[playerid] = 0;
  607. SetPlayerPos(playerid, 1242.3445,-1815.5928,14.7578);
  608. KillTimer(InfoTimer[playerid]);
  609. TogglePlayerControllable(playerid, true);
  610. SetCameraBehindPlayer(playerid);
  611. #if defined RACE_IN_OTHER_WORLD
  612. SetPlayerVirtualWorld(playerid, 0);
  613. #endif
  614. } else return SendClientMessage(playerid, VERMELHO, "[x] Você não está em uma corrida!");
  615. return 1;
  616. }
  617.  
  618. public OnVehicleDamageStatusUpdate(vehicleid, playerid)
  619. {
  620. if(CarGod[vehicleid]) RepairVehicle(vehicleid);
  621. return 1;
  622. }
  623.  
  624.  
  625.  
  626.  
  627.  
  628. public OnPlayerEnterRaceCheckpoint(playerid)
  629. {
  630. if(CPProgesso[playerid] == TotalCP -1)
  631. {
  632.  
  633. new
  634. TimeStamp,
  635. TotalRaceTime,
  636. string[256],
  637. arquivo[256],
  638. pName[MAX_PLAYER_NAME],
  639. rTime[3],
  640. Prize[2],
  641. TempTotalTime,
  642. TempTime[3]
  643. ;
  644. Posicao++;
  645. GetPlayerName(playerid, pName, sizeof(pName));
  646. SetVehicleHealth(GetPlayerVehicleID(playerid),999999);
  647. TimeStamp = GetTickCount();
  648. TotalRaceTime = TimeStamp - CorridaTick;
  649. ConvertTime(var, TotalRaceTime, rTime[0], rTime[1], rTime[2]);
  650. switch(Posicao)
  651. {
  652.  
  653. case 1: Prize[0] = (random(random(5000)) + 10000), Prize[1] = 10;
  654. case 2: Prize[0] = (random(random(4500)) + 9000), Prize[1] = 9;
  655. case 3: Prize[0] = (random(random(4000)) + 8000), Prize[1] = 8;
  656. case 4: Prize[0] = (random(random(3500)) + 7000), Prize[1] = 7;
  657. case 5: Prize[0] = (random(random(3000)) + 6000), Prize[1] = 6;
  658. case 6: Prize[0] = (random(random(2500)) + 5000), Prize[1] = 5;
  659. case 7: Prize[0] = (random(random(2000)) + 4000), Prize[1] = 4;
  660. case 8: Prize[0] = (random(random(1500)) + 3000), Prize[1] = 3;
  661. case 9: Prize[0] = (random(random(1000)) + 2000), Prize[1] = 2;
  662. default: Prize[0] = random(random(1000)), Prize[1] = 1;
  663. }
  664.  
  665. format(string, sizeof(string), "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", pName, Posicao);
  666. SendClientMessageToAll(VERMELHO, string);
  667. format(string, sizeof(string), "~~~~~~~~~~~~~~~ O Jogador %s Venceu a Corida em %d Lugar ~~~~~~~~~~~~~~~", pName, Posicao);
  668. SendClientMessageToAll(BRANCO, string);
  669. format(string, sizeof(string), "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", pName, Posicao);
  670. SendClientMessageToAll(VERMELHO, string);
  671. format(string, sizeof(string), "", rTime[0], rTime[1], rTime[2]);
  672. SendClientMessageToAll(BRANCO, string);
  673. format(string, sizeof(string), "", Prize[0], Prize[1]);
  674. SendClientMessageToAll(BRANCO, string);
  675.  
  676. if(FinishCount <= 5)
  677. {
  678.  
  679. format(arquivo, sizeof(arquivo), DIRETORIO_CORRIDAS, NomeCorrida);
  680. format(string, sizeof(string), "MelhorTempoCorrida-%d", TempoProgresso);
  681. TempTotalTime = DOF2_GetInt(arquivo, string);
  682. ConvertTime(var1, TempTotalTime, TempTime[0], TempTime[1], TempTime[2]);
  683. if(TotalRaceTime <= DOF2_GetInt(arquivo, string) || TempTotalTime == 0)
  684. {
  685.  
  686. DOF2_SetInt(arquivo, string, TotalRaceTime);
  687. format(string, sizeof(string), "MelhorCorrida-%d", TempoProgresso);
  688. if(TempTotalTime != 0) format(string, sizeof(string), "", pName, DOF2_GetString(arquivo, string), -(rTime[1] - TempTime[1]), TempoProgresso+1);
  689. else format(string, sizeof(string), "", pName, TempoProgresso+1);
  690. SendClientMessageToAll(VERDE, " ");
  691. SendClientMessageToAll(VERDE, string);
  692. SendClientMessageToAll(VERDE, " ");
  693. format(string, sizeof(string), "MelhorCorrida-%d", TempoProgresso);
  694. DOF2_SetString(arquivo, string, pName);
  695. TempoProgresso++;
  696. }
  697. }
  698. FinishCount++;
  699. GivePlayerMoney(playerid, Prize[0]);
  700. SetPlayerScore(playerid, GetPlayerScore(playerid) + Prize[0]);
  701. DisablePlayerRaceCheckpoint(playerid);
  702. CPProgesso[playerid]++;
  703. SetPlayerPos(playerid, 1242.3445,-1815.5928,14.7578);
  704. if(FinishCount >= JoinCount) return StopRace();
  705. }
  706. else
  707. {
  708.  
  709. CPProgesso[playerid]++;
  710. CPCoords[CPProgesso[playerid]][3]++;
  711. Colocacao[playerid] = floatround(CPCoords[CPProgesso[playerid]][3], floatround_floor);
  712. SetCP(playerid, CPProgesso[playerid], CPProgesso[playerid]+1, TotalCP, CorridaTipo);
  713. PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);
  714. }
  715. return 1;
  716. }
  717.  
  718. public OnPlayerDisconnect(playerid)
  719. {
  720. if(NaCorrida[playerid] == true)
  721. {
  722.  
  723. JoinCount--;
  724. NaCorrida[playerid] = false;
  725. DestroyVehicle(CriarVehCorrida[playerid]);
  726. DisablePlayerRaceCheckpoint(playerid);
  727. TextDrawHideForPlayer(playerid, CorridaInfo[playerid]);
  728. CPProgesso[playerid] = 0;
  729. KillTimer(InfoTimer[playerid]);
  730. #if defined RACE_IN_OTHER_WORLD
  731. SetPlayerVirtualWorld(playerid, 0);
  732. #endif
  733. }
  734. TextDrawDestroy(CorridaInfo[playerid]);
  735. if(ConstruindoCorrida == playerid+1) ConstruindoCorrida = 0;
  736. return 1;
  737. }
  738.  
  739. public OnPlayerConnect(playerid)
  740. {
  741. CorridaInfo[playerid] = TextDrawCreate(633.000000, 348.000000, " ");
  742. TextDrawAlignment(CorridaInfo[playerid], 3);
  743. SetVehicleHealth(GetPlayerVehicleID(playerid),999999);
  744. TextDrawBackgroundColor(CorridaInfo[playerid], 255);
  745. TextDrawFont(CorridaInfo[playerid], 1);
  746. TextDrawLetterSize(CorridaInfo[playerid], 0.240000, 1.100000);
  747. TextDrawColor(CorridaInfo[playerid], -687931137);
  748. TextDrawSetOutline(CorridaInfo[playerid], 0);
  749. TextDrawSetProportional(CorridaInfo[playerid], 1);
  750. TextDrawSetShadow(CorridaInfo[playerid], 1);
  751. return 1;
  752. }
  753.  
  754. public OnPlayerDeath(playerid)
  755. {
  756. if(NaCorrida[playerid] == true)
  757. {
  758.  
  759. JoinCount--;
  760. NaCorrida[playerid] = false;
  761. DestroyVehicle(CriarVehCorrida[playerid]);
  762. DisablePlayerRaceCheckpoint(playerid);
  763. TextDrawHideForPlayer(playerid, CorridaInfo[playerid]);
  764. CPProgesso[playerid] = 0;
  765. KillTimer(InfoTimer[playerid]);
  766. #if defined RACE_IN_OTHER_WORLD
  767. SetPlayerVirtualWorld(playerid, 0);
  768. #endif
  769. }
  770. if(ConstruindoCorrida == playerid+1) ConstruindoCorrida = 0;
  771. return 1;
  772. }
  773.  
  774. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  775. {
  776. switch(dialogid)
  777. {
  778.  
  779. case 599:
  780. {
  781.  
  782. if(!response) return ConstruindoCorrida = 0;
  783. switch(listitem)
  784. {
  785.  
  786. case 0: ConstrucaoCorridaTipo = 0;
  787. case 1: ConstrucaoCorridaTipo = 3;
  788. }
  789. ShowDialog(playerid, 600);
  790. }
  791. case 600..601:
  792. {
  793.  
  794. if(!response) return ShowDialog(playerid, 599);
  795. if(!strlen(inputtext)) return ShowDialog(playerid, 601);
  796. if(strlen(inputtext) < 1 || strlen(inputtext) > 20) return ShowDialog(playerid, 601);
  797. strmid(NomeConstrucao, inputtext, 0, strlen(inputtext), sizeof(NomeConstrucao));
  798. ShowDialog(playerid, 602);
  799. }
  800. case 602..603:
  801. {
  802.  
  803. if(!response) return ShowDialog(playerid, 600);
  804. if(!strlen(inputtext)) return ShowDialog(playerid, 603);
  805. if(isNumeric(inputtext))
  806. {
  807.  
  808.  
  809. if(!IsValidVehicle(strval(inputtext))) return ShowDialog(playerid, 603);
  810. new
  811. Float: pPos[4]
  812. ;
  813. GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  814. GetPlayerFacingAngle(playerid, pPos[3]);
  815. ConstrucaoModeloID = strval(inputtext);
  816. ConstrucaoVeiculoCriado = (ConstrucaoVeiculoCriado == 0x01) ? (DestroyVehicle(ConstrucaoVeiculo), ConstrucaoVeiculoCriado = 0x00) : (DestroyVehicle(ConstrucaoVeiculo), ConstrucaoVeiculoCriado = 0x00);
  817. ConstrucaoVeiculo = CreateVehicle(strval(inputtext), pPos[0], pPos[1], pPos[2], pPos[3], random(126), random(126), (60 * 60));
  818. PutPlayerInVehicle(playerid, ConstrucaoVeiculo, 0);
  819. ConstrucaoVeiculoCriado = 0x01;
  820. ShowDialog(playerid, 604);
  821. }
  822. else
  823. {
  824.  
  825. if(!IsValidVehicle(ReturnVehicleID(inputtext))) return ShowDialog(playerid, 603);
  826. new
  827. Float: pPos[4]
  828. ;
  829. GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  830. GetPlayerFacingAngle(playerid, pPos[3]);
  831. ConstrucaoModeloID = ReturnVehicleID(inputtext);
  832. ConstrucaoVeiculoCriado = (ConstrucaoVeiculoCriado == 0x01) ? (DestroyVehicle(ConstrucaoVeiculo), ConstrucaoVeiculoCriado = 0x00) : (DestroyVehicle(ConstrucaoVeiculo), ConstrucaoVeiculoCriado = 0x00);
  833. ConstrucaoVeiculo = CreateVehicle(ReturnVehicleID(inputtext), pPos[0], pPos[1], pPos[2], pPos[3], random(126), random(126), (60 * 60));
  834. PutPlayerInVehicle(playerid, ConstrucaoVeiculo, 0);
  835. ConstrucaoVeiculoCriado = 0x01;
  836. ShowDialog(playerid, 604);
  837. }
  838. }
  839. case 604:
  840. {
  841.  
  842. if(!response) return ShowDialog(playerid, 602);
  843. SendClientMessage(playerid, VERMELHO, ">> [x] IMPORTANTE: Aperte 'KEY_FIRE' Na Posiçao Local onde Será os Primeiros Lugares da Corrida.");
  844. SendClientMessage(playerid, VERMELHO, " Apos Setar as Posições Voce Continuara a Construção ");
  845. BuildVehPosCount = 0;
  846. BuildTakeVehPos = true;
  847. }
  848. case 605:
  849. {
  850.  
  851. if(!response) return ShowDialog(playerid, 604);
  852. SendClientMessage(playerid, VERMELHO, ">> Insira os Check-Points Pressionando 'KEY_FIRE' ");
  853. SendClientMessage(playerid, VERMELHO, " [x] IMPORTANTE: Pressione 'ENTER' Quando Inserir o Ultimo Check-Point Para o a Corrida Construida for Salva e Terminada ");
  854. ConstruirCheckPointCount = 0;
  855. BuildTakeCheckpoints = true;
  856. }
  857. case 606:
  858. {
  859.  
  860.  
  861. if(!response) return ShowDialog(playerid, 606);
  862. ConstruindoCorrida = 0;
  863. ConstruirCheckPointCount = 0;
  864. BuildVehPosCount = 0;
  865. BuildTakeCheckpoints = false;
  866. BuildTakeVehPos = false;
  867. ConstrucaoVeiculoCriado = (ConstrucaoVeiculoCriado == 0x01) ? (DestroyVehicle(ConstrucaoVeiculo), ConstrucaoVeiculoCriado = 0x00) : (DestroyVehicle(ConstrucaoVeiculo), ConstrucaoVeiculoCriado = 0x00);
  868. }
  869. }
  870. return 1;
  871. }
  872.  
  873. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  874. {
  875. new
  876. string[256], CorridaArquivo[256], arquivo[256], Float: vPos[4];
  877. if(newkeys & KEY_FIRE)
  878. {
  879. if(ConstruindoCorrida == playerid+1)
  880. {
  881. if(BuildTakeVehPos == true)
  882. {
  883. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, VERMELHO, ">> Voce Prescisa Estar em Um Veiculo");
  884. format(arquivo, sizeof(arquivo), DIRETORIO_CORRIDAS, NomeConstrucao);
  885. GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
  886. GetVehicleZAngle(GetPlayerVehicleID(playerid), vPos[3]);
  887. DOF2_CreateFile(arquivo);
  888. DOF2_SetInt(arquivo, "Modelo", ConstrucaoModeloID);
  889. DOF2_SetInt(arquivo, "Tipo", ConstrucaoCorridaTipo);
  890. format(string, sizeof(string), "PosX_%d", BuildVehPosCount), DOF2_SetFloat(arquivo, string, vPos[0]);
  891. format(string, sizeof(string), "PosY_%d", BuildVehPosCount), DOF2_SetFloat(arquivo, string, vPos[1]);
  892. format(string, sizeof(string), "PosZ_%d", BuildVehPosCount), DOF2_SetFloat(arquivo, string, vPos[2]);
  893. format(string, sizeof(string), "Angulo_%d", BuildVehPosCount), DOF2_SetFloat(arquivo, string, vPos[3]);
  894. format(string, sizeof(string), ">> Posição Do Veiculo '%d' Setado.", BuildVehPosCount+1);
  895. SendClientMessage(playerid, AMARELO, string);
  896. BuildVehPosCount++;
  897. }
  898. if(BuildVehPosCount >= 2)
  899. {
  900.  
  901. BuildVehPosCount = 0;
  902. BuildTakeVehPos = false;
  903. ShowDialog(playerid, 605);
  904. }
  905. if(BuildTakeCheckpoints == true)
  906. {
  907.  
  908. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, VERMELHO, "");
  909. if(ConstruirCheckPointCount > MAX_CHECKPOINTS) return SendClientMessage(playerid, VERMELHO, ">> Voce Atingiu o Limite Maximo de Check-Point");
  910. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, VERMELHO, ">> Voce Prescisa Estar em Um Veiculo");
  911. format(arquivo, sizeof(arquivo), DIRETORIO_CORRIDAS, NomeConstrucao);
  912. GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
  913. format(string, sizeof(string), "CP_%d_PosX", ConstruirCheckPointCount), DOF2_SetFloat(arquivo, string, vPos[0]);
  914. format(string, sizeof(string), "CP_%d_PosY", ConstruirCheckPointCount), DOF2_SetFloat(arquivo, string, vPos[1]);
  915. format(string, sizeof(string), "CP_%d_PosZ", ConstruirCheckPointCount), DOF2_SetFloat(arquivo, string, vPos[2]);
  916. format(string, sizeof(string), ">> Checkpoint '%d' Setado!", ConstruirCheckPointCount+1);
  917. SendClientMessage(playerid, AMARELO, string);
  918. ConstruirCheckPointCount++;
  919. }
  920. }
  921. }
  922. if(newkeys & KEY_SECONDARY_ATTACK)
  923. {
  924. if(BuildTakeCheckpoints == true)
  925. {
  926.  
  927. ShowDialog(playerid, 606);
  928. format(CorridaArquivo, sizeof(CorridaArquivo), DIRETORIO_NOME_CORRIDAS);
  929. TotalCorridas = DOF2_GetInt(CorridaArquivo, "TotalCorridas");
  930. TotalCorridas++;
  931. DOF2_SetInt(CorridaArquivo, "TotalCorridas", TotalCorridas);
  932. format(string, sizeof(string), "Race_%d", TotalCorridas-1);
  933. format(arquivo, sizeof(arquivo), DIRETORIO_CORRIDAS, NomeConstrucao);
  934. DOF2_SetString(CorridaArquivo, string, NomeConstrucao);
  935. DOF2_SetInt(arquivo, "TotalCP", ConstruirCheckPointCount);
  936. Loop(x, 5)
  937. {
  938.  
  939. format(string, sizeof(string), "MelhorTempoCorrida-%d", x);
  940. DOF2_SetString(arquivo, string, "0");
  941. format(string, sizeof(string), "MelhorCorrida-%d", x);
  942. DOF2_SetString(arquivo, string, "Nenhum");
  943. }
  944. }
  945. }
  946. return 1;
  947. }
  948.  
  949. function CarregarNomeCorridas()
  950. {
  951. new
  952. CorridaArquivo[64],string[64];
  953. format(CorridaArquivo, sizeof(CorridaArquivo), DIRETORIO_NOME_CORRIDAS);
  954. TotalCorridas = DOF2_GetInt(CorridaArquivo, "TotalCorridas");
  955. Loop(x, TotalCorridas)
  956. {
  957.  
  958. format(string, sizeof(string), "Race_%d", x), strmid(NomeCorridas[x], DOF2_GetString(CorridaArquivo, string), 0, 20, sizeof(NomeCorridas));
  959. printf(">> Loaded Races: %s", NomeCorridas[x]);
  960. }
  961. return 1;
  962. }
  963.  
  964. function CarregarCorridasAutomaticas(rName[])
  965. {
  966. new
  967. arquivo[256],
  968. string[256]
  969. ;
  970. format(arquivo, sizeof(arquivo), DIRETORIO_CORRIDAS, rName);
  971. strmid(NomeCorrida, rName, 0, strlen(rName), sizeof(NomeCorrida));
  972. VeiculoCorrida = DOF2_GetInt(arquivo, "Modelo");
  973. CorridaTipo = DOF2_GetInt(arquivo, "Tipo");
  974. TotalCP = DOF2_GetInt(arquivo, "TotalCP");
  975.  
  976. #if DEBUG_CORRIDA == 1
  977. printf("ModeloVeiculo: %d", VeiculoCorrida);
  978. printf("CorridaTipo: %d", CorridaTipo);
  979. printf("TotalCheckpoints: %d", TotalCP);
  980. #endif
  981.  
  982. Loop(x, 2)
  983. {
  984.  
  985. format(string, sizeof(string), "PosX_%d", x), CoordVehCorrida[x][0] = DOF2_GetFloat(arquivo, string);
  986. format(string, sizeof(string), "PosY_%d", x), CoordVehCorrida[x][1] = DOF2_GetFloat(arquivo, string);
  987. format(string, sizeof(string), "PosZ_%d", x), CoordVehCorrida[x][2] = DOF2_GetFloat(arquivo, string);
  988. format(string, sizeof(string), "Angulo_%d", x), CoordVehCorrida[x][3] = DOF2_GetFloat(arquivo, string);
  989. #if DEBUG_CORRIDA == 1
  990. printf("VeiculoPos %d: %f, %f, %f, %f", x, CoordVehCorrida[x][0], CoordVehCorrida[x][1], CoordVehCorrida[x][2], CoordVehCorrida[x][3]);
  991. #endif
  992. }
  993. Loop(x, TotalCP)
  994. {
  995.  
  996. format(string, sizeof(string), "CP_%d_PosX", x), CPCoords[x][0] = DOF2_GetFloat(arquivo, string);
  997. format(string, sizeof(string), "CP_%d_PosY", x), CPCoords[x][1] = DOF2_GetFloat(arquivo, string);
  998. format(string, sizeof(string), "CP_%d_PosZ", x), CPCoords[x][2] = DOF2_GetFloat(arquivo, string);
  999. #if DEBUG_CORRIDA == 1
  1000. printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
  1001. #endif
  1002. }
  1003. Posicao = 0;
  1004. FinishCount = 0;
  1005. JoinCount = 0;
  1006. Loop(x, 2) PlayersCount[x] = 0;
  1007. CountAmount = CONTAGEM_START;
  1008. CorridaTempo = MAX_CORRIDA_TEMPO;
  1009. RaceBusy = 0x01;
  1010. CountTimer = SetTimer("CountTillRace", 999, 1);
  1011. TempoProgresso = 0;
  1012. return 1;
  1013. }
  1014.  
  1015. function LoadRace(playerid, rName[])
  1016. {
  1017. new
  1018. arquivo[256],
  1019. string[256]
  1020. ;
  1021.  
  1022. format(arquivo, sizeof(arquivo), DIRETORIO_CORRIDAS, rName);
  1023. if(!DOF2_FileExists(arquivo)) return SendClientMessage(playerid, VERMELHO, "[x] Corrida Inexistente ! ");
  1024. strmid(NomeCorrida, rName, 0, strlen(rName), sizeof(NomeCorrida));
  1025. VeiculoCorrida = DOF2_GetInt(arquivo, "Modelo");
  1026. CorridaTipo = DOF2_GetInt(arquivo, "Tipo");
  1027. TotalCP = DOF2_GetInt(arquivo, "TotalCP");
  1028.  
  1029. #if DEBUG_CORRIDA == 1
  1030. printf("ModeloVeiculo: %d", VeiculoCorrida);
  1031. printf("CorridaTipo: %d", CorridaTipo);
  1032. printf("TotalCheckpoints: %d", TotalCP);
  1033. #endif
  1034.  
  1035. Loop(x, 2)
  1036. {
  1037.  
  1038. format(string, sizeof(string), "PosX_%d", x), CoordVehCorrida[x][0] = DOF2_GetFloat(arquivo, string);
  1039. format(string, sizeof(string), "PosY_%d", x), CoordVehCorrida[x][1] = DOF2_GetFloat(arquivo, string);
  1040. format(string, sizeof(string), "PosZ_%d", x), CoordVehCorrida[x][2] = DOF2_GetFloat(arquivo, string);
  1041. format(string, sizeof(string), "Angulo_%d", x), CoordVehCorrida[x][3] = DOF2_GetFloat(arquivo, string);
  1042. #if DEBUG_CORRIDA == 1
  1043. printf("VeiculoPos %d: %f, %f, %f, %f", x, CoordVehCorrida[x][0], CoordVehCorrida[x][1], CoordVehCorrida[x][2], CoordVehCorrida[x][3]);
  1044. #endif
  1045. }
  1046. Loop(x, TotalCP)
  1047. {
  1048.  
  1049. format(string, sizeof(string), "CP_%d_PosX", x), CPCoords[x][0] = DOF2_GetFloat(arquivo, string);
  1050. format(string, sizeof(string), "CP_%d_PosY", x), CPCoords[x][1] = DOF2_GetFloat(arquivo, string);
  1051. format(string, sizeof(string), "CP_%d_PosZ", x), CPCoords[x][2] = DOF2_GetFloat(arquivo, string);
  1052. #if DEBUG_CORRIDA == 1
  1053. printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
  1054. #endif
  1055. }
  1056. Posicao = 0;
  1057. FinishCount = 0;
  1058. JoinCount = 0;
  1059. Loop(x, 2) PlayersCount[x] = 0;
  1060. NaCorrida[playerid] = true;
  1061. CountAmount = CONTAGEM_START;
  1062. CorridaTempo = MAX_CORRIDA_TEMPO;
  1063. RaceBusy = 0x01;
  1064. TempoProgresso = 0;
  1065. SetupRaceForPlayer(playerid);
  1066. CountTimer = SetTimer("CountTillRace", 999, 1);
  1067. return 1;
  1068. }
  1069.  
  1070. function SetCP(playerid, PrevCP, NextCP, MaxCP, Type)
  1071. {
  1072. if(Type == 0)
  1073. {
  1074.  
  1075. if(NextCP == MaxCP) SetPlayerRaceCheckpoint(playerid, 1, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], TAMANHO_CHECKPOINTS);
  1076. else SetPlayerRaceCheckpoint(playerid, 0, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], TAMANHO_CHECKPOINTS);
  1077. }
  1078. else if(Type == 3)
  1079. {
  1080.  
  1081. if(NextCP == MaxCP) SetPlayerRaceCheckpoint(playerid, 4, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], TAMANHO_CHECKPOINTS);
  1082. else SetPlayerRaceCheckpoint(playerid, 3, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], TAMANHO_CHECKPOINTS);
  1083. }
  1084. return 1;
  1085. }
  1086.  
  1087. function SetupRaceForPlayer(playerid)
  1088. {
  1089. CPProgesso[playerid] = 0;
  1090. TogglePlayerControllable(playerid, false);
  1091. CPCoords[playerid][3] = 0;
  1092. SetCP(playerid, CPProgesso[playerid], CPProgesso[playerid]+1, TotalCP, CorridaTipo);
  1093. if(IsOdd(playerid)) Index = 1;
  1094. else Index = 0;
  1095.  
  1096. switch(Index)
  1097. {
  1098.  
  1099. case 0:
  1100. {
  1101.  
  1102. if(PlayersCount[0] == 1)
  1103. {
  1104.  
  1105.  
  1106. CoordVehCorrida[0][0] -= (6 * floatsin(-CoordVehCorrida[0][3], degrees));
  1107. CoordVehCorrida[0][1] -= (6 * floatcos(-CoordVehCorrida[0][3], degrees));
  1108. if(IsPlayerInAnyVehicle(playerid) == 1)
  1109. RepairVehicle(playerid);
  1110. CriarVehCorrida[playerid] = CreateVehicle(VeiculoCorrida, CoordVehCorrida[0][0], CoordVehCorrida[0][1], CoordVehCorrida[0][2]+2, CoordVehCorrida[0][3], random(126), random(126), (60 * 60));
  1111. SetPlayerPos(playerid, CoordVehCorrida[0][0], CoordVehCorrida[0][1], CoordVehCorrida[0][2]+2);
  1112. SetPlayerFacingAngle(playerid, CoordVehCorrida[0][3]);
  1113. PutPlayerInVehicle(playerid, CriarVehCorrida[playerid], RepairVehicle(playerid));
  1114. SetVehicleHealth(GetPlayerVehicleID(playerid),99999);
  1115. Camera(playerid, CoordVehCorrida[0][0], CoordVehCorrida[0][1], CoordVehCorrida[0][2], CoordVehCorrida[0][3], 20);
  1116. }
  1117. }
  1118. case 1:
  1119. {
  1120.  
  1121. if(PlayersCount[1] == 1)
  1122. {
  1123.  
  1124.  
  1125. CoordVehCorrida[1][0] -= (6 * floatsin(-CoordVehCorrida[1][3], degrees));
  1126. CoordVehCorrida[1][1] -= (6 * floatcos(-CoordVehCorrida[1][3], degrees));
  1127. CriarVehCorrida[playerid] = CreateVehicle(VeiculoCorrida, CoordVehCorrida[1][0], CoordVehCorrida[1][1], CoordVehCorrida[1][2]+2, CoordVehCorrida[1][3], random(126), random(126), (60 * 60));
  1128. SetPlayerPos(playerid, CoordVehCorrida[1][0], CoordVehCorrida[1][1], CoordVehCorrida[1][2]+2);
  1129. SetPlayerFacingAngle(playerid, CoordVehCorrida[1][3]);
  1130. PutPlayerInVehicle(playerid, CriarVehCorrida[playerid], 0);
  1131. SetVehicleHealth(GetPlayerVehicleID(playerid),99999);
  1132. RepairVehicle(GetPlayerVehicleID(playerid));
  1133. Camera(playerid, CoordVehCorrida[1][0], CoordVehCorrida[1][1], CoordVehCorrida[1][2], CoordVehCorrida[1][3], 20);
  1134. }
  1135. }
  1136. }
  1137. switch(Index)
  1138. {
  1139.  
  1140. case 0:
  1141. {
  1142.  
  1143. if(PlayersCount[0] != 1)
  1144. {
  1145.  
  1146.  
  1147. CriarVehCorrida[playerid] = CreateVehicle(VeiculoCorrida, CoordVehCorrida[0][0], CoordVehCorrida[0][1], CoordVehCorrida[0][2]+2, CoordVehCorrida[0][3], random(126), random(126), (60 * 60));
  1148. SetPlayerPos(playerid, CoordVehCorrida[0][0], CoordVehCorrida[0][1], CoordVehCorrida[0][2]+2);
  1149. SetPlayerFacingAngle(playerid, CoordVehCorrida[0][3]);
  1150. PutPlayerInVehicle(playerid, CriarVehCorrida[playerid], 0);
  1151. SetVehicleHealth(GetPlayerVehicleID(playerid),99999);
  1152. RepairVehicle(GetPlayerVehicleID(playerid));
  1153. Camera(playerid, CoordVehCorrida[0][0], CoordVehCorrida[0][1], CoordVehCorrida[0][2], CoordVehCorrida[0][3], 20);
  1154. PlayersCount[0] = 1;
  1155. }
  1156. }
  1157. case 1:
  1158. {
  1159.  
  1160. if(PlayersCount[1] != 1)
  1161. {
  1162.  
  1163.  
  1164. CriarVehCorrida[playerid] = CreateVehicle(VeiculoCorrida, CoordVehCorrida[1][0], CoordVehCorrida[1][1], CoordVehCorrida[1][2]+2, CoordVehCorrida[1][3], random(126), random(126), (60 * 60));
  1165. SetPlayerPos(playerid, CoordVehCorrida[1][0], CoordVehCorrida[1][1], CoordVehCorrida[1][2]+2);
  1166. SetVehicleHealth(GetPlayerVehicleID(playerid),99999);
  1167. SetPlayerFacingAngle(playerid, CoordVehCorrida[1][3]);
  1168. PutPlayerInVehicle(playerid, CriarVehCorrida[playerid], 0);
  1169. Camera(playerid, CoordVehCorrida[1][0], CoordVehCorrida[1][1], CoordVehCorrida[1][2], CoordVehCorrida[1][3], 20);
  1170. PlayersCount[1] = 1;
  1171. }
  1172. }
  1173. }
  1174. new
  1175. string[128];
  1176. #if defined RACE_IN_OTHER_WORLD
  1177. SetPlayerVirtualWorld(playerid, 10);
  1178. #endif
  1179. InfoTimer[playerid] = SetTimerEx("TextInfo", 500, 1, "e", playerid);
  1180. if(JoinCount == 1) format(string, sizeof(string), "Corrida: ~w~%s~n~~p~~h~Checkpoint: ~w~%d/%d~n~~b~~h~CorridaTempo: ~w~%s~n~~y~Posicao: ~w~1/1~n~ ", NomeCorrida, CPProgesso[playerid], TotalCP, TempoConvertido(CorridaTempo));
  1181. else format(string, sizeof(string), "Corrida: ~w~%s~n~~p~~h~Checkpoint: ~w~%d/%d~n~~b~~h~CorridaTempo: ~w~%s~n~~y~Posicao: ~w~%d/%d~n~ ", NomeCorrida, CPProgesso[playerid], TotalCP, TempoConvertido(CorridaTempo), Colocacao[playerid], JoinCount);
  1182. TextDrawSetString(CorridaInfo[playerid], string);
  1183. TextDrawShowForPlayer(playerid, CorridaInfo[playerid]);
  1184. JoinCount++;
  1185. return 1;
  1186. }
  1187.  
  1188. function CountTillRace()
  1189. {
  1190. switch(CountAmount)
  1191. {
  1192.  
  1193. case 0:
  1194. {
  1195.  
  1196. ForEach(i, MAX_PLAYERS)
  1197. {
  1198.  
  1199. if(NaCorrida[i] == false)
  1200. {
  1201.  
  1202. new
  1203. string[128]
  1204. ;
  1205. format(string, sizeof(string), ">> Você não pode participar de corrida chamado %s mais. Junte-se tempo está acabado!", NomeCorrida);
  1206. SendClientMessage(i, VERMELHO, string);
  1207. }
  1208. }
  1209. StartRace();
  1210. }
  1211. case 1..5:
  1212. {
  1213.  
  1214. new
  1215. string[10]
  1216. ;
  1217. format(string, sizeof(string), "~b~%d", CountAmount);
  1218. ForEach(i, MAX_PLAYERS)
  1219. {
  1220.  
  1221. if(NaCorrida[i] == true)
  1222. {
  1223.  
  1224. GameTextForPlayer(i, string, 999, 5);
  1225. PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
  1226. }
  1227. }
  1228. }
  1229. case 60, 50, 40, 30, 20, 10:
  1230. {
  1231.  
  1232. new
  1233. string[128]
  1234. ;
  1235. format(string, sizeof(string), ">> Uma Corrida Foi Iniciada ! Digite /EntrarRace para Participar da Corrida");
  1236. SendClientMessageToAll(VERMELHO, string);
  1237. }
  1238. }
  1239. return CountAmount--;
  1240. }
  1241.  
  1242. function StartRace()
  1243. {
  1244. ForEach(i, MAX_PLAYERS)
  1245. {
  1246.  
  1247. if(NaCorrida[i] == true)
  1248. {
  1249.  
  1250. TogglePlayerControllable(i, true);
  1251. PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
  1252. GameTextForPlayer(i, "~g~GO GO GO", 2000, 5);
  1253. SetCameraBehindPlayer(i);
  1254. SetVehicleHealth(GetPlayerVehicleID(i),99999);
  1255. RepairVehicle(GetPlayerVehicleID(i));
  1256. }
  1257. }
  1258. rCounter = SetTimer("RaceCounter", 900, 1);
  1259. CorridaTick = GetTickCount();
  1260. CorridaIniciada = 1;
  1261. KillTimer(CountTimer);
  1262. return 1;
  1263. }
  1264.  
  1265. function StopRace()
  1266. {
  1267. KillTimer(rCounter);
  1268. CorridaIniciada = 0;
  1269. CorridaTick = 0;
  1270. RaceBusy = 0x00;
  1271. JoinCount = 0;
  1272. FinishCount = 0;
  1273. TempoProgresso = 0;
  1274.  
  1275. ForEach(i, MAX_PLAYERS)
  1276. {
  1277.  
  1278. if(NaCorrida[i] == true)
  1279. {
  1280.  
  1281. DisablePlayerRaceCheckpoint(i);
  1282. DestroyVehicle(CriarVehCorrida[i]);
  1283. NaCorrida[i] = false;
  1284. TextDrawHideForPlayer(i, CorridaInfo[i]);
  1285. CPProgesso[i] = 0;
  1286. KillTimer(InfoTimer[i]);
  1287. }
  1288. }
  1289. if(CorrridasAutomaticas == true) CarregarNomeCorridas(), CarregarCorridasAutomaticas(NomeCorridas[random(TotalCorridas)]);
  1290. return 1;
  1291. }
  1292.  
  1293. function RaceCounter()
  1294. {
  1295. if(CorridaIniciada == 1)
  1296. {
  1297.  
  1298. CorridaTempo--;
  1299. if(JoinCount <= 0)
  1300. {
  1301.  
  1302. StopRace();
  1303. SendClientMessageToAll(VERMELHO, "---------------------------------------------------------------------------------------");
  1304. SendClientMessageToAll(VERMELHO, "");
  1305. SendClientMessageToAll(VERMELHO, ">> Corrida Encerrada Por Nao Haver Competidores ...");
  1306. SendClientMessageToAll(VERMELHO, "");
  1307. SendClientMessageToAll(VERMELHO, "---------------------------------------------------------------------------------------");
  1308. }
  1309. }
  1310. if(CorridaTempo <= 0)
  1311. {
  1312.  
  1313. StopRace();
  1314. }
  1315. return 1;
  1316. }
  1317.  
  1318. function TextInfo(playerid)
  1319. {
  1320. new
  1321. string[128]
  1322. ;
  1323. if(JoinCount == 1) format(string, sizeof(string), "Corrida: ~w~%s~n~~p~~h~Checkpoint: ~w~%d/%d~n~~b~~h~CorridaTempo: ~w~%s~n~~y~Posicao: ~w~1/1~n~", NomeCorrida, CPProgesso[playerid], TotalCP, TempoConvertido(CorridaTempo));
  1324. else format(string, sizeof(string), "Corrida: ~w~%s~n~~p~~h~Checkpoint: ~w~%d/%d~n~~b~~h~CorridaTempo: ~w~%s~n~~y~Posicao: ~w~%d/%d~n~", NomeCorrida, CPProgesso[playerid], TotalCP, TempoConvertido(CorridaTempo), Colocacao[playerid], JoinCount);
  1325. TextDrawSetString(CorridaInfo[playerid], string);
  1326. TextDrawShowForPlayer(playerid, CorridaInfo[playerid]);
  1327. }
  1328.  
  1329. function Camera(playerid, Float:X, Float:Y, Float:Z, Float:A, Mul)
  1330. {
  1331. SetPlayerCameraLookAt(playerid, X, Y, Z);
  1332. SetPlayerCameraPos(playerid, X + (Mul * floatsin(-A, degrees)), Y + (Mul * floatcos(-A, degrees)), Z+6);
  1333. }
  1334.  
  1335. function IsPlayerInRace(playerid)
  1336. {
  1337. if(NaCorrida[playerid] == true) return true;
  1338. else return false;
  1339. }
  1340.  
  1341. function ShowDialog(playerid, dialogid)
  1342. {
  1343. switch(dialogid)
  1344. {
  1345. case 599: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, CreateCaption("Construir Nova Corrida"), "\
  1346. Corrida Terrestre / Nautica\n\
  1347. Corrida Aerea", "Next", "Exit");
  1348.  
  1349. case 600: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Construir Nova Corrida (Etapa 1/4)"), "\
  1350. {F50000}Etapa 1:\n\
  1351. \n\
  1352. {A1A1A3}Bem Vindo a Modo 'Construção de Corrida'.\n\
  1353. Aqui Voce Iniciar a Construir uma Nova Corrida, Insira um NOME para Sua Corrida, EX: RACE-1\n\n\
  1354. >> Insira Um NOME para Sua Corrida e Pressione 'Next' Para Continuar.", "Next", "Back");
  1355.  
  1356. case 601: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Construir Nova Corrida (Etapa 1/4)"), "\
  1357. {F50000}ERRO: Nome Da Corrida Muito Grande/Pequeno (Min. 1 - Max. 20)\n\n\
  1358. {F50000}Etapa 1:\n\
  1359. ********\n\
  1360. {A1A1A3}Bem Vindo ao Modo 'Construção de Corrida'.\n\
  1361. Aqui Voce Iniciar a Construir uma Nova Corrida, Insira um NOME para Sua Corrida, EX: RACE-1\n\n\
  1362. >> Insira o Nome da Corrida e Pressione 'Next' Para Continuar", "Next", "Back");
  1363.  
  1364. case 602: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Construir Nova Corrida (Etapa 2/4)"), "\
  1365. {F50000}Etapa 2:\n\
  1366. \n\
  1367. {A1A1A3}Insira o ID do Veiculo a Ser usado Na Corrida Ou o NOME Para Continuar Sua Construção.\n\n\
  1368. >> Insira o ID ou o NOME Do Veiculo e Pressione 'Next' Para Continuar. 'Back' Para Voltar.", "Next", "Back");
  1369.  
  1370. case 603: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Construir Nova Corrida (Etapa 2/4)"), "\
  1371. {F50000}ERRO: ID Invalido/Nome\n\n\
  1372. {F50000}Etapa 2:\n\
  1373. \n\
  1374. {A1A1A3}ID Invalido! Insira o ID do Veiculo a Ser usado Na Corrida Ou o NOME Para Continuar Sua Construção.\n\n\
  1375. >> Insira o ID ou o NOME Do Veiculo e Pressione 'Next' Para Continuar. 'Back' Para Voltar. ", "Next", "Back");
  1376.  
  1377. case 604: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Construir Nova Corrida (Etapa 3/4)"),
  1378. "\
  1379. {F50000}Etapa3:\n\
  1380. \n\
  1381. {A1A1A3}Agora Voce Tera que Setar as Posições do Primeiro e Segundo Lugar da Largada.\n\
  1382. Nota: Clicando Em 'OK' Retorna em Modo Free. Aperte 'KEY_FIRE' Para Setar as Posições do Primeiro e Segundo Lugar. \n\
  1383. Nota: Apos Setar as Posições, Voce ira para a Ultima Etapa da Construção\n\n\
  1384. >> Pressione 'OK' Para Continuar. 'Back' Para Voltar.", "OK", "Back");
  1385.  
  1386. case 605: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Construir Nova Corrida (Etapa 4/4)"),
  1387. "\
  1388. {F50000}Etapa 4:\n\
  1389. \n\
  1390. {A1A1A3}Aqui Voce Setara os Check-Points Para Sua Corrida.\n\
  1391. Para Setar os Check-Poits Pressione 'KEY_FIRE' No Lugar Desejado, o Check-Point Ira Salvar Automaticamente. \n\
  1392. Ao Terminar Pressione 'ENTER' Para Finalizar Sua Corrida \n\n\
  1393. >> Pressione 'OK' Para Continuar. 'Back' Para Voltar.", "OK", "Back");
  1394.  
  1395. case 606: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Construir Nova Corrida (Done)"),
  1396. "\
  1397. Você Criou uma nova Corrida. \n\n\
  1398. >> Pressione 'Final' Para Terminar ou 'Exit' Para Sair Sem Salvar a Corrida ", "Final", "Exit");
  1399. }
  1400. return 1;
  1401. }
  1402.  
  1403. CreateCaption(arguments[])
  1404. {
  1405.  
  1406. new
  1407. string[128 char]
  1408. ;
  1409. format(string, sizeof(string), "{03FF5F}» {F50000}Corrida", arguments);
  1410. return string;
  1411. }
  1412.  
  1413. stock IsValidVehicle(vehicleid)
  1414. {
  1415. if(vehicleid < 400 || vehicleid > 611) return false;
  1416. else return true;
  1417. }
  1418.  
  1419. ReturnVehicleID(vName[])
  1420. {
  1421. Loop(x, 211)
  1422. {
  1423.  
  1424. if(strfind(vNames[x], vName, true) != -1)
  1425. return x + 400;
  1426. }
  1427. return -1;
  1428. }
  1429.  
  1430. TempoConvertido(seconds)
  1431. {
  1432. new tmp[16];
  1433. new minutes = floatround(seconds/60);
  1434. seconds -= minutes*60;
  1435. format(tmp, sizeof(tmp), "%d:%02d", minutes, seconds);
  1436. return tmp;
  1437. }
  1438. stock isNumeric(const string[])
  1439. {
  1440. new length=strlen(string);
  1441. if (length==0) return false;
  1442. for (new i = 0; i < length; i++)
  1443. {
  1444. if (
  1445. (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+')
  1446. || (string[i]=='-' && i!=0)
  1447. || (string[i]=='+' && i!=0)
  1448. ) return false;
  1449. }
  1450. if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
  1451. return true;
  1452. }
  1453.  
  1454. forward GodModEvento();
  1455. public GodModEvento()
  1456. {
  1457. for(new i; i < MAX_VEHICLES; ++i)
  1458. {
  1459. RepairVehicle(i);
  1460. SetVehicleHealth(i, 1000.0);
  1461. }
  1462. return 1;
  1463. }
Advertisement
Add Comment
Please, Sign In to add comment