Chip7

[FS] FilterScript Sistema de Corrida PT/BR

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