Rei_Ayanami

Corrida3

Mar 4th, 2021
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.08 KB | None | 0 0
  1. /* Criando Creditos pelo Rei Ayanami e Extreme_
  2. [FS] Corrida Race Construir
  3. Não retire meu creditos -_-
  4. Meu discord e FuriaDaNoite#2316
  5.  
  6. CORRIDA 3°
  7.  
  8. [NOVOS ADICIONAR]
  9. Adicionar Corrida TextDraw
  10. Adicionar Ckeckpoint Pequeno
  11. Adicionar dinheiro aleatório
  12. Adicionar Comandos Fixed: /sairrace
  13. Adicionar Comandos: /eventos
  14. */
  15.  
  16. #include <a_samp>
  17. #include <Dini_race>
  18. #include <zcmd>
  19.  
  20. #pragma unused \
  21. ret_memcpy
  22.  
  23. #define ForEach(%0,%1) \
  24. for(new %0 = 0; %0 != %1; %0++) if(IsPlayerConnected(%0) && !IsPlayerNPC(%0))
  25.  
  26. #define Loop(%0,%1) \
  27. for(new %0 = 0; %0 != %1; %0++)
  28.  
  29. #define IsOdd(%1) \
  30. ((%1) & 1)
  31.  
  32. #define ConvertTime(%0,%1,%2,%3,%4) \
  33. new \
  34. Float: %0 = floatdiv(%1, 60000) \
  35. ;\
  36. %2 = floatround(%0, floatround_tozero); \
  37. %3 = floatround(floatmul(%0 - %2, 60), floatround_tozero); \
  38. %4 = floatround(floatmul(floatmul(%0 - %2, 60) - %3, 1000), floatround_tozero)
  39.  
  40. #define function%0(%1) \
  41. forward%0(%1); public%0(%1)
  42.  
  43. #define MAX_RACE_CHECKPOINTS_EACH_RACE \
  44. 120
  45.  
  46. #define MAX_RACES \
  47. 100
  48.  
  49. #define COUNT_DOWN_TILL_RACE_START \
  50. 31 // segundo
  51.  
  52. #define MAX_RACE_TIME \
  53. 300 // segundo
  54.  
  55. #define RACE_CHECKPOINT_SIZE \
  56. 5.10
  57.  
  58. #define DEBUG_RACE \
  59. 1
  60.  
  61. #define GREY \
  62. 0xAFAFAFAA
  63.  
  64. #define GREEN \
  65. 0x9FFF00FF
  66.  
  67. #define RED \
  68. 0xE60000FF
  69.  
  70. #define YELLOW \
  71. 0xFFFF00AA
  72.  
  73. #define WHITE \
  74. 0xFFFFFFAA
  75.  
  76. #define SD ShowPlayerDialog
  77. #define DIALOG_BEGIN 905
  78. #define DM DIALOG_STYLE_MSGBOX
  79. #define CM_MAX_PLAYERS (20) // maximo jogador 20 slots
  80.  
  81. new EntrarSlots;
  82.  
  83. new
  84. vNames[212][] =
  85. {
  86. {"Landstalker"},
  87. {"Bravura"},
  88. {"Buffalo"},
  89. {"Linerunner"},
  90. {"Perrenial"},
  91. {"Sentinel"},
  92. {"Dumper"},
  93. {"Firetruck"},
  94. {"Trashmaster"},
  95. {"Stretch"},
  96. {"Manana"},
  97. {"Infernus"},
  98. {"Voodoo"},
  99. {"Pony"},
  100. {"Mule"},
  101. {"Cheetah"},
  102. {"Ambulance"},
  103. {"Leviathan"},
  104. {"Moonbeam"},
  105. {"Esperanto"},
  106. {"Taxi"},
  107. {"Washington"},
  108. {"Bobcat"},
  109. {"Mr Whoopee"},
  110. {"BF Injection"},
  111. {"Hunter"},
  112. {"Premier"},
  113. {"Enforcer"},
  114. {"Securicar"},
  115. {"Banshee"},
  116. {"Predator"},
  117. {"Bus"},
  118. {"Rhino"},
  119. {"Barracks"},
  120. {"Hotknife"},
  121. {"Trailer 1"},
  122. {"Previon"},
  123. {"Coach"},
  124. {"Cabbie"},
  125. {"Stallion"},
  126. {"Rumpo"},
  127. {"RC Bandit"},
  128. {"Romero"},
  129. {"Packer"},
  130. {"Monster"},
  131. {"Admiral"},
  132. {"Squalo"},
  133. {"Seasparrow"},
  134. {"Pizzaboy"},
  135. {"Tram"},
  136. {"Trailer 2"},
  137. {"Turismo"},
  138. {"Speeder"},
  139. {"Reefer"},
  140. {"Tropic"},
  141. {"Flatbed"},
  142. {"Yankee"},
  143. {"Caddy"},
  144. {"Solair"},
  145. {"Berkley's RC Van"},
  146. {"Skimmer"},
  147. {"PCJ-600"},
  148. {"Faggio"},
  149. {"Freeway"},
  150. {"RC Baron"},
  151. {"RC Raider"},
  152. {"Glendale"},
  153. {"Oceanic"},
  154. {"Sanchez"},
  155. {"Sparrow"},
  156. {"Patriot"},
  157. {"Quad"},
  158. {"Coastguard"},
  159. {"Dinghy"},
  160. {"Hermes"},
  161. {"Sabre"},
  162. {"Rustler"},
  163. {"ZR-350"},
  164. {"Walton"},
  165. {"Regina"},
  166. {"Comet"},
  167. {"BMX"},
  168. {"Burrito"},
  169. {"Camper"},
  170. {"Marquis"},
  171. {"Baggage"},
  172. {"Dozer"},
  173. {"Maverick"},
  174. {"News Chopper"},
  175. {"Rancher"},
  176. {"FBI Rancher"},
  177. {"Virgo"},
  178. {"Greenwood"},
  179. {"Jetmax"},
  180. {"Hotring"},
  181. {"Sandking"},
  182. {"Blista Compact"},
  183. {"Police Maverick"},
  184. {"Boxville"},
  185. {"Benson"},
  186. {"Mesa"},
  187. {"RC Goblin"},
  188. {"Hotring Racer A"},
  189. {"Hotring Racer B"},
  190. {"Bloodring Banger"},
  191. {"Rancher"},
  192. {"Super GT"},
  193. {"Elegant"},
  194. {"Journey"},
  195. {"Bike"},
  196. {"Mountain Bike"},
  197. {"Beagle"},
  198. {"Cropdust"},
  199. {"Stunt"},
  200. {"Tanker"},
  201. {"Roadtrain"},
  202. {"Nebula"},
  203. {"Majestic"},
  204. {"Buccaneer"},
  205. {"Shamal"},
  206. {"Hydra"},
  207. {"FCR-900"},
  208. {"NRG-500"},
  209. {"HPV1000"},
  210. {"Cement Truck"},
  211. {"Tow Truck"},
  212. {"Fortune"},
  213. {"Cadrona"},
  214. {"FBI Truck"},
  215. {"Willard"},
  216. {"Forklift"},
  217. {"Tractor"},
  218. {"Combine"},
  219. {"Feltzer"},
  220. {"Remington"},
  221. {"Slamvan"},
  222. {"Blade"},
  223. {"Freight"},
  224. {"Streak"},
  225. {"Vortex"},
  226. {"Vincent"},
  227. {"Bullet"},
  228. {"Clover"},
  229. {"Sadler"},
  230. {"Firetruck LA"},
  231. {"Hustler"},
  232. {"Intruder"},
  233. {"Primo"},
  234. {"Cargobob"},
  235. {"Tampa"},
  236. {"Sunrise"},
  237. {"Merit"},
  238. {"Utility"},
  239. {"Nevada"},
  240. {"Yosemite"},
  241. {"Windsor"},
  242. {"Monster A"},
  243. {"Monster B"},
  244. {"Uranus"},
  245. {"Jester"},
  246. {"Sultan"},
  247. {"Stratum"},
  248. {"Elegy"},
  249. {"Raindance"},
  250. {"RC Tiger"},
  251. {"Flash"},
  252. {"Tahoma"},
  253. {"Savanna"},
  254. {"Bandito"},
  255. {"Freight Flat"},
  256. {"Streak Carriage"},
  257. {"Kart"},
  258. {"Mower"},
  259. {"Duneride"},
  260. {"Sweeper"},
  261. {"Broadway"},
  262. {"Tornado"},
  263. {"AT-400"},
  264. {"DFT-30"},
  265. {"Huntley"},
  266. {"Stafford"},
  267. {"BF-400"},
  268. {"Newsvan"},
  269. {"Tug"},
  270. {"Trailer 3"},
  271. {"Emperor"},
  272. {"Wayfarer"},
  273. {"Euros"},
  274. {"Hotdog"},
  275. {"Club"},
  276. {"Freight Carriage"},
  277. {"Trailer 3"},
  278. {"Andromada"},
  279. {"Dodo"},
  280. {"RC Cam"},
  281. {"Launch"},
  282. {"Police Car (LSPD)"},
  283. {"Police Car (SFPD)"},
  284. {"Police Car (LVPD)"},
  285. {"Police Ranger"},
  286. {"Picador"},
  287. {"S.W.A.T. Van"},
  288. {"Alpha"},
  289. {"Phoenix"},
  290. {"Glendale"},
  291. {"Sadler"},
  292. {"Luggage Trailer A"},
  293. {"Luggage Trailer B"},
  294. {"Stair Trailer"},
  295. {"Boxville"},
  296. {"Farm Plow"},
  297. {"Utility Trailer"}
  298. },
  299. BuildRace,
  300. BuildRaceType,
  301. BuildVehicle,
  302. BuildCreatedVehicle,
  303. BuildModeVID,
  304. BuildName[30],
  305. bool: BuildTakeVehPos,
  306. BuildVehPosCount,
  307. bool: BuildTakeCheckpoints,
  308. BuildCheckPointCount,
  309. RaceBusy = 0x00,
  310. RaceName[30],
  311. RaceVehicle,
  312. RaceType,
  313. TotalCP,
  314. Float: RaceVehCoords[2][4],
  315. Float: CPCoords[MAX_RACE_CHECKPOINTS_EACH_RACE][4],
  316. CreatedRaceVeh[MAX_PLAYERS],
  317. Index,
  318. PlayersCount[2],
  319. CountTimer,
  320. CountAmount,
  321. bool: Joined[MAX_PLAYERS],
  322. RaceTick,
  323. RaceStarted,
  324. CPProgess[MAX_PLAYERS],
  325. Position,
  326. FinishCount,
  327. JoinCount,
  328. rCounter,
  329. RaceTime,
  330. Text: RaceInfo[MAX_PLAYERS],
  331. InfoTimer[MAX_PLAYERS],
  332. RacePosition[MAX_PLAYERS],
  333. RaceNames[MAX_RACES][128],
  334. TotalRaces,
  335. bool: AutomaticRace,
  336. TimeProgress
  337. ;
  338.  
  339. public OnFilterScriptExit()
  340. {
  341. BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
  342. KillTimer(rCounter);
  343. KillTimer(CountTimer);
  344. Loop(i, MAX_PLAYERS)
  345. {
  346. DisablePlayerRaceCheckpoint(i);
  347. TextDrawDestroy(RaceInfo[i]);
  348. DestroyVehicle(CreatedRaceVeh[i]);
  349. Joined[i] = false;
  350. KillTimer(InfoTimer[i]);
  351. }
  352. JoinCount = 0;
  353. FinishCount = 0;
  354. TimeProgress = 0;
  355. AutomaticRace = false;
  356. return 1;
  357. }
  358.  
  359. //>>>>>>>>>>>>>>>> COMANDOS <<<<<<<<<<<<<<<<<<<
  360. CMD:eventos(playerid)
  361. {
  362. new string[618];
  363. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "{ffffff}» {ff2400}Voce nao e uma administrador!");
  364.  
  365. strcat(string, "{ff2400}Corrida Evento {02F6E5}3°\n\n");
  366. strcat(string, "{ffffff}/startautorace {02F6E5}Iniciar corrida aleatoria automaticamente\n");
  367. strcat(string, "{ffffff}/stopautorace {02F6E5}Fechar Corrida Desativado\n");
  368. strcat(string, "{ffffff}/iniciarrace {02F6E5}nome do corrida mapas\n");
  369. strcat(string, "{ffffff}/relogarace {02F6E5}para corrida relogar automaticamente\n");
  370. strcat(string, "{ffffff}/stoprace {02F6E5}corrida aleatoria automaticamente novamente\n");
  371. strcat(string, "{ffffff}/criarace {02F6E5}Construir na corrida\n");
  372. strcat(string, "{ffffff}/addveh {02F6E5}Adicionar posicao Veiculos\n");
  373. strcat(string, "{ffffff}/addcp {02F6E5}Adicionar Posicao Ckeckpoint\n");
  374. strcat(string, "{ffffff}/endcp {02F6E5}Final Linha Posicao Ckeckpoint\n\n");
  375. strcat(string, "{ff2400}Creditos By FuriaDaNoite & Mateus Santos\n");
  376. SD(playerid, DIALOG_BEGIN, DM, "Menu Evento", string, "Ok", "");
  377. return 1;
  378. }
  379.  
  380.  
  381. CMD:criarace(playerid, params[])
  382. {
  383. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "» Voce nao e uma administrador!!");
  384. if(BuildRace != 0) return SendClientMessage(playerid, RED, "<!> There's already someone building a race!");
  385. if(RaceBusy == 0x01) return SendClientMessage(playerid, RED, "<!> Espere primeiro ate a corrida terminar!");
  386. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "<!> Por favor, deixe seu veiculo primeiro!");
  387. BuildRace = playerid+1;
  388. ShowDialog(playerid, 599);
  389. return 1;
  390. }
  391. CMD:iniciarace(playerid, params[])
  392. {
  393. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "» Voce nao e uma administrador!!");
  394. if(AutomaticRace == true) return SendClientMessage(playerid, RED, "<!> Nao e possivel. A corrida automatica esta habilitada!");
  395. if(BuildRace != 0) return SendClientMessage(playerid, RED, "<!> Alguem esta construindo uma corrida!");
  396. if(RaceBusy == 0x01 || RaceStarted == 1) return SendClientMessage(playerid, RED, "<!> Ha uma corrida atualmente. Espere primeiro ate a corrida terminar!");
  397. if(isnull(params)) return SendClientMessage(playerid, RED, "<!> /iniciarace [nome corrida]");
  398. LoadRace(playerid, params);
  399. return 1;
  400. }
  401. CMD:relogarace(playerid, params[])
  402. {
  403. new pName[MAX_PLAYER_NAME];
  404. GetPlayerName(playerid, pName, sizeof(pName));
  405. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "» Voce nao e uma administrador!!");
  406. if(RaceBusy == 0x00 || RaceStarted == 0) return SendClientMessage(playerid, RED, "<!> Nao ha corrida para parar!");
  407. return StopRace();
  408. }
  409. CMD:stoprace(playerid, params[])
  410. {
  411. new pName[MAX_PLAYER_NAME];
  412. GetPlayerName(playerid, pName, sizeof(pName));
  413. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "» Voce nao e uma administrador!!");
  414. KillTimer(CountTimer);
  415. if(RaceBusy == 0x00 || RaceStarted == 0) return StopRace();
  416. return 1;
  417. }
  418.  
  419. CMD:entermp(playerid, params[])
  420. {
  421. new string[800], pName[MAX_PLAYER_NAME];
  422. GetPlayerName(playerid, pName, sizeof(pName));
  423. if(RaceStarted == 1) return SendClientMessage(playerid, RED, "{30D5C8}» {ffffff}Por favor espere ate o final do evento.");
  424. if(RaceBusy == 0x00) return SendClientMessage(playerid, RED, "{30D5C8}» {ffffff}Corrida esta Desativado.");
  425. if(Joined[playerid] == true) return SendClientMessage(playerid, RED, "{30D5C8}» {ffffff}Voce ja entrou no lobby.");
  426. if(EntrarSlots >= CM_MAX_PLAYERS) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Voce nao pode participar do evento Race porque esta cheio.");
  427. EntrarSlots++;
  428. format(string, sizeof(string), "{08E8DE}» {FFFFFF}Jogador {08E8DE}%s {FFFFFF}Entrou na corrida Mapas: {08E8DE}%s{FFFFFF} {09e9de}[%d/%d]", pName, RaceName, EntrarSlots, CM_MAX_PLAYERS);
  429. SendClientMessageToAll(GREEN, string);
  430. Joined[playerid] = true;
  431. return 1;
  432. }
  433.  
  434. CMD:startautorace(playerid, params[])
  435. {
  436. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "» Voce nao e uma administrador!");
  437. if(RaceBusy == 0x01 || RaceStarted == 1) return SendClientMessage(playerid, RED, "<!> Calma Corrida Ira Acabado segundo temporario evento");
  438. if(AutomaticRace == true) return SendClientMessage(playerid, RED, "<!> ja foi Ativado!");
  439. LoadRaceNames();
  440. LoadAutoRace(RaceNames[random(TotalRaces)]);
  441. AutomaticRace = true;
  442. SendClientMessage(playerid, GREEN, ">> Voce Iniciando Automaticar Aleartorio Race MP!");
  443. //if(RaceBusy == 0x00) return SendClientMessage(playerid, RED, "<!> Nao ha corrida para parar!");
  444. return 1;
  445. }
  446. CMD:stopautorace(playerid, params[])
  447. {
  448. new string[500];
  449. format(string, sizeof(string), "{08E8DE}» {FFFFFF}CORRIDA ESTA DESATIVADO!");
  450. SendClientMessageToAll(GREEN, string);
  451. if(AutomaticRace == false) //return SendClientMessage(playerid, RED, "{08E8DE}» {FFFFFF}CORRIDA ESTA DESATIVADO!");
  452. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "» Voce nao e uma administrador!!");
  453. AutomaticRace = false;
  454. if(RaceBusy == 0x00) return SendClientMessage(playerid, RED, "<!> Nao ha corrida para parar!");
  455. return 1;
  456. }
  457.  
  458. CMD:sairrace(playerid, params[])
  459. {
  460. new string[500], pName[MAX_PLAYER_NAME];
  461. GetPlayerName(playerid, pName, sizeof(pName));
  462. if(Joined[playerid] == true)
  463. {
  464. JoinCount--;
  465. Joined[playerid] = false;
  466. DestroyVehicle(CreatedRaceVeh[playerid]);
  467. DisablePlayerRaceCheckpoint(playerid);
  468. TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
  469. CPProgess[playerid] = 0;
  470. KillTimer(InfoTimer[playerid]);
  471. format(string, sizeof(string), "{08E8DE}» {FFFFFF}Jogador {08E8DE}%s {FFFFFF}Saiu na corrida", pName);
  472. SendClientMessageToAll(WHITE, string);
  473. EntrarSlots = 0;
  474. TogglePlayerControllable(playerid, true);
  475. SetCameraBehindPlayer(playerid);
  476. #if defined RACE_IN_OTHER_WORLD
  477. SetPlayerVirtualWorld(playerid, 0);
  478. #endif
  479. } else return SendClientMessage(playerid, RED, "<!> Voce nao esta em uma corrida!");
  480. return 1;
  481. }
  482.  
  483. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  484. {
  485. switch(dialogid)
  486. {
  487. case 599:
  488. {
  489. if(!response) return BuildRace = 0;
  490. switch(listitem)
  491. {
  492. case 0: BuildRaceType = 0;
  493. case 1: BuildRaceType = 3;
  494. }
  495. ShowDialog(playerid, 600);
  496. }
  497. case 600..601:
  498. {
  499. if(!response) return ShowDialog(playerid, 599);
  500. if(!strlen(inputtext)) return ShowDialog(playerid, 601);
  501. if(strlen(inputtext) < 1 || strlen(inputtext) > 20) return ShowDialog(playerid, 601);
  502. strmid(BuildName, inputtext, 0, strlen(inputtext), sizeof(BuildName));
  503. ShowDialog(playerid, 602);
  504. }
  505. case 602..603:
  506. {
  507. if(!response) return ShowDialog(playerid, 600);
  508. if(!strlen(inputtext)) return ShowDialog(playerid, 603);
  509. if(isNumeric(inputtext))
  510. {
  511.  
  512. if(!IsValidVehicle(strval(inputtext))) return ShowDialog(playerid, 603);
  513. new Float: pPos[4];
  514. GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  515. GetPlayerFacingAngle(playerid, pPos[3]);
  516. BuildModeVID = strval(inputtext);
  517. BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
  518. BuildVehicle = CreateVehicle(strval(inputtext), pPos[0], pPos[1], pPos[2], pPos[3], random(126), random(126), (60 * 60));
  519. PutPlayerInVehicle(playerid, BuildVehicle, 0);
  520. BuildCreatedVehicle = 0x01;
  521. ShowDialog(playerid, 604);
  522. }
  523. else
  524. {
  525. if(!IsValidVehicle(ReturnVehicleID(inputtext))) return ShowDialog(playerid, 603);
  526. new Float: pPos[4];
  527. GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  528. GetPlayerFacingAngle(playerid, pPos[3]);
  529. BuildModeVID = ReturnVehicleID(inputtext);
  530. BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
  531. BuildVehicle = CreateVehicle(ReturnVehicleID(inputtext), pPos[0], pPos[1], pPos[2], pPos[3], random(126), random(126), (60 * 60));
  532. PutPlayerInVehicle(playerid, BuildVehicle, 0);
  533. BuildCreatedVehicle = 0x01;
  534. ShowDialog(playerid, 604);
  535. }
  536. }
  537. case 604:
  538. {
  539. if(!response) return ShowDialog(playerid, 602);
  540. SendClientMessage(playerid, GREEN, "{ffffff}>> Va para a linha de partida na estrada a esquerda e pressione {ff2400}'/addveh' {ffffff}e faca o mesmo com o bloqueio certo.");
  541. SendClientMessage(playerid, GREEN, "{ffffff}>> Quando isso for feito, voce vera uma caixa de dialogo para continuar.");
  542. BuildVehPosCount = 0;
  543. BuildTakeVehPos = true;
  544. }
  545. case 605:
  546. {
  547. if(!response) return ShowDialog(playerid, 604);
  548. SendClientMessage(playerid, GREEN, "{ffffff}>> Comece a fazer checkpoints agora clicando {ff2400}'/addcp'");
  549. SendClientMessage(playerid, GREEN, "{ffffff}>> IMPORTANTE: Pressione {ff2400}'/endcp' {ffffff}quando voce terminar com os pontos de verificacao! Se nao reagir, pressione novamente e novamente.");
  550. BuildCheckPointCount = 0;
  551. BuildTakeCheckpoints = true;
  552. }
  553. case 606:
  554. {
  555. if(!response) return ShowDialog(playerid, 606);
  556. BuildRace = 0;
  557. BuildCheckPointCount = 0;
  558. BuildVehPosCount = 0;
  559. BuildTakeCheckpoints = false;
  560. BuildTakeVehPos = false;
  561. BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
  562. return 1;
  563. }
  564. }
  565. return 1;
  566. }
  567.  
  568. //------------------------------------------------
  569. public OnPlayerDisconnect(playerid)
  570. {
  571. new string[400], pName[MAX_PLAYER_NAME];
  572. GetPlayerName(playerid, pName, sizeof(pName));
  573. if(Joined[playerid] == true)
  574. {
  575. JoinCount--;
  576. Joined[playerid] = false;
  577. DestroyVehicle(CreatedRaceVeh[playerid]);
  578. DisablePlayerRaceCheckpoint(playerid);
  579. TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
  580. CPProgess[playerid] = 0;
  581. KillTimer(InfoTimer[playerid]);
  582. format(string, sizeof(string), "{08E8DE}» {FFFFFF}Jogador {08E8DE}%s {FFFFFF}saiu na corrida lobby.", pName);
  583. SendClientMessageToAll(-1, string);
  584. EntrarSlots = 0;
  585. #if defined RACE_IN_OTHER_WORLD
  586. SetPlayerVirtualWorld(playerid, 0);
  587. #endif
  588. }
  589. TextDrawDestroy(RaceInfo[playerid]);
  590. if(BuildRace == playerid+1) BuildRace = 0;
  591. return 1;
  592. }
  593.  
  594.  
  595. public OnPlayerConnect(playerid)
  596. {
  597. //Sistema de corrida Evento - Textdraw
  598. RaceInfo[playerid] = TextDrawCreate(13.294108, 271.666687, " ");
  599. TextDrawAlignment(RaceInfo[playerid], 1);
  600. TextDrawBackgroundColor(RaceInfo[playerid], 255);
  601. TextDrawFont(RaceInfo[playerid], 1);
  602. TextDrawLetterSize(RaceInfo[playerid], 0.449999, 1.600000);
  603. TextDrawTextSize(RaceInfo[playerid], 200.588256, 110.416664);
  604. TextDrawColor(RaceInfo[playerid], -1);
  605. TextDrawUseBox(RaceInfo[playerid], 1);
  606. TextDrawBoxColor(RaceInfo[playerid], 255);
  607. TextDrawSetOutline(RaceInfo[playerid], 0);
  608. TextDrawSetProportional(RaceInfo[playerid], 1);
  609. TextDrawSetShadow(RaceInfo[playerid], 1);
  610. return 1;
  611. }
  612.  
  613. //Corrida: veiculos de saida na porta - automático saiu lobby
  614. public OnPlayerDeath(playerid)
  615. {
  616. new string[400], pName[MAX_PLAYER_NAME];
  617. GetPlayerName(playerid, pName, sizeof(pName));
  618. if(Joined[playerid] == true)
  619. {
  620. JoinCount--;
  621. Joined[playerid] = false;
  622. DestroyVehicle(CreatedRaceVeh[playerid]);
  623. DisablePlayerRaceCheckpoint(playerid);
  624. TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
  625. CPProgess[playerid] = 0;
  626. KillTimer(InfoTimer[playerid]);
  627. format(string, sizeof(string), "{08E8DE}» {FFFFFF}Jogador {08E8DE}%s {FFFFFF}saiu na corrida lobby", pName);
  628. SendClientMessageToAll(WHITE, string);
  629. EntrarSlots = 0;
  630. #if defined RACE_IN_OTHER_WORLD
  631. SetPlayerVirtualWorld(playerid, 0);
  632. #endif
  633. }
  634. if(BuildRace == playerid+1) BuildRace = 0;
  635. return 1;
  636. }
  637.  
  638. public OnPlayerEnterRaceCheckpoint(playerid)
  639. {
  640. if(CPProgess[playerid] == TotalCP -1)
  641. {
  642. new
  643. TimeStamp,
  644. TotalRaceTime,
  645. string[256],
  646. rFile[256],
  647. pName[MAX_PLAYER_NAME],
  648. rTime[3],
  649. Prize[2],
  650. TempTotalTime,
  651. TempTime[3]
  652. ;
  653. Position++;
  654. GetPlayerName(playerid, pName, sizeof(pName));
  655. TimeStamp = GetTickCount();
  656. TotalRaceTime = TimeStamp - RaceTick;
  657. ConvertTime(var, TotalRaceTime, rTime[0], rTime[1], rTime[2]);
  658. switch(Position)
  659. {
  660. case 1: Prize[0] = (random(random(250000)) + 250000), Prize[1] = 30;
  661. case 2: Prize[0] = (random(random(10000)) + 10000), Prize[1] = 20;
  662. case 3: Prize[0] = (random(random(1000)) + 1000), Prize[1] = 10;
  663. case 4: Prize[0] = (random(random(8000)) + 8000), Prize[1] = 7;
  664. case 5: Prize[0] = (random(random(8000)) + 8000), Prize[1] = 6;
  665. case 6: Prize[0] = (random(random(8000)) + 8000), Prize[1] = 5;
  666. case 7: Prize[0] = (random(random(8000)) + 8000), Prize[1] = 4;
  667. case 8: Prize[0] = (random(random(8000)) + 8000), Prize[1] = 3;
  668. case 9: Prize[0] = (random(random(8000)) + 8000), Prize[1] = 2;
  669. case 10: Prize[0] = (random(random(8000)) + 8000), Prize[1] = 1;
  670. default: Prize[0] = random(random(50000)), Prize[1] = 0;
  671. }
  672. new GranaExp = random(100000);// < Dinheiro Aleatorio
  673. GivePlayerMoney(playerid, GranaExp);
  674. format(string, sizeof(string), "{08E8DE}» {FFFFFF}Jogador {08E8DE}%s {FFFFFF}tomar um {08E8DE}%d {FFFFFF}lugar.", pName, Position);
  675. SetPlayerVirtualWorld(playerid, 0);
  676. EntrarSlots = 0;
  677. //SetPlayerPos(playerid, 1753.7681,-1894.2273,13.5571);
  678. SendClientMessageToAll(WHITE, string);
  679.  
  680. if(FinishCount <= 10)
  681. {
  682. format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", RaceName);
  683. format(string, sizeof(string), "BestRacerTime_%d", TimeProgress);
  684. TempTotalTime = dini_Int(rFile, string);
  685. ConvertTime(var1, TempTotalTime, TempTime[0], TempTime[1], TempTime[2]);
  686. if(TotalRaceTime <= dini_Int(rFile, string) || TempTotalTime == 0)
  687. {
  688. dini_IntSet(rFile, string, TotalRaceTime);
  689. format(string, sizeof(string), "BestRacer_%d", TimeProgress);
  690. format(string, sizeof(string), "BestRacer_%d", TimeProgress);
  691. dini_Set(rFile, string, pName);
  692. TimeProgress++;
  693. }
  694. }
  695. FinishCount++;
  696. //GivePlayerMoney(playerid, Prize[0]);
  697. SetPlayerScore(playerid, GetPlayerScore(playerid) + Prize[1]);
  698. DisablePlayerRaceCheckpoint(playerid);
  699. TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
  700. CPProgess[playerid]++;
  701. if(FinishCount >= JoinCount) return StopRace();
  702. }
  703. else
  704. {
  705. CPProgess[playerid]++;
  706. CPCoords[CPProgess[playerid]][3]++;
  707. RacePosition[playerid] = floatround(CPCoords[CPProgess[playerid]][3], floatround_floor);
  708. SetCP(playerid, CPProgess[playerid], CPProgess[playerid]+1, TotalCP, RaceType);
  709. PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);
  710. }
  711. return 1;
  712. }
  713.  
  714. CMD:addveh(playerid, params[])
  715. {
  716. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "» Voce nao e uma administrador!!");
  717.  
  718. new string[256], rFile[256], Float: vPos[4];
  719.  
  720. if(BuildRace == playerid+1)
  721. {
  722. if(BuildTakeVehPos == true)
  723. {
  724. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, ">> Voce precisa estar em um veiculo");
  725. format(rFile, sizeof(rFile), "rRaceSystem/%s.RRACE", BuildName);
  726. GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
  727. GetVehicleZAngle(GetPlayerVehicleID(playerid), vPos[3]);
  728. dini_Create(rFile);
  729. dini_IntSet(rFile, "vModel", BuildModeVID);
  730. dini_IntSet(rFile, "rType", BuildRaceType);
  731. format(string, sizeof(string), "vPosX_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[0]);
  732. format(string, sizeof(string), "vPosY_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[1]);
  733. format(string, sizeof(string), "vPosZ_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[2]);
  734. format(string, sizeof(string), "vAngle_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[3]);
  735. format(string, sizeof(string), ">>Posicionar veiculos '%d' Adicionar linha de veiculos", BuildVehPosCount+1);
  736. SendClientMessage(playerid, YELLOW, string);
  737. BuildVehPosCount++;
  738. }
  739. if(BuildVehPosCount >= 2)
  740. {
  741. BuildVehPosCount = 0;
  742. BuildTakeVehPos = false;
  743. ShowDialog(playerid, 605);
  744. }
  745. }
  746. return 1;
  747. }
  748.  
  749. CMD:addcp(playerid, params[])
  750. {
  751. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "» Voce nao e uma administrador!!");
  752.  
  753. new string[256], rFile[256], Float: vPos[4];
  754.  
  755. if(BuildTakeCheckpoints == true)
  756. {
  757. if(BuildCheckPointCount > MAX_RACE_CHECKPOINTS_EACH_RACE) return SendClientMessage(playerid, RED, ">> Voce atingiu a quantidade maxima de ckeckpoint!");
  758. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, ">> Voce precisa estar em um veiculo");
  759. format(rFile, sizeof(rFile), "rRaceSystem/%s.RRACE", BuildName);
  760. GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
  761. format(string, sizeof(string), "CP_%d_PosX", BuildCheckPointCount), dini_FloatSet(rFile, string, vPos[0]);
  762. format(string, sizeof(string), "CP_%d_PosY", BuildCheckPointCount), dini_FloatSet(rFile, string, vPos[1]);
  763. format(string, sizeof(string), "CP_%d_PosZ", BuildCheckPointCount), dini_FloatSet(rFile, string, vPos[2]);
  764. format(string, sizeof(string), ">> Adicionar ckeckpoint '%d' hora de inicio!", BuildCheckPointCount+1);
  765. SendClientMessage(playerid, YELLOW, string);
  766. BuildCheckPointCount++;
  767. }
  768. return 1;
  769. }
  770.  
  771. CMD:endcp(playerid, params[])
  772. {
  773. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "» Voce nao e uma administrador!!");
  774. new string[256], rNameFile[256], rFile[256];
  775.  
  776. if(BuildTakeCheckpoints == true)
  777. {
  778. ShowDialog(playerid, 606);
  779. format(rNameFile, sizeof(rNameFile), "rRaceSystem/RaceNames/RaceNames.txt");
  780. TotalRaces = dini_Int(rNameFile, "TotalRaces");
  781. TotalRaces++;
  782. dini_IntSet(rNameFile, "TotalRaces", TotalRaces);
  783. format(string, sizeof(string), "Race_%d", TotalRaces-1);
  784. format(rFile, sizeof(rFile), "rRaceSystem/%s.RRACE", BuildName);
  785. dini_Set(rNameFile, string, BuildName);
  786. dini_IntSet(rFile, "TotalCP", BuildCheckPointCount);
  787. Loop(x, 10)
  788. {
  789. format(string, sizeof(string), "BestRacerTime_%d", x);
  790. dini_Set(rFile, string, "0");
  791. format(string, sizeof(string), "BestRacer_%d", x);
  792. dini_Set(rFile, string, "noone");
  793. }
  794. }
  795. return 1;
  796. }
  797.  
  798. function LoadRaceNames()
  799. {
  800. new
  801. rNameFile[64],
  802. string[64]
  803. ;
  804. format(rNameFile, sizeof(rNameFile), "/rRaceSystem/RaceNames/RaceNames.txt");
  805. TotalRaces = dini_Int(rNameFile, "TotalRaces");
  806. Loop(x, TotalRaces)
  807. {
  808. format(string, sizeof(string), "Race_%d", x), strmid(RaceNames[x], dini_Get(rNameFile, string), 0, 20, sizeof(RaceNames));
  809. //printf(">> Loaded Races: %s", RaceNames[x]);
  810. }
  811. return 1;
  812. }
  813.  
  814. function LoadAutoRace(rName[])
  815. {
  816. new
  817. rFile[256],
  818. string[256]
  819. ;
  820. format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", rName);
  821. strmid(RaceName, rName, 0, strlen(rName), sizeof(RaceName));
  822. RaceVehicle = dini_Int(rFile, "vModel");
  823. RaceType = dini_Int(rFile, "rType");
  824. TotalCP = dini_Int(rFile, "TotalCP");
  825.  
  826. #if DEBUG_RACE == 1
  827. //printf("VehicleModel: %d", RaceVehicle);
  828. //printf("RaceType: %d", RaceType);
  829. // printf("TotalCheckpoints: %d", TotalCP);
  830. #endif
  831.  
  832. Loop(x, 2)
  833. {
  834. format(string, sizeof(string), "vPosX_%d", x), RaceVehCoords[x][0] = dini_Float(rFile, string);
  835. format(string, sizeof(string), "vPosY_%d", x), RaceVehCoords[x][1] = dini_Float(rFile, string);
  836. format(string, sizeof(string), "vPosZ_%d", x), RaceVehCoords[x][2] = dini_Float(rFile, string);
  837. format(string, sizeof(string), "vAngle_%d", x), RaceVehCoords[x][3] = dini_Float(rFile, string);
  838. #if DEBUG_RACE == 1
  839. //printf("VehiclePos %d: %f, %f, %f, %f", x, RaceVehCoords[x][0], RaceVehCoords[x][1], RaceVehCoords[x][2], RaceVehCoords[x][3]);
  840. #endif
  841. }
  842. Loop(x, TotalCP)
  843. {
  844. format(string, sizeof(string), "CP_%d_PosX", x), CPCoords[x][0] = dini_Float(rFile, string);
  845. format(string, sizeof(string), "CP_%d_PosY", x), CPCoords[x][1] = dini_Float(rFile, string);
  846. format(string, sizeof(string), "CP_%d_PosZ", x), CPCoords[x][2] = dini_Float(rFile, string);
  847. #if DEBUG_RACE == 1
  848. // printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
  849. #endif
  850. }
  851. Position = 0;
  852. FinishCount = 0;
  853. JoinCount = 0;
  854. Loop(x, 2) PlayersCount[x] = 0;
  855. CountAmount = COUNT_DOWN_TILL_RACE_START;
  856. RaceTime = MAX_RACE_TIME;
  857. RaceBusy = 0x01;
  858. CountTimer = SetTimer("CountTillRace", 999, 1);
  859. TimeProgress = 0;
  860. return 1;
  861. }
  862.  
  863. function LoadRace(playerid, rName[])
  864. {
  865. new
  866. rFile[256],
  867. string[256]
  868. ;
  869. format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", rName);
  870. if(!dini_Exists(rFile)) return SendClientMessage(playerid, RED, "<!> Race doesn't exist!"), printf("Race \"%s\" doesn't exist!", rName);
  871. strmid(RaceName, rName, 0, strlen(rName), sizeof(RaceName));
  872. RaceVehicle = dini_Int(rFile, "vModel");
  873. RaceType = dini_Int(rFile, "rType");
  874. TotalCP = dini_Int(rFile, "TotalCP");
  875.  
  876. #if DEBUG_RACE == 1
  877. // printf("VehicleModel: %d", RaceVehicle);
  878. // printf("RaceType: %d", RaceType);
  879. // printf("TotalCheckpoints: %d", TotalCP);
  880. #endif
  881.  
  882. Loop(x, 2)
  883. {
  884. format(string, sizeof(string), "vPosX_%d", x), RaceVehCoords[x][0] = dini_Float(rFile, string);
  885. format(string, sizeof(string), "vPosY_%d", x), RaceVehCoords[x][1] = dini_Float(rFile, string);
  886. format(string, sizeof(string), "vPosZ_%d", x), RaceVehCoords[x][2] = dini_Float(rFile, string);
  887. format(string, sizeof(string), "vAngle_%d", x), RaceVehCoords[x][3] = dini_Float(rFile, string);
  888. #if DEBUG_RACE == 1
  889. //printf("VehiclePos %d: %f, %f, %f, %f", x, RaceVehCoords[x][0], RaceVehCoords[x][1], RaceVehCoords[x][2], RaceVehCoords[x][3]);
  890. #endif
  891. }
  892. Loop(x, TotalCP)
  893. {
  894. format(string, sizeof(string), "CP_%d_PosX", x), CPCoords[x][0] = dini_Float(rFile, string);
  895. format(string, sizeof(string), "CP_%d_PosY", x), CPCoords[x][1] = dini_Float(rFile, string);
  896. format(string, sizeof(string), "CP_%d_PosZ", x), CPCoords[x][2] = dini_Float(rFile, string);
  897. #if DEBUG_RACE == 1
  898. // printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
  899. #endif
  900. }
  901. Position = 0;
  902. FinishCount = 0;
  903. JoinCount = 0;
  904. Loop(x, 2) PlayersCount[x] = 0;
  905. Joined[playerid] = true;
  906. CountAmount = COUNT_DOWN_TILL_RACE_START;
  907. RaceTime = MAX_RACE_TIME;
  908. RaceBusy = 0x01;
  909. TimeProgress = 0;
  910. SetupRaceForPlayer(playerid);
  911. CountTimer = SetTimer("CountTillRace", 999, 1);
  912. return 1;
  913. }
  914.  
  915. function SetCP(playerid, PrevCP, NextCP, MaxCP, Type)
  916. {
  917. if(Type == 0)
  918. {
  919. if(NextCP == MaxCP) SetPlayerRaceCheckpoint(playerid, 1, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
  920. else SetPlayerRaceCheckpoint(playerid, 0, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
  921. }
  922. else if(Type == 3)
  923. {
  924. if(NextCP == MaxCP) SetPlayerRaceCheckpoint(playerid, 4, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
  925. else SetPlayerRaceCheckpoint(playerid, 3, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
  926. }
  927. return 1;
  928. }
  929.  
  930. function SetupRaceForPlayer(playerid)
  931. {
  932. CPProgess[playerid] = 0;
  933. CPCoords[playerid][3] = 0;
  934. SetCP(playerid, CPProgess[playerid], CPProgess[playerid]+1, TotalCP, RaceType);
  935. if(IsOdd(playerid)) Index = 1;
  936. else Index = 0;
  937.  
  938. switch(Index)
  939. {
  940. case 0:
  941. {
  942. if(PlayersCount[0] == 1)
  943. {
  944. RaceVehCoords[0][0] -= (6 * floatsin(-RaceVehCoords[0][3], degrees));
  945. RaceVehCoords[0][1] -= (6 * floatcos(-RaceVehCoords[0][3], degrees));
  946. CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2, RaceVehCoords[0][3], random(126), random(126), (60 * 60));
  947. SetPlayerPos(playerid, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2);
  948. SetPlayerFacingAngle(playerid, RaceVehCoords[0][3]);
  949. PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
  950. }
  951. }
  952. case 1:
  953. {
  954. if(PlayersCount[1] == 1)
  955. {
  956. RaceVehCoords[1][0] -= (6 * floatsin(-RaceVehCoords[1][3], degrees));
  957. RaceVehCoords[1][1] -= (6 * floatcos(-RaceVehCoords[1][3], degrees));
  958. CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2, RaceVehCoords[1][3], random(126), random(126), (60 * 60));
  959. SetPlayerPos(playerid, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2);
  960. SetPlayerFacingAngle(playerid, RaceVehCoords[1][3]);
  961. PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
  962. }
  963. }
  964. }
  965. switch(Index)
  966. {
  967. case 0:
  968. {
  969. if(PlayersCount[0] != 1)
  970. {
  971. CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2, RaceVehCoords[0][3], random(126), random(126), (60 * 60));
  972. SetPlayerPos(playerid, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2);
  973. SetPlayerFacingAngle(playerid, RaceVehCoords[0][3]);
  974. PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
  975. PlayersCount[0] = 1;
  976. }
  977. }
  978. case 1:
  979. {
  980. if(PlayersCount[1] != 1)
  981. {
  982. CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2, RaceVehCoords[1][3], random(126), random(126), (60 * 60));
  983. SetPlayerPos(playerid, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2);
  984. SetPlayerFacingAngle(playerid, RaceVehCoords[1][3]);
  985. PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
  986. PlayersCount[1] = 1;
  987. }
  988. }
  989. }
  990. new
  991. string[128]
  992. ;
  993. #if defined RACE_IN_OTHER_WORLD
  994. SetPlayerVirtualWorld(playerid, 10);
  995. #endif
  996. InfoTimer[playerid] = SetTimerEx("TextInfo", 500, 1, "e", playerid);
  997. if(JoinCount == 1) format(string, sizeof(string), "~b~Tempo_de_Corrida: ~r~%s ", TimeConvert(RaceTime));
  998. else format(string, sizeof(string), "~b~Tempo_de_Corrida: ~r~%s ", TimeConvert(RaceTime), JoinCount);
  999. TextDrawSetString(RaceInfo[playerid], string);
  1000. TextDrawShowForPlayer(playerid, RaceInfo[playerid]);
  1001. JoinCount++;
  1002. return 1;
  1003. }
  1004.  
  1005. function CountTillRace(playerid)
  1006. {
  1007. switch(CountAmount)
  1008. {
  1009. case 0:
  1010. {
  1011. ForEach(i, MAX_PLAYERS)
  1012. {
  1013. if(Joined[i] == false)
  1014. {
  1015.  
  1016. }
  1017. }
  1018. StartRace(playerid);
  1019. }
  1020. case 1..30:
  1021. {
  1022. new
  1023. string[900]
  1024. ;
  1025. format(string, sizeof(string), "~b~AGUARDE CONTAGEM VOLTAR SEGUNDO: ~r~%d", CountAmount);
  1026. ForEach(i, MAX_PLAYERS)
  1027. {
  1028. if(Joined[i] == true)
  1029. {
  1030. GameTextForPlayer(i, string, 1000, 5);
  1031. PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
  1032. }
  1033. }
  1034. }
  1035. case 90, 80, 70, 60, 50, 40, 31, 200, 100:
  1036. {
  1037. new
  1038. string[300]
  1039. ;
  1040. new GranaExp = random(100000);// < Dinheiro Aleatorio
  1041. printf("> Mapas: %s (Corrida) Preco: %i$ /entermp. ", RaceName, GranaExp);
  1042. format(string, sizeof(string), "{08E8DE}» {FFFFFF}Mapas: {08E8DE}%s{FFFFFF}({08E8DE}Corrida{FFFFFF}) {FFFFFF}Preco: {08E8DE}%i$ /entermp. ", RaceName, GranaExp);
  1043. SendClientMessageToAll(GREEN, string);
  1044. EntrarSlots = 0;
  1045. }
  1046. }
  1047. return CountAmount--;
  1048. }
  1049.  
  1050. function StartRace(playerid)
  1051. {
  1052. new string[200];
  1053. ForEach(i, MAX_PLAYERS)
  1054. {
  1055. if(Joined[i] == true)
  1056. {
  1057. IsPlayerInAnyVehicle(i);
  1058. SetupRaceForPlayer(i);
  1059. SetVehicleVirtualWorld(GetPlayerVehicleID(i), 1);
  1060. SetPlayerVirtualWorld(i, 1);
  1061. for(i=0; i<30; i++)
  1062. {
  1063. SendClientMessage(playerid,-1," ");
  1064. }
  1065. format(string, sizeof(string), "~g~GO GO GO");
  1066. GameTextForPlayer(i, string, 5000, 1);
  1067. PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
  1068. }
  1069. }
  1070. rCounter = SetTimer("RaceCounter", 900, 1);
  1071. RaceTick = GetTickCount();
  1072. RaceStarted = 1;
  1073. KillTimer(CountTimer);
  1074. return 1;
  1075. }
  1076.  
  1077. function StopRace()
  1078. {
  1079. KillTimer(rCounter);
  1080. RaceStarted = 0;
  1081. RaceTick = 0;
  1082. RaceBusy = 0x00;
  1083. JoinCount = 0;
  1084. FinishCount = 0;
  1085. TimeProgress = 0;
  1086.  
  1087. ForEach(i, MAX_PLAYERS)
  1088. {
  1089. if(Joined[i] == true)
  1090. {
  1091. DisablePlayerRaceCheckpoint(i);
  1092. DestroyVehicle(CreatedRaceVeh[i]);
  1093. Joined[i] = false;
  1094. TextDrawHideForPlayer(i, RaceInfo[i]);
  1095. CPProgess[i] = 0;
  1096. KillTimer(InfoTimer[i]);
  1097. }
  1098. }
  1099. if(AutomaticRace == true) LoadRaceNames(), LoadAutoRace(RaceNames[random(TotalRaces)]);
  1100. return 1;
  1101. }
  1102.  
  1103. function RaceCounter()
  1104. {
  1105. if(RaceStarted == 1)
  1106. {
  1107. RaceTime--;
  1108. if(JoinCount <= 0)
  1109. {
  1110. StopRace();
  1111. }
  1112. }
  1113. if(RaceTime <= 0)
  1114. {
  1115. StopRace();
  1116. }
  1117. return 1;
  1118. }
  1119.  
  1120. function TextInfo(playerid)
  1121. {
  1122. new
  1123. string[128]
  1124. ;
  1125. if(JoinCount == 1) format(string, sizeof(string), "~b~Tempo_de_Corrida: ~r~%s", TimeConvert(RaceTime));
  1126. else format(string, sizeof(string), "~b~Tempo_de_Corrida: ~r~%s", TimeConvert(RaceTime), JoinCount);
  1127. TextDrawSetString(RaceInfo[playerid], string);
  1128. TextDrawShowForPlayer(playerid, RaceInfo[playerid]);
  1129. }
  1130.  
  1131. function IsPlayerInRace(playerid)
  1132. {
  1133. if(Joined[playerid] == true) return true;
  1134. else return false;
  1135. }
  1136.  
  1137. function ShowDialog(playerid, dialogid)
  1138. {
  1139. switch(dialogid)
  1140. {
  1141. case 599: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, CreateCaption("Construir uma nova corrida "), "\
  1142. Normal Corrida\n\
  1143. Aviao Corrida", "Proxima", "Sair");
  1144.  
  1145. case 600: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Construir uma nova corrida (Passo 1/4)"), "\
  1146. Passo 1:\n\
  1147. ********\n\
  1148. Bem vindo ao race 'Construir uma nova corrida'.\n\
  1149. Antes de comecar, preciso saber o nome (e.g. Corrida#1) do para salva-lo sob.\n\n\
  1150. >> De o NOME abaixo e pressione 'Proxima' Continuar.", "Proxima", "Voltar");
  1151.  
  1152. case 601: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Construir uma nova corrida (Passo 1/4)"), "\
  1153. ERRO: Nome muito curto ou muito longo! (min. 1 - max. 20)\n\n\n\
  1154. Passo 1:\n\
  1155. ********\n\
  1156. Bem vindo ao race 'Construir uma nova corrida'.\n\
  1157. Antes de comecar, preciso saber o nome (e.g. Corrida#1) do para salva-lo sob.\n\n\
  1158. >> De o NOME abaixo e pressione 'Proxima' continuar.", "Proxima", "Voltar");
  1159.  
  1160. case 602: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Construir uma nova corrida (Passo 2/4)"), "\
  1161. Passo 2:\n\
  1162. ********\n\
  1163. Por favor, forneca o ID ou NOME do veiculo que sera usado na corrida que Voce Esta criando agora.\n\n\
  1164. >> Forneca a ID ou NOME do veiculo abaixo e pressione 'Proxima' Continuar. 'Voltar' mudar algo.", "Proxima", "Voltar");
  1165.  
  1166. case 603: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Construir uma nova corrida (Step 2/4)"), "\
  1167. ERRO: Veiculo Invalido ID/Nome\n\n\n\
  1168. Passo 2:\n\
  1169. ********\n\
  1170. Por favor, forneca o ID ou NOME do veiculo que sera usado na corrida que Voce Esta criando agora.\n\n\
  1171. >> Forneca a ID ou NOME do veiculo abaixo e pressione 'Proxima' Continuar. 'Voltar' mudar algo.", "Proxima", "Voltar");
  1172.  
  1173. case 604: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Construir uma nova corrida (Step 3/4)"),
  1174. "\
  1175. Passo 3:\n\
  1176. ********\n\
  1177. {ffffff}Estamos quase terminando! Agora va para a linha de partida, onde o primeiro e o segundo carro devem estar.\n\
  1178. Nota: Quando Voce clica 'OK' Voce estara livre. Usar {ff2400}'/ADDVEH' {ffffff}para definir a primeira posicao e a segunda posicao.\n\
  1179. Nota: Depois de obter essas posicoes, Voce vera automaticamente uma caixa de dialogo para continuar o assistente.\n\n\
  1180. >> pressione 'OK' para fazer as coisas acima. 'Voltar' mudar algo.", "OK", "Voltar");
  1181.  
  1182. case 605: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Construir uma nova corrida (Step 4/4)"),
  1183. "\
  1184. Passo 4:\n\
  1185. ********\n\
  1186. {ffffff}Bem-vindo a ultima etapa. Nesta etapa, Voce deve definir os pontos de verificacao; entao se Voce clicar 'OK' Voce pode definir os pontos de verificacao.\n\
  1187. Voce pode definir os pontos de verificacao com {ff2400}'/ADDCP'. {ffffff}Cada checkpoint que Voce definir ira salvar.\n\
  1188. Voce tem que digite {ff2400}/ENDCP{ffffff} quando Voce terminar com tudo. Sua corrida Esta disponivel entao!\n\n\
  1189. >> pressione 'OK' para fazer as coisas acima. 'Voltar' mudar algo.", "OK", "Voltar");
  1190.  
  1191. case 606: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Construir uma nova corrida (Complete)"),
  1192. "\
  1193. Voce criou sua corrida e ela Esta pronta para ser usada agora.\n\n\
  1194. >> pressione 'Terminar' para terminar. 'Sair' - Nao tem efeito.", "Terminar", "Sair");
  1195. }
  1196. return 1;
  1197. }
  1198.  
  1199. CreateCaption(arguments[])
  1200. {
  1201. new
  1202. string[128 char]
  1203. ;
  1204. format(string, sizeof(string), "Race System - %s", arguments);
  1205. return string;
  1206. }
  1207.  
  1208. stock IsValidVehicle(vehicleid)
  1209. {
  1210. if(vehicleid < 400 || vehicleid > 611) return false;
  1211. else return true;
  1212. }
  1213.  
  1214. ReturnVehicleID(vName[])
  1215. {
  1216. Loop(x, 211)
  1217. {
  1218. if(strfind(vNames[x], vName, true) != -1)
  1219. return x + 400;
  1220. }
  1221. return -1;
  1222. }
  1223. // ~~~~~~~~~~~~~ Verificamos se é numero ~~~~~~~~~~~~~
  1224. stock IsNumeric(const string[]) {
  1225. for (new i = 0, j = strlen(string); i < j; i++)
  1226. {
  1227. if (string[i] > '9' || string[i] < '0') return 0;
  1228. }
  1229. return 1;
  1230. }
  1231. TimeConvert(seconds)
  1232. {
  1233. new tmp[16];
  1234. new minutes = floatround(seconds/60);
  1235. seconds -= minutes*60;
  1236. format(tmp, sizeof(tmp), "%d:%02d", minutes, seconds);
  1237. return tmp;
  1238. }
  1239.  
Add Comment
Please, Sign In to add comment