Advertisement
Guest User

Sistema de Concessionária 2.0 - Rodrigo_LosT

a guest
Oct 30th, 2015
1,651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 50.33 KB | None | 0 0
  1. ========================================================================
  2. ================================================================================
  3. ===========================[ Sistema de Concessionária ]========================
  4. ================================[ By Rodrigo_LosT]==============================
  5. ========================[ Por favor, mantenha os créditos ]=====================
  6. ================================================================================
  7. ==============================================================================*/
  8.  
  9. #define FILTERSCRIPT
  10. #include <a_samp>
  11. #include <DOF2>
  12.  
  13. #define AzulLindo 0x3FCFFFFF
  14. #define Azul 0x33CCFFAA
  15. #define Branco 0xFFFFFFAA
  16.  
  17. //Nome dos Carros
  18. new vehName[][] ={
  19. "Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster",
  20. "Limosine","Manana","Infernus","Voodoo","Pony","Mule","Cheetah","Ambulancia","Leviathan","Moonbeam","Esperanto",
  21. "Taxi","Washington","Bobcat","Mr Whoopee","BF Injection","Hunter","Premier","Enforcer","Securicar","Banshee",
  22. "Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie","Stallion","Rumpo",
  23. "RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer",
  24. "Turismo","Speeder","Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van","Skimmer",
  25. "PCJ-600","Faggio","Freeway","RC Baron","RC Raider","Glendale","Oceanic","Sanchez","Sparrow","Patriot",
  26. "Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR-350","Walton","Regina","Comet","BMX",
  27. "Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo",
  28. "Greenwood","Jetmax","Hotring","Sandking","Blista Compact","Maverick Policial","Boxville","Benson","Mesa",
  29. "RC Goblin","Hotring Racer A","Hotring Racer B","Bloodring Banger","Rancher","Super GT","Elegant",
  30. "Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain","Nebula","Majestic",
  31. "Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona",
  32. "FBI Truck","Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight",
  33. "Streak","Vortex","Vincent","Bullet","Clover","Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob",
  34. "Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster A","Monster B","Uranus",
  35. "Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight",
  36. "Trailer","Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford",
  37. "BF-400","Newsvan","Tug","Trailer A","Emperor","Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C",
  38. "Andromada","Dodo","RC Cam","Launch","Viatura (LSPD)","Viatura (SFPD)","Viatura (LVPD)","Police Ranger",
  39. "Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B",
  40. "Stair Trailer","Boxville","Farm Plow","Utility Trailer" };
  41.  
  42. //===[ Sistema PART 1 ]===
  43. #define MAX_cCARROS 51 // 1 a mais do máximo de carros (Máximo = 50)
  44. #define MAX_DIGITOS 4 //Máximo de digitos (+ 1) personalizados na placa (Máximo = 3)
  45. forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
  46. forward CarregarCarros();
  47. forward CarregarCarro(cCarroid);
  48. SalvarCarro(cCarroid);
  49. forward ComprarCarro(playerid);
  50. forward FuncaocCarro(playerid);
  51. forward CarroVida(playerid);
  52. PrecoCarro(playerid, modelo);
  53. forward DiniCarro(playerid);
  54. verificarPreco(modelo);
  55. verificarModelo(modelo);
  56. new CarroVidaTimer;
  57. enum cInfo
  58. {
  59.     cDono[MAX_PLAYER_NAME],
  60.     cModelo,
  61.     Float:cSpawnX,
  62.     Float:cSpawnY,
  63.     Float:cSpawnZ,
  64.     Float:cAngulo,
  65.     cCarroON,
  66.     cCorUm,
  67.     cCorDois,
  68.     cChave[MAX_cCARROS],
  69.     cCID,
  70.     cPlaca[MAX_DIGITOS]
  71. };
  72. new Carro[MAX_cCARROS][cInfo];
  73. new cCarro[MAX_cCARROS];
  74. //new cCarr[MAX_cCARROS];
  75. new TaNoCarro[MAX_PLAYERS];
  76. new ModeloCarro[MAX_PLAYERS];
  77. new Text3D:texto3DCarro[MAX_cCARROS];
  78. //------------------------------------------------------------------------------
  79. //===[ Sistema PART 2 ]===
  80. forward CarregarDono(playerid);
  81. forward SalvarDono(playerid);
  82. enum dInfo
  83. {
  84.     dChave,
  85.     dDono[MAX_PLAYER_NAME],
  86.     dModelo
  87. };
  88. new Dono[MAX_PLAYERS][dInfo];
  89.  
  90. #define MAX_TIPOSCARROS 69 //Total de modelos
  91. //Preços
  92. #define PRECO_Bravura 35000
  93. #define PRECO_Buffalo 45000
  94. #define PRECO_Perenniel 35000
  95. #define PRECO_Sentinel 35000
  96. #define PRECO_Limosine 60000
  97. #define PRECO_Manana 35000
  98. #define PRECO_Voodoo 40000
  99. #define PRECO_Cheetah 45000
  100. #define PRECO_Moonbeam 35000
  101. #define PRECO_Esperanto 35000
  102. #define PRECO_Washington 35000
  103. #define PRECO_Premier 35000
  104. #define PRECO_Banshee 50000
  105. #define PRECO_Hotknife 50000
  106. #define PRECO_Previon 35000
  107. #define PRECO_Stallion 35000
  108. #define PRECO_Romero 35000
  109. #define PRECO_Admiral 35000
  110. #define PRECO_Turismo 50000
  111. #define PRECO_Solair 35000
  112. #define PRECO_Glendale 35000
  113. #define PRECO_Oceanic 35000
  114. #define PRECO_Hermes 35000
  115. #define PRECO_Sabre 35000
  116. #define PRECO_ZR350 45000
  117. #define PRECO_Regina 35000
  118. #define PRECO_Comet 40000
  119. #define PRECO_Camper 35000
  120. #define PRECO_Virgo 35000
  121. #define PRECO_Greenwood 40000
  122. #define PRECO_BlistaCompact 35000
  123. #define PRECO_SuperGT 45000
  124. #define PRECO_Elegant 35000
  125. #define PRECO_Nebula 35000
  126. #define PRECO_Majestic 35000
  127. #define PRECO_Buccaneer 35000
  128. #define PRECO_Fortune 35000
  129. #define PRECO_Cadrona 35000
  130. #define PRECO_Willard 35000
  131. #define PRECO_Feltzer 35000
  132. #define PRECO_Remington 35000
  133. #define PRECO_Slamvan 35000
  134. #define PRECO_Blade 35000
  135. #define PRECO_Vincent 35000
  136. #define PRECO_Bullet 50000
  137. #define PRECO_Clover 35000
  138. #define PRECO_Hustler 35000
  139. #define PRECO_Intruder 35000
  140. #define PRECO_Primo 35000
  141. #define PRECO_Tampa 35000
  142. #define PRECO_Sunrise 35000
  143. #define PRECO_Merit 35000
  144. #define PRECO_Windsor 35000
  145. #define PRECO_Uranus 45000
  146. #define PRECO_Jester 40000
  147. #define PRECO_Sultan 45000
  148. #define PRECO_Stratum 35000
  149. #define PRECO_Elegy 45000
  150. #define PRECO_Flash 35000
  151. #define PRECO_Tahoma 35000
  152. #define PRECO_Savanna 40000
  153. #define PRECO_Broadway 35000
  154. #define PRECO_Tornado 35000
  155. #define PRECO_Stafford 35000
  156. #define PRECO_Emperor 35000
  157. #define PRECO_Euros 45000
  158. #define PRECO_Club 35000
  159. #define PRECO_Alpha 40000
  160. #define PRECO_Phoenix 45000
  161.  
  162. //------------------------------------------------------------------------------
  163.  
  164. strtok(const string[], &index)
  165. {
  166.     new length = strlen(string);
  167.     while ((index < length) && (string[index] <= ' '))
  168.     {
  169.         index++;
  170.     }
  171.  
  172.     new offset = index;
  173.     new result[20];
  174.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  175.     {
  176.         result[index - offset] = string[index];
  177.         index++;
  178.     }
  179.     result[index - offset] = EOS;
  180.     return result;
  181. }
  182.  
  183. public CarroVida(playerid)
  184. {
  185.     new Float:Vida;
  186.     new VID = GetPlayerVehicleID(playerid);
  187.     GetVehicleHealth(VID, Vida);
  188.     if(Vida < 244)
  189.     {
  190.         new car = TaNoCarro[playerid];
  191.         if(car > 0)
  192.         {
  193.             Delete3DTextLabel(texto3DCarro[car]);
  194.             DestroyVehicle(cCarro[car]);
  195.             SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Seu carro foi destruído... Lamentamos, sem re-imbolso.");
  196.             TaNoCarro[playerid] = 0;
  197.             format(Carro[car][cDono], MAX_PLAYER_NAME, "Ninguem");
  198.             KillTimer(CarroVidaTimer);
  199.             return 1;
  200.         }
  201.     }
  202.     return 0;
  203. }
  204.  
  205. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  206. {
  207.     for(new c = 0; c < MAX_cCARROS; c++)
  208.     {
  209.         if(Carro[c][cCID] == vehicleid)
  210.         {
  211.             new string[256];
  212.             format(string, sizeof(string), "[CONCESSIONÁRIA] Este(a) %s pertence à %s.", vehName[GetVehicleModel(vehicleid)-400], Carro[c][cDono]);
  213.             SendClientMessage(playerid, Branco, " ");
  214.             SendClientMessage(playerid, Azul, string);
  215.         }
  216.     }
  217.     return 1;
  218. }
  219.  
  220. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  221. {
  222.     new PlayerNick[MAX_PLAYER_NAME];
  223.     GetPlayerName(playerid,PlayerNick,sizeof(PlayerNick));
  224.     new arquivo[256];
  225.     format(arquivo, sizeof(arquivo), "/Concessionaria/Donos/%s.ini",PlayerNick);
  226.     if(dialogid == 1319)
  227.     {
  228.         if(response == 1)
  229.         {
  230.                 if(listitem == 0)
  231.                 {
  232.                     if(DOF2_FileExists(arquivo))
  233.                     {
  234.                         CarregarDono(playerid);
  235.                         new carro = Dono[playerid][dModelo];
  236.                         new string[256];
  237.                         format(string, sizeof(string), "Tem certeza que deseja vender seu carro?\nVocê receberá $%d", (verificarPreco(carro)/2));
  238.                         ShowPlayerDialog(playerid,1320,DIALOG_STYLE_MSGBOX,"Concessionária",string,"Sim","Não");
  239.                     }
  240.                     else
  241.                     {
  242.                         SendClientMessage(playerid, Branco, "[CONCESSIONÁRIA] Você não tem um carro!");
  243.                     }
  244.                 }
  245.                 if(listitem == 1)
  246.                 {
  247.                     new textdialog[3000];
  248.                     new string[MAX_TIPOSCARROS][256];
  249.                     for(new c = 0; c < MAX_TIPOSCARROS; c++)
  250.                     {
  251.                         format(string[c], sizeof(string), "%s, $%d\n", vehName[verificarModelo(c)-400] ,verificarPreco(verificarModelo(c)));
  252.                         strins(textdialog, string[c], strlen(textdialog));
  253.                     }
  254.                     ShowPlayerDialog(playerid,1321,DIALOG_STYLE_LIST,"Qual carro você deseja comprar?",textdialog,"Selecionar","Cancelar");
  255.                 }
  256.         }
  257.         else
  258.         {
  259.             //Tudo que vai acontecer no botão direito.
  260.         }
  261.     }
  262.     if(dialogid == 1320)
  263.     {
  264.         if(response == 1)
  265.         {
  266.             if(DOF2_FileExists(arquivo))
  267.             {
  268.                 new carro = Dono[playerid][dChave];
  269.                 GivePlayerMoney(playerid, (verificarPreco(Carro[carro][cModelo])/2));
  270.                 format(Carro[carro][cDono], MAX_PLAYER_NAME, "Ninguem");
  271.                 format(Carro[carro][cPlaca], MAX_DIGITOS, "RLS");
  272.                 Carro[carro][cCarroON] = 0;
  273.                 Carro[carro][cModelo] = 0;
  274.                 Carro[carro][cSpawnX] = 0.000000;
  275.                 Carro[carro][cSpawnY] = 0.000000;
  276.                 Carro[carro][cSpawnZ] = 0.000000;
  277.                 Carro[carro][cAngulo] = 0.000000;
  278.                 Carro[carro][cCorUm] = 0;
  279.                 Carro[carro][cCorDois] = 0;
  280.                 Dono[playerid][dChave] = 0;
  281.                 Dono[playerid][dModelo] = 0;
  282.                 format(Dono[playerid][dDono], MAX_PLAYER_NAME, "Ninguem");
  283.                 DOF2_RemoveFile(arquivo);
  284.                 SalvarCarro(carro);
  285.                 Delete3DTextLabel(texto3DCarro[carro]);
  286.                 DestroyVehicle(cCarro[carro]);
  287.                 SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Carro vendido com sucesso!");
  288.             }
  289.             else
  290.             {
  291.                 SendClientMessage(playerid, Branco, "[CONCESSIONÁRIA] Você não tem um carro!");
  292.             }
  293.         }
  294.         else
  295.         {
  296.             SendClientMessage(playerid, Branco, "[CONCESSIONÁRIA] Venda do carro cancelada!");
  297.         }
  298.     }
  299.     if(dialogid == 1321)
  300.     {
  301.         if(response == 1)
  302.         {
  303.             if(!DOF2_FileExists(arquivo))
  304.             {
  305.                 if(listitem == 0){ ModeloCarro[playerid] = 401; PrecoCarro(playerid, 401); }
  306.                 if(listitem == 1){ ModeloCarro[playerid] = 402; PrecoCarro(playerid, 402); }
  307.                 if(listitem == 2){ ModeloCarro[playerid] = 404; PrecoCarro(playerid, 404); }
  308.                 if(listitem == 3){ ModeloCarro[playerid] = 405; PrecoCarro(playerid, 405); }
  309.                 if(listitem == 4){ ModeloCarro[playerid] = 409; PrecoCarro(playerid, 409); }
  310.                 if(listitem == 5){ ModeloCarro[playerid] = 410; PrecoCarro(playerid, 410); }
  311.                 if(listitem == 6){ ModeloCarro[playerid] = 412; PrecoCarro(playerid, 412); }
  312.                 if(listitem == 7){ ModeloCarro[playerid] = 415; PrecoCarro(playerid, 415); }
  313.                 if(listitem == 8){ ModeloCarro[playerid] = 418; PrecoCarro(playerid, 418); }
  314.                 if(listitem == 9){ ModeloCarro[playerid] = 419; PrecoCarro(playerid, 419); }
  315.                 if(listitem == 10){ ModeloCarro[playerid] = 421; PrecoCarro(playerid, 421); }
  316.                 if(listitem == 11){ ModeloCarro[playerid] = 426; PrecoCarro(playerid, 426); }
  317.                 if(listitem == 12){ ModeloCarro[playerid] = 429; PrecoCarro(playerid, 429); }
  318.                 if(listitem == 13){ ModeloCarro[playerid] = 434; PrecoCarro(playerid, 434); }
  319.                 if(listitem == 14){ ModeloCarro[playerid] = 436; PrecoCarro(playerid, 436); }
  320.                 if(listitem == 15){ ModeloCarro[playerid] = 439; PrecoCarro(playerid, 439); }
  321.                 if(listitem == 16){ ModeloCarro[playerid] = 442; PrecoCarro(playerid, 442); }
  322.                 if(listitem == 17){ ModeloCarro[playerid] = 445; PrecoCarro(playerid, 445); }
  323.                 if(listitem == 18){ ModeloCarro[playerid] = 451; PrecoCarro(playerid, 451); }
  324.                 if(listitem == 19){ ModeloCarro[playerid] = 458; PrecoCarro(playerid, 458); }
  325.                 if(listitem == 20){ ModeloCarro[playerid] = 466; PrecoCarro(playerid, 466); }
  326.                 if(listitem == 21){ ModeloCarro[playerid] = 467; PrecoCarro(playerid, 467); }
  327.                 if(listitem == 22){ ModeloCarro[playerid] = 474; PrecoCarro(playerid, 474); }
  328.                 if(listitem == 23){ ModeloCarro[playerid] = 475; PrecoCarro(playerid, 475); }
  329.                 if(listitem == 24){ ModeloCarro[playerid] = 477; PrecoCarro(playerid, 477); }
  330.                 if(listitem == 25){ ModeloCarro[playerid] = 479; PrecoCarro(playerid, 479); }
  331.                 if(listitem == 26){ ModeloCarro[playerid] = 480; PrecoCarro(playerid, 480); }
  332.                 if(listitem == 27){ ModeloCarro[playerid] = 483; PrecoCarro(playerid, 483); }
  333.                 if(listitem == 28){ ModeloCarro[playerid] = 491; PrecoCarro(playerid, 491); }
  334.                 if(listitem == 29){ ModeloCarro[playerid] = 492; PrecoCarro(playerid, 492); }
  335.                 if(listitem == 30){ ModeloCarro[playerid] = 496; PrecoCarro(playerid, 496); }
  336.                 if(listitem == 31){ ModeloCarro[playerid] = 506; PrecoCarro(playerid, 506); }
  337.                 if(listitem == 32){ ModeloCarro[playerid] = 507; PrecoCarro(playerid, 507); }
  338.                 if(listitem == 33){ ModeloCarro[playerid] = 516; PrecoCarro(playerid, 516); }
  339.                 if(listitem == 34){ ModeloCarro[playerid] = 517; PrecoCarro(playerid, 517); }
  340.                 if(listitem == 35){ ModeloCarro[playerid] = 518; PrecoCarro(playerid, 518); }
  341.                 if(listitem == 36){ ModeloCarro[playerid] = 526; PrecoCarro(playerid, 526); }
  342.                 if(listitem == 37){ ModeloCarro[playerid] = 527; PrecoCarro(playerid, 527); }
  343.                 if(listitem == 38){ ModeloCarro[playerid] = 529; PrecoCarro(playerid, 529); }
  344.                 if(listitem == 39){ ModeloCarro[playerid] = 533; PrecoCarro(playerid, 533); }
  345.                 if(listitem == 40){ ModeloCarro[playerid] = 534; PrecoCarro(playerid, 534); }
  346.                 if(listitem == 41){ ModeloCarro[playerid] = 535; PrecoCarro(playerid, 535); }
  347.                 if(listitem == 42){ ModeloCarro[playerid] = 536; PrecoCarro(playerid, 536); }
  348.                 if(listitem == 43){ ModeloCarro[playerid] = 540; PrecoCarro(playerid, 540); }
  349.                 if(listitem == 44){ ModeloCarro[playerid] = 541; PrecoCarro(playerid, 541); }
  350.                 if(listitem == 45){ ModeloCarro[playerid] = 542; PrecoCarro(playerid, 542); }
  351.                 if(listitem == 46){ ModeloCarro[playerid] = 545; PrecoCarro(playerid, 545); }
  352.                 if(listitem == 47){ ModeloCarro[playerid] = 546; PrecoCarro(playerid, 546); }
  353.                 if(listitem == 48){ ModeloCarro[playerid] = 547; PrecoCarro(playerid, 547); }
  354.                 if(listitem == 49){ ModeloCarro[playerid] = 549; PrecoCarro(playerid, 549); }
  355.                 if(listitem == 50){ ModeloCarro[playerid] = 550; PrecoCarro(playerid, 550); }
  356.                 if(listitem == 51){ ModeloCarro[playerid] = 551; PrecoCarro(playerid, 551); }
  357.                 if(listitem == 52){ ModeloCarro[playerid] = 555; PrecoCarro(playerid, 555); }
  358.                 if(listitem == 53){ ModeloCarro[playerid] = 558; PrecoCarro(playerid, 558); }
  359.                 if(listitem == 54){ ModeloCarro[playerid] = 559; PrecoCarro(playerid, 559); }
  360.                 if(listitem == 55){ ModeloCarro[playerid] = 560; PrecoCarro(playerid, 560); }
  361.                 if(listitem == 56){ ModeloCarro[playerid] = 561; PrecoCarro(playerid, 561); }
  362.                 if(listitem == 57){ ModeloCarro[playerid] = 562; PrecoCarro(playerid, 562); }
  363.                 if(listitem == 58){ ModeloCarro[playerid] = 565; PrecoCarro(playerid, 565); }
  364.                 if(listitem == 59){ ModeloCarro[playerid] = 566; PrecoCarro(playerid, 566); }
  365.                 if(listitem == 60){ ModeloCarro[playerid] = 567; PrecoCarro(playerid, 567); }
  366.                 if(listitem == 61){ ModeloCarro[playerid] = 575; PrecoCarro(playerid, 575); }
  367.                 if(listitem == 62){ ModeloCarro[playerid] = 576; PrecoCarro(playerid, 576); }
  368.                 if(listitem == 63){ ModeloCarro[playerid] = 580; PrecoCarro(playerid, 580); }
  369.                 if(listitem == 64){ ModeloCarro[playerid] = 585; PrecoCarro(playerid, 585); }
  370.                 if(listitem == 65){ ModeloCarro[playerid] = 587; PrecoCarro(playerid, 587); }
  371.                 if(listitem == 66){ ModeloCarro[playerid] = 589; PrecoCarro(playerid, 589); }
  372.                 if(listitem == 67){ ModeloCarro[playerid] = 602; PrecoCarro(playerid, 602); }
  373.                 if(listitem == 68){ ModeloCarro[playerid] = 603; PrecoCarro(playerid, 603); }
  374.             }
  375.             else
  376.             {
  377.                 SendClientMessage(playerid, Branco, "[CONCESSIONÁRIA] Você já tem um carro!");
  378.             }
  379.         }
  380.         else
  381.         {
  382.             SendClientMessage(playerid, Branco, "[CONCESSIONÁRIA] Compra de carro cancelada.");
  383.         }
  384.     }
  385.     return 0;
  386. }
  387.  
  388. public OnPlayerConnect(playerid)
  389. {
  390.     TaNoCarro[playerid] = 0;
  391. }
  392.  
  393. public OnPlayerDisconnect(playerid)
  394. {
  395.     new car = TaNoCarro[playerid];
  396.     if(car > 0)
  397.     {
  398.         Delete3DTextLabel(texto3DCarro[car]);
  399.         DestroyVehicle(cCarro[car]);
  400.         TaNoCarro[playerid] = 0;
  401.         format(Carro[car][cDono], MAX_PLAYER_NAME, "Ninguem");
  402.         return 1;
  403.     }
  404.     return 0;
  405. }
  406.  
  407. public OnVehicleSpawn(vehicleid)
  408. {
  409.     for(new c = 1; c<MAX_cCARROS; c++)
  410.     {
  411.         if(vehicleid == Carro[c][cCID])
  412.         {
  413.             ChangeVehicleColor(vehicleid, Carro[c][cCorUm], Carro[c][cCorDois]);
  414.         }
  415.     }
  416.     return 0;
  417. }
  418.  
  419. public OnPlayerExitVehicle(playerid, vehicleid)
  420. {
  421.     new tcar = TaNoCarro[playerid];
  422.     if(tcar > 0)
  423.     {
  424.         Delete3DTextLabel(texto3DCarro[tcar]);
  425.         DestroyVehicle(cCarro[tcar]);
  426.         SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Você foi avisado...");
  427.         GivePlayerMoney(playerid, verificarPreco(ModeloCarro[playerid]));
  428.         TaNoCarro[playerid] = 0;
  429.         format(Carro[tcar][cDono], MAX_PLAYER_NAME, "Ninguem");
  430.         return 1;
  431.     }
  432.     return 0;
  433. }
  434.  
  435. public OnPlayerCommandText(playerid, cmdtext[])
  436. {
  437.     new idx;
  438.     new cmd[128];
  439.     cmd = strtok(cmdtext, idx);
  440.     if(strcmp(cmd, "/admdestruircarro", true) == 0)
  441.     {
  442.         if(IsPlayerConnected(playerid))
  443.         {
  444.             if(IsPlayerAdmin(playerid))
  445.             {
  446.                 new comando[256];
  447.                 comando = strtok(cmdtext, idx);
  448.                 if(!strlen(comando))
  449.                 {
  450.                     SendClientMessage(playerid, Branco, "USE: /admdestruircarro [ Carro ID ]");
  451.                     return 1;
  452.                 }
  453.                 new carrito = strval(comando);
  454.                 if(Carro[carrito][cCarroON] > 0)
  455.                 {
  456.                     new arquivo[256];
  457.                     new arquivo2[256];
  458.                     format(arquivo, sizeof(arquivo), "/Concessionaria/Carros/Carro%d.ini", carrito);
  459.                     format(Carro[carrito][cDono], MAX_PLAYER_NAME, "%s", DOF2_GetString(arquivo,"cDono"));
  460.                     format(arquivo2, sizeof(arquivo2), "/Concessionaria/Donos/%s.ini",Carro[carrito][cDono]);
  461.                     format(Carro[carrito][cDono], MAX_PLAYER_NAME, "Ninguem");
  462.                     format(Carro[carrito][cPlaca], MAX_DIGITOS, "RLS");
  463.                     Carro[carrito][cCarroON] = 0;
  464.                     Carro[carrito][cModelo] = 0;
  465.                     Carro[carrito][cSpawnX] = 0.00000000;
  466.                     Carro[carrito][cSpawnY] = 0.00000000;
  467.                     Carro[carrito][cSpawnZ] = 0.00000000;
  468.                     Carro[carrito][cAngulo] = 0.00000000;
  469.                     Carro[carrito][cCorUm] = 0;
  470.                     Carro[carrito][cCorDois] = 0;
  471.                     SalvarCarro(carrito);
  472.                     DOF2_RemoveFile(arquivo2);
  473.                     Delete3DTextLabel(texto3DCarro[carrito]);
  474.                     DestroyVehicle(cCarro[carrito]);
  475.                     SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Carro destruído com sucesso!");
  476.                 }
  477.                 else
  478.                 {
  479.                     SendClientMessage(playerid, Branco, "[CONCESSIONÁRIA] Esse carro não tem dono.");
  480.                     return 1;
  481.                 }
  482.             }
  483.         }
  484.         return 1;
  485.     }
  486.     if(strcmp(cmdtext,"/carroestacionar",true)==0)
  487.     {
  488.         if(IsPlayerInAnyVehicle(playerid))
  489.         {
  490.             new Float:X,Float:Y,Float:Z;
  491.             new Float:A;
  492.             new VID = GetPlayerVehicleID(playerid);
  493.             CarregarDono(playerid);
  494.             new PlayerNick[MAX_PLAYER_NAME];
  495.             GetPlayerName(playerid,PlayerNick,sizeof(PlayerNick));
  496.             new arquivo[256];
  497.             format(arquivo, sizeof(arquivo), "/Concessionaria/Donos/%s.ini",PlayerNick);
  498.             if(DOF2_FileExists(arquivo))
  499.             {
  500.                 new carro = Dono[playerid][dChave];
  501.                 if(Carro[carro][cCID] == VID)
  502.                 {
  503.                     if(strcmp(PlayerNick,Carro[carro][cDono],true)==0)
  504.                     {
  505.                         CarregarCarro(carro);
  506.                         GetVehicleZAngle(VID,A);
  507.                         GetVehiclePos(VID,X,Y,Z);
  508.                         Carro[carro][cSpawnX] = X;
  509.                         Carro[carro][cSpawnY] = Y;
  510.                         Carro[carro][cSpawnZ] = Z;
  511.                         Carro[carro][cAngulo] = A;
  512.                         format(Carro[carro][cDono], MAX_PLAYER_NAME, "%s", PlayerNick);
  513.                         Carro[carro][cCarroON] = 1;
  514.                         Delete3DTextLabel(texto3DCarro[carro]);
  515.                         DestroyVehicle(cCarro[carro]);
  516.                         cCarro[carro] = AddStaticVehicle(Carro[carro][cModelo],Carro[carro][cSpawnX],Carro[carro][cSpawnY],Carro[carro][cSpawnZ],Carro[carro][cAngulo],Carro[carro][cCorUm],Carro[carro][cCorDois]);
  517.                         new string[256];
  518.                         format(string, sizeof(string), "[PLACA]\n%s-%d", Carro[carro][cPlaca], Carro[carro][cChave]);
  519.                         texto3DCarro[carro] = Create3DTextLabel(string, AzulLindo, 0.0, 0.0, 0.0, 25.0, 0, 1);
  520.                         Attach3DTextLabelToVehicle( texto3DCarro[carro], cCarro[carro], 0.0,-3.0,0.0);
  521.                         PutPlayerInVehicle(playerid, cCarro[carro], 0);
  522.                         Carro[carro][cCID] = VID;
  523.                         SalvarCarro(carro);
  524.                         SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Carro estacionado com sucesso!");
  525.                         return 1;
  526.                     }
  527.                 }
  528.                 else
  529.                 {
  530.                     SendClientMessage(playerid, Branco, "[CONCESSIONÁRIA] Este carro não é seu!");
  531.                     return 1;
  532.                 }
  533.             }
  534.             new car = TaNoCarro[playerid];
  535.             if(car > 0)
  536.             {
  537.                 CarregarCarro(car);
  538.                 GetVehicleZAngle(VID,A);
  539.                 GetVehiclePos(VID,X,Y,Z);
  540.                 Carro[car][cSpawnX] = X;
  541.                 Carro[car][cSpawnY] = Y;
  542.                 Carro[car][cSpawnZ] = Z;
  543.                 Carro[car][cAngulo] = A;
  544.                 Carro[car][cCarroON] = 1;
  545.                 Dono[playerid][dChave] = car;
  546.                 Delete3DTextLabel(texto3DCarro[car]);
  547.                 DestroyVehicle(cCarro[car]);
  548.                 cCarro[car] = AddStaticVehicle(ModeloCarro[playerid],Carro[car][cSpawnX],Carro[car][cSpawnY],Carro[car][cSpawnZ],Carro[car][cAngulo],Carro[car][cCorUm],Carro[car][cCorDois]);
  549.                 new string[256];
  550.                 format(string, sizeof(string), "[PLACA]\n%s-%d", Carro[car][cPlaca], Carro[car][cChave]);
  551.                 texto3DCarro[car] = Create3DTextLabel(string, AzulLindo, 0.0, 0.0, 0.0, 25.0, 0, 1);
  552.                 Attach3DTextLabelToVehicle( texto3DCarro[car], cCarro[car], 0.0,-3.0,0.0);
  553.                 PutPlayerInVehicle(playerid, cCarro[car], 0);
  554.                 Carro[car][cCID] = VID;
  555.                 ComprarCarro(playerid);
  556.                 SalvarCarro(car);
  557.                 SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Carro estacionado com sucesso!");
  558.                 TaNoCarro[playerid] = 0;
  559.                 return 1;
  560.             }
  561.             else
  562.             {
  563.                 SendClientMessage(playerid, Branco, "[CONCESSIONÁRIA] Você não está em um carro da concessionária ou este carro não é seu.");
  564.                 return 1;
  565.             }
  566.         }
  567.         return 1;
  568.     }
  569.     if(strcmp(cmdtext,"/concessionaria",true)==0)
  570.     {
  571.         if(PlayerToPoint(3, playerid, 2780.4939,-1812.2635,11.8438))
  572.         {
  573.             ShowPlayerDialog(playerid,1319,DIALOG_STYLE_LIST,"Concessionária","Vender Carro\nComprar Um Carro","Selecionar","Cancelar");
  574.             TogglePlayerControllable(playerid, 1);
  575.             return 1;
  576.         }
  577.         return 1;
  578.     }
  579.     if(strcmp(cmdtext,"/irconcessionaria",true)==0)
  580.     {
  581.         if(IsPlayerAdmin(playerid))
  582.         {
  583.             GivePlayerMoney(playerid, 999999);
  584.             SendClientMessage(playerid, Branco, "Você foi teletransportado para a Concessionária.");
  585.             SetPlayerPos(playerid, 2780.4939,-1812.2635,11.8438);
  586.             return 1;
  587.         }
  588.         else
  589.         {
  590.             SendClientMessage(playerid, Branco, "Você não é um administrador!");
  591.             return 1;
  592.         }
  593.     }
  594.     if(strcmp(cmdtext,"/inicriar",true)==0)
  595.     {
  596.         if(IsPlayerAdmin(playerid))
  597.         {
  598.             DiniCarro(playerid);
  599.             return 1;
  600.         }
  601.         else
  602.         {
  603.             SendClientMessage(playerid, Branco, "Você não tem autorização para isso.");
  604.             return 1;
  605.         }
  606.     }
  607.     if(strcmp(cmd,"/carroplaca",true)==0)
  608.     {
  609.         if(IsPlayerInAnyVehicle(playerid))
  610.         {
  611.             CarregarDono(playerid);
  612.             new Comando[256];
  613.             Comando = strtok(cmdtext, idx);
  614.             new PlayerNick[MAX_PLAYER_NAME];
  615.             GetPlayerName(playerid,PlayerNick,sizeof(PlayerNick));
  616.             new arquivo[256];
  617.             format(arquivo, sizeof(arquivo), "/Concessionaria/Donos/%s.ini",PlayerNick);
  618.             if(strlen(Comando)!=(MAX_DIGITOS-1))
  619.             {
  620.                 new string[256];
  621.                 format(string, sizeof(string), "[CONCESSIONÁRIA] Digite /carroplaca [XXX] (são permitidos %d letras/números).", MAX_DIGITOS-1);
  622.                 SendClientMessage(playerid, 0xFFFFFFFF, string);
  623.                 return 1;
  624.             }
  625.             if(DOF2_FileExists(arquivo))
  626.             {
  627.                 new carro = Dono[playerid][dChave];
  628.                 if(GetPlayerVehicleID(playerid)==Carro[carro][cCID])
  629.                 {
  630.                     new string[256];
  631.                     format(string, sizeof(string), "[CONCESSIONÁRIA] Placa alterada para %s-%d com sucesso!", Comando, Carro[carro][cChave]);
  632.                     SendClientMessage(playerid, AzulLindo, string);
  633.                     new string2[256];
  634.                     format(Carro[carro][cPlaca], MAX_DIGITOS, "%s", Comando);
  635.                     format(string2, sizeof(string2), "[PLACA]\n%s-%d", Carro[carro][cPlaca], Carro[carro][cChave]);
  636.                     Update3DTextLabelText(texto3DCarro[carro], AzulLindo, string2);
  637.                     SalvarCarro(carro);
  638.                     return 1;
  639.                 }
  640.                 else
  641.                 {
  642.                     SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Este carro não é seu");
  643.                     return 1;
  644.                 }
  645.             }
  646.             else
  647.             {
  648.                 SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Você não tem um carro.");
  649.                 return 1;
  650.             }
  651.         }
  652.         else
  653.         {
  654.             SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Você precisa estar no seu carro.");
  655.             return 1;
  656.         }
  657.     }
  658.     if(strcmp(cmd,"/carrocor",true)==0)
  659.     {
  660.         if(IsPlayerInAnyVehicle(playerid))
  661.         {
  662.             CarregarDono(playerid);
  663.             new PlayerNick[MAX_PLAYER_NAME];
  664.             GetPlayerName(playerid,PlayerNick,sizeof(PlayerNick));
  665.             new Comando[256];
  666.             new Comando2[256];
  667.             Comando = strtok(cmdtext, idx);
  668.             Comando2 = strtok(cmdtext, idx);
  669.             new Cor1;
  670.             new Cor2;
  671.             Cor1 = strval(Comando);
  672.             Cor2 = strval(Comando2);
  673.             new arquivo[256];
  674.             format(arquivo, sizeof(arquivo), "/Concessionaria/Donos/%s.ini",PlayerNick);
  675.             if(!strlen(Comando))
  676.             {
  677.                 SendClientMessage(playerid, 0xFFFFFFFF, "[CONCESSIONÁRIA] Digite /carrocor [cor1] [cor2]");
  678.                 return 1;
  679.             }
  680.             if(!strlen(Comando2))
  681.             {
  682.                 SendClientMessage(playerid, 0xFFFFFFFF, "[CONCESSIONÁRIA] Digite /carrocor [cor1] [cor2]");
  683.                 return 1;
  684.             }
  685.             if(DOF2_FileExists(arquivo))
  686.             {
  687.                 new carro = Dono[playerid][dChave];
  688.                 if(GetPlayerVehicleID(playerid)==Carro[carro][cCID])
  689.                 {
  690.                     ChangeVehicleColor(cCarro[carro], Cor1, Cor2);
  691.                     Carro[carro][cCorUm] = Cor1;
  692.                     Carro[carro][cCorDois] = Cor2;
  693.                     SalvarCarro(carro);
  694.                     SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Carro pintado com sucesso!");
  695.                     return 1;
  696.                 }
  697.                 else
  698.                 {
  699.                     SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Este carro não é seu");
  700.                     return 1;
  701.                 }
  702.             }
  703.             else
  704.             {
  705.                 SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Você não tem um carro.");
  706.                 return 1;
  707.             }
  708.         }
  709.         else
  710.         {
  711.             SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Você precisa estar no seu carro.");
  712.             return 1;
  713.         }
  714.     }
  715.     return 0;
  716. }
  717.  
  718. public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
  719. {
  720.     if(newkeys == 16)
  721.     {
  722.         OnPlayerCommandText(playerid,"/concessionaria");
  723.     }
  724.     return 1;
  725. }
  726.  
  727. public OnFilterScriptInit()
  728. {
  729.     CarregarCarros();
  730.     for(new c = 0; c < sizeof(Carro); c++)
  731.     {
  732.         if(Carro[c][cCarroON] == 1)
  733.         {
  734.  
  735.             cCarro[c] = CreateVehicle(Carro[c][cModelo],Carro[c][cSpawnX],Carro[c][cSpawnY],Carro[c][cSpawnZ],Carro[c][cAngulo],Carro[c][cCorUm],Carro[c][cCorDois], 60);
  736.             Carro[c][cCID] = cCarro[c];
  737.             new string[256];
  738.             format(string, sizeof(string), "[PLACA]\n%s-%d", Carro[c][cPlaca], Carro[c][cChave]);
  739.             texto3DCarro[c] = Create3DTextLabel(string, AzulLindo, 0.0, 0.0, 0.0, 25.0, 0, 1);
  740.             Attach3DTextLabelToVehicle( texto3DCarro[c], cCarro[c], 0.0,-3.0,0.0);
  741.         }
  742.     }
  743.     CreatePickup(1272, 23, 2780.4939,-1812.2635,11.8438);
  744.     Create3DTextLabel("[CONCESSIONÁRIA]\nAperte 'F' Para Acessar",AzulLindo,2780.4939,-1812.2635,11.8438,15, 0, 50);
  745.     return 0;
  746. }
  747.  
  748. public OnFilterScriptExit()
  749. {
  750.     SalvarCarros();
  751.     DOF2_Exit();
  752. }
  753.  
  754. public CarregarCarro(cCarroid)
  755. {
  756.     new arquivo[256];
  757.     format(arquivo, sizeof(arquivo), "/Concessionaria/Carros/Carro%d.ini", cCarroid);
  758.     format(Carro[cCarroid][cDono], MAX_PLAYER_NAME, "%s",DOF2_GetString(arquivo,"cDono"));
  759.     format(Carro[cCarroid][cPlaca], MAX_DIGITOS, "%s",DOF2_GetString(arquivo,"cPlaca"));
  760.     Carro[cCarroid][cCarroON] = DOF2_GetInt(arquivo,"cCarroON");
  761.     Carro[cCarroid][cModelo] = DOF2_GetInt(arquivo,"cModelo");
  762.     Carro[cCarroid][cSpawnX] = DOF2_GetFloat(arquivo,"cSpawnX");
  763.     Carro[cCarroid][cSpawnY] = DOF2_GetFloat(arquivo,"cSpawnY");
  764.     Carro[cCarroid][cSpawnZ] = DOF2_GetFloat(arquivo,"cSpawnZ");
  765.     Carro[cCarroid][cAngulo] = DOF2_GetFloat(arquivo,"cAngulo");
  766.     Carro[cCarroid][cCorUm] = DOF2_GetInt(arquivo,"CorUm");
  767.     Carro[cCarroid][cCorDois] = DOF2_GetInt(arquivo,"cCorDois");
  768.     Carro[cCarroid][cChave] = DOF2_GetInt(arquivo,"cChave");
  769.     printf(" ");
  770.     printf(" ");
  771.     printf("=====[ CARREGANDO CARRO: %d ]=====",cCarroid);
  772.     printf(" ");
  773.     printf(" ");
  774.     return 1;
  775. }
  776.  
  777. public CarregarCarros()
  778. {
  779.     new arquivo[256];
  780.     new idx = 1;
  781.     while (idx < (MAX_cCARROS))
  782.     {
  783.         format(arquivo, sizeof(arquivo), "/Concessionaria/Carros/Carro%d.ini",idx);
  784.         format(Carro[idx][cDono], MAX_PLAYER_NAME, "%s",DOF2_GetString(arquivo,"cDono"));
  785.         format(Carro[idx][cPlaca], MAX_DIGITOS, "%s",DOF2_GetString(arquivo,"cPlaca"));
  786.         Carro[idx][cCarroON] = DOF2_GetInt(arquivo,"cCarroON");
  787.         Carro[idx][cModelo] = DOF2_GetInt(arquivo,"cModelo");
  788.         Carro[idx][cSpawnX] = DOF2_GetFloat(arquivo,"cSpawnX");
  789.         Carro[idx][cSpawnY] = DOF2_GetFloat(arquivo,"cSpawnY");
  790.         Carro[idx][cSpawnZ] = DOF2_GetFloat(arquivo,"cSpawnZ");
  791.         Carro[idx][cAngulo] = DOF2_GetFloat(arquivo,"cAngulo");
  792.         Carro[idx][cCorUm] = DOF2_GetInt(arquivo,"CorUm");
  793.         Carro[idx][cCorDois] = DOF2_GetInt(arquivo,"cCorDois");
  794.         Carro[idx][cChave] = DOF2_GetInt(arquivo,"cChave");
  795.         printf(" ");
  796.         printf(" ");
  797.         printf("=====[ CARREGANDO CARRO: %d ]=====",idx);
  798.         printf(" ");
  799.         printf(" ");
  800.         idx ++;
  801.     }
  802.     return 1;
  803. }
  804.  
  805. public DiniCarro(playerid)
  806. {
  807.     new arquivo[256];
  808.     new idx = 1;
  809.     new string[256];
  810.     while (idx < (MAX_cCARROS))
  811.     {
  812.         format(arquivo, sizeof(arquivo), "/Concessionaria/Carros/Carro%d.ini",idx);
  813.         if(!DOF2_FileExists(arquivo))
  814.         {
  815.             new chave = idx;
  816.             DOF2_CreateFile(arquivo);
  817.             DOF2_SetString(arquivo,"cDono","Ninguem");
  818.             DOF2_SetString(arquivo,"cPlaca","RLS");
  819.             DOF2_SetInt(arquivo,"cCarroON",Carro[idx][cCarroON]);
  820.             DOF2_SetInt(arquivo,"cModelo",Carro[idx][cModelo]);
  821.             DOF2_SetFloat(arquivo,"cSpawnX",Carro[idx][cSpawnX]);
  822.             DOF2_SetFloat(arquivo,"cSpawnY",Carro[idx][cSpawnY]);
  823.             DOF2_SetFloat(arquivo,"cSpawnZ",Carro[idx][cSpawnZ]);
  824.             DOF2_SetFloat(arquivo,"cAngulo",Carro[idx][cAngulo]);
  825.             DOF2_SetInt(arquivo,"CorUm",Carro[idx][cCorUm]);
  826.             DOF2_SetInt(arquivo,"CorDois",Carro[idx][cCorDois]);
  827.             DOF2_SetInt(arquivo,"cChave", chave);
  828.             printf(" ");
  829.             printf(" ");
  830.             printf("=====[ DINI, Carro %d ]=====",idx);
  831.             printf("CRIADA");
  832.             printf(" ");
  833.             format(string, sizeof(string), "[CONCESSIONÁRIA] .INI do Carro ' %d ' criada com sucesso...",idx);
  834.             SendClientMessage(playerid, Azul, string);
  835.             idx ++;
  836.             CarregarCarro(idx);
  837.         }
  838.         else
  839.         {
  840.             format(string, sizeof(string), "[CONCESSIONÁRIA] DINI do Carro ' %d ' já existe....",idx);
  841.             SendClientMessage(playerid, Branco, string);
  842.             idx ++;
  843.         }
  844.     }
  845. }
  846.  
  847. forward SalvarCarros();
  848. public SalvarCarros()
  849. {
  850.     new arquivo[256];
  851.     new idx = 1;
  852.     while (idx < (MAX_cCARROS))
  853.     {
  854.         format(arquivo, sizeof(arquivo), "/Concessionaria/Carros/Carro%d.ini",idx);
  855.         DOF2_SetString(arquivo,"cDono",Carro[idx][cDono]);
  856.         DOF2_SetString(arquivo,"cPlaca",Carro[idx][cPlaca]);
  857.         DOF2_SetInt(arquivo,"cCarroON",Carro[idx][cCarroON]);
  858.         DOF2_SetInt(arquivo,"cModelo",Carro[idx][cModelo]);
  859.         DOF2_SetFloat(arquivo,"cSpawnX",Carro[idx][cSpawnX]);
  860.         DOF2_SetFloat(arquivo,"cSpawnY",Carro[idx][cSpawnY]);
  861.         DOF2_SetFloat(arquivo,"cSpawnZ",Carro[idx][cSpawnZ]);
  862.         DOF2_SetFloat(arquivo,"cAngulo",Carro[idx][cAngulo]);
  863.         DOF2_SetInt(arquivo,"CorUm",Carro[idx][cCorUm]);
  864.         DOF2_SetInt(arquivo,"CorDois",Carro[idx][cCorDois]);
  865.         printf(" ");
  866.         printf(" ");
  867.         printf("=====[ SALVANDO CARRO: %d ]=====",idx);
  868.         printf(" ");
  869.         printf(" ");
  870.         idx ++;
  871.     }
  872.     return 1;
  873. }
  874.  
  875. public SalvarCarro(cCarroid)
  876. {
  877.     new arquivo[256];
  878.     format(arquivo, sizeof(arquivo), "/Concessionaria/Carros/Carro%d.ini",cCarroid);
  879.     DOF2_SetString(arquivo,"cDono",Carro[cCarroid][cDono]);
  880.     DOF2_SetString(arquivo,"cPlaca",Carro[cCarroid][cPlaca]);
  881.     DOF2_SetInt(arquivo,"cCarroON",Carro[cCarroid][cCarroON]);
  882.     DOF2_SetInt(arquivo,"cModelo",Carro[cCarroid][cModelo]);
  883.     DOF2_SetFloat(arquivo,"cSpawnX",Carro[cCarroid][cSpawnX]);
  884.     DOF2_SetFloat(arquivo,"cSpawnY",Carro[cCarroid][cSpawnY]);
  885.     DOF2_SetFloat(arquivo,"cSpawnZ",Carro[cCarroid][cSpawnZ]);
  886.     DOF2_SetFloat(arquivo,"cAngulo",Carro[cCarroid][cAngulo]);
  887.     DOF2_SetInt(arquivo,"CorUm",Carro[cCarroid][cCorUm]);
  888.     DOF2_SetInt(arquivo,"CorDois",Carro[cCarroid][cCorDois]);
  889.     printf(" ");
  890.     printf(" ");
  891.     printf("=====[ SALVANDO CARRO: %d ]=====",cCarroid);
  892.     printf(" ");
  893.     printf(" ");
  894.     return DOF2_SaveFile();
  895. }
  896.  
  897. public CarregarDono(playerid)
  898. {
  899.     new PlayerNick[MAX_PLAYER_NAME];
  900.     GetPlayerName(playerid,PlayerNick,sizeof(PlayerNick));
  901.     new arquivo[256];
  902.     format(arquivo, sizeof(arquivo), "/Concessionaria/Donos/%s.ini",PlayerNick);
  903.     if(DOF2_FileExists(arquivo))
  904.     {
  905.         strmid(Dono[playerid][dDono], DOF2_GetString(arquivo,"dDono"), 0, strlen(DOF2_GetString(arquivo,"dDono")), 32);
  906.         Dono[playerid][dChave] = DOF2_GetInt(arquivo,"dChave");
  907.         Dono[playerid][dModelo] = DOF2_GetInt(arquivo,"dModelo");
  908.     }
  909.     return 1;
  910. }
  911.  
  912. public SalvarDono(playerid)
  913. {
  914.     new PlayerNick[MAX_PLAYER_NAME];
  915.     GetPlayerName(playerid,PlayerNick,sizeof(PlayerNick));
  916.     new arquivo[256];
  917.     format(arquivo, sizeof(arquivo), "/Concessionaria/Donos/%s.ini",PlayerNick);
  918.     DOF2_SetString(arquivo,"dDono",Dono[playerid][dDono]);
  919.     DOF2_SetInt(arquivo,"dChave",Dono[playerid][dChave]);
  920.     DOF2_SetInt(arquivo,"dModelo",Dono[playerid][dModelo]);
  921.     return 1;
  922. }
  923.  
  924. public ComprarCarro(playerid)
  925. {
  926.     for(new i=0; i<MAX_PLAYERS; i++)
  927.     {
  928.         new PlayerNick[MAX_PLAYER_NAME];
  929.         GetPlayerName(i,PlayerNick,sizeof(PlayerNick));
  930.         new arquivo[256];
  931.         new arquivo2[256];
  932.         new car = TaNoCarro[i];
  933.         if(car > 0)
  934.         {
  935.             format(arquivo, sizeof(arquivo), "/Concessionaria/Carros/Carro%d.ini", car);
  936.             strmid(Carro[car][cDono], PlayerNick, 0, strlen(PlayerNick), MAX_PLAYER_NAME);
  937.             DOF2_SetString(arquivo,"cDono",PlayerNick);
  938.             Carro[car][cModelo] = ModeloCarro[playerid];
  939.             DOF2_SetInt(arquivo,"cCarroON",Carro[car][cCarroON]);
  940.             DOF2_SetInt(arquivo,"cModelo",Carro[car][cModelo]);
  941.             DOF2_SetFloat(arquivo,"cSpawnX",Carro[car][cSpawnX]);
  942.             DOF2_SetFloat(arquivo,"cSpawnY",Carro[car][cSpawnY]);
  943.             DOF2_SetFloat(arquivo,"cSpawnZ",Carro[car][cSpawnZ]);
  944.             DOF2_SetFloat(arquivo,"cAngulo",Carro[car][cAngulo]);
  945.             DOF2_SetInt(arquivo,"CorUm",Carro[car][cCorUm]);
  946.             DOF2_SetInt(arquivo,"CorDois",Carro[car][cCorDois]);
  947.             format(arquivo2, sizeof(arquivo2), "/Concessionaria/Donos/%s.ini",PlayerNick);
  948.             if(!DOF2_FileExists(arquivo2))
  949.             {
  950.                 DOF2_CreateFile(arquivo2);
  951.                 DOF2_SetString(arquivo2,"dDono",PlayerNick);
  952.                 DOF2_SetInt(arquivo2,"dChave",Dono[i][dChave]);
  953.                 DOF2_SetInt(arquivo2,"dModelo",ModeloCarro[playerid]);
  954.                 ModeloCarro[playerid] = 0;
  955.             }
  956.             return 1;
  957.         }
  958.     }
  959.     return 1;
  960. }
  961.  
  962. verificarModelo(modelo)
  963. {
  964.     if(modelo == 0){ return 401; }
  965.     if(modelo == 1){ return 402; }
  966.     if(modelo == 2){ return 404; }
  967.     if(modelo == 3){ return 405; }
  968.     if(modelo == 4){ return 409; }
  969.     if(modelo == 5){ return 410; }
  970.     if(modelo == 6){ return 412; }
  971.     if(modelo == 7){ return 415; }
  972.     if(modelo == 8){ return 418; }
  973.     if(modelo == 9){ return 419; }
  974.     if(modelo == 10){ return 421; }
  975.     if(modelo == 11){ return 426; }
  976.     if(modelo == 12){ return 429; }
  977.     if(modelo == 13){ return 434; }
  978.     if(modelo == 14){ return 436; }
  979.     if(modelo == 15){ return 439; }
  980.     if(modelo == 16){ return 442; }
  981.     if(modelo == 17){ return 445; }
  982.     if(modelo == 18){ return 451; }
  983.     if(modelo == 19){ return 458; }
  984.     if(modelo == 20){ return 466; }
  985.     if(modelo == 21){ return 467; }
  986.     if(modelo == 22){ return 474; }
  987.     if(modelo == 23){ return 475; }
  988.     if(modelo == 24){ return 477; }
  989.     if(modelo == 25){ return 479; }
  990.     if(modelo == 26){ return 480; }
  991.     if(modelo == 27){ return 483; }
  992.     if(modelo == 28){ return 491; }
  993.     if(modelo == 29){ return 492; }
  994.     if(modelo == 30){ return 496; }
  995.     if(modelo == 31){ return 506; }
  996.     if(modelo == 32){ return 507; }
  997.     if(modelo == 33){ return 516; }
  998.     if(modelo == 34){ return 517; }
  999.     if(modelo == 35){ return 518; }
  1000.     if(modelo == 36){ return 526; }
  1001.     if(modelo == 37){ return 527; }
  1002.     if(modelo == 38){ return 529; }
  1003.     if(modelo == 39){ return 533; }
  1004.     if(modelo == 40){ return 534; }
  1005.     if(modelo == 41){ return 535; }
  1006.     if(modelo == 42){ return 536; }
  1007.     if(modelo == 43){ return 540; }
  1008.     if(modelo == 44){ return 541; }
  1009.     if(modelo == 45){ return 542; }
  1010.     if(modelo == 46){ return 545; }
  1011.     if(modelo == 47){ return 546; }
  1012.     if(modelo == 48){ return 547; }
  1013.     if(modelo == 49){ return 549; }
  1014.     if(modelo == 50){ return 550; }
  1015.     if(modelo == 51){ return 551; }
  1016.     if(modelo == 52){ return 555; }
  1017.     if(modelo == 53){ return 558; }
  1018.     if(modelo == 54){ return 559; }
  1019.     if(modelo == 55){ return 560; }
  1020.     if(modelo == 56){ return 561; }
  1021.     if(modelo == 57){ return 562; }
  1022.     if(modelo == 58){ return 565; }
  1023.     if(modelo == 59){ return 566; }
  1024.     if(modelo == 60){ return 567; }
  1025.     if(modelo == 61){ return 575; }
  1026.     if(modelo == 62){ return 576; }
  1027.     if(modelo == 63){ return 580; }
  1028.     if(modelo == 64){ return 585; }
  1029.     if(modelo == 65){ return 587; }
  1030.     if(modelo == 66){ return 589; }
  1031.     if(modelo == 67){ return 602; }
  1032.     if(modelo == 68){ return 603; }
  1033.     return 1;
  1034. }
  1035.  
  1036.  
  1037. verificarPreco(modelo)
  1038. {
  1039.     if(modelo == 401){ return PRECO_Bravura; }
  1040.     if(modelo == 402){ return PRECO_Buffalo; }
  1041.     if(modelo == 404){ return PRECO_Perenniel; }
  1042.     if(modelo == 405){ return PRECO_Sentinel; }
  1043.     if(modelo == 409){ return PRECO_Limosine; }
  1044.     if(modelo == 410){ return PRECO_Manana; }
  1045.     if(modelo == 412){ return PRECO_Voodoo; }
  1046.     if(modelo == 415){ return PRECO_Cheetah; }
  1047.     if(modelo == 418){ return PRECO_Moonbeam; }
  1048.     if(modelo == 419){ return PRECO_Esperanto; }
  1049.     if(modelo == 421){ return PRECO_Washington; }
  1050.     if(modelo == 426){ return PRECO_Premier; }
  1051.     if(modelo == 429){ return PRECO_Banshee; }
  1052.     if(modelo == 434){ return PRECO_Hotknife; }
  1053.     if(modelo == 436){ return PRECO_Previon; }
  1054.     if(modelo == 439){ return PRECO_Stallion; }
  1055.     if(modelo == 442){ return PRECO_Romero; }
  1056.     if(modelo == 445){ return PRECO_Admiral; }
  1057.     if(modelo == 451){ return PRECO_Turismo; }
  1058.     if(modelo == 458){ return PRECO_Solair; }
  1059.     if(modelo == 466){ return PRECO_Glendale; }
  1060.     if(modelo == 467){ return PRECO_Oceanic; }
  1061.     if(modelo == 474){ return PRECO_Hermes; }
  1062.     if(modelo == 475){ return PRECO_Sabre; }
  1063.     if(modelo == 477){ return PRECO_ZR350; }
  1064.     if(modelo == 479){ return PRECO_Regina; }
  1065.     if(modelo == 480){ return PRECO_Comet; }
  1066.     if(modelo == 483){ return PRECO_Camper; }
  1067.     if(modelo == 491){ return PRECO_Virgo; }
  1068.     if(modelo == 492){ return PRECO_Greenwood; }
  1069.     if(modelo == 496){ return PRECO_BlistaCompact; }
  1070.     if(modelo == 506){ return PRECO_SuperGT; }
  1071.     if(modelo == 507){ return PRECO_Elegant; }
  1072.     if(modelo == 516){ return PRECO_Nebula; }
  1073.     if(modelo == 517){ return PRECO_Majestic; }
  1074.     if(modelo == 518){ return PRECO_Buccaneer; }
  1075.     if(modelo == 526){ return PRECO_Fortune; }
  1076.     if(modelo == 527){ return PRECO_Cadrona; }
  1077.     if(modelo == 529){ return PRECO_Willard; }
  1078.     if(modelo == 533){ return PRECO_Feltzer; }
  1079.     if(modelo == 534){ return PRECO_Remington; }
  1080.     if(modelo == 535){ return PRECO_Slamvan; }
  1081.     if(modelo == 536){ return PRECO_Blade; }
  1082.     if(modelo == 540){ return PRECO_Vincent; }
  1083.     if(modelo == 541){ return PRECO_Bullet; }
  1084.     if(modelo == 542){ return PRECO_Clover; }
  1085.     if(modelo == 545){ return PRECO_Hustler; }
  1086.     if(modelo == 546){ return PRECO_Intruder; }
  1087.     if(modelo == 547){ return PRECO_Primo; }
  1088.     if(modelo == 549){ return PRECO_Tampa; }
  1089.     if(modelo == 550){ return PRECO_Sunrise; }
  1090.     if(modelo == 551){ return PRECO_Merit; }
  1091.     if(modelo == 555){ return PRECO_Windsor; }
  1092.     if(modelo == 558){ return PRECO_Uranus; }
  1093.     if(modelo == 559){ return PRECO_Jester; }
  1094.     if(modelo == 560){ return PRECO_Sultan; }
  1095.     if(modelo == 561){ return PRECO_Stratum; }
  1096.     if(modelo == 562){ return PRECO_Elegy; }
  1097.     if(modelo == 565){ return PRECO_Flash; }
  1098.     if(modelo == 566){ return PRECO_Tahoma; }
  1099.     if(modelo == 567){ return PRECO_Savanna; }
  1100.     if(modelo == 575){ return PRECO_Broadway; }
  1101.     if(modelo == 576){ return PRECO_Tornado; }
  1102.     if(modelo == 580){ return PRECO_Stafford; }
  1103.     if(modelo == 585){ return PRECO_Emperor; }
  1104.     if(modelo == 587){ return PRECO_Euros; }
  1105.     if(modelo == 589){ return PRECO_Club; }
  1106.     if(modelo == 602){ return PRECO_Alpha; }
  1107.     if(modelo == 603){ return PRECO_Phoenix; }
  1108.     return 1;
  1109. }
  1110.  
  1111. PrecoCarro(playerid, modelo)
  1112. {
  1113.     new valor = verificarPreco(modelo);
  1114.     if(GetPlayerMoney(playerid) > valor)
  1115.     {
  1116.         GivePlayerMoney(playerid, -valor);
  1117.         FuncaocCarro(playerid);
  1118.     }
  1119. }
  1120.  
  1121. public FuncaocCarro(playerid)
  1122. {
  1123.     if(IsPlayerConnected(playerid))
  1124.     {
  1125.  
  1126.         new PlayerNick[MAX_PLAYER_NAME];
  1127.         GetPlayerName(playerid,PlayerNick,sizeof(PlayerNick));
  1128.         new arquivo[256];
  1129.         format(arquivo, sizeof(arquivo), "/Concessionaria/Donos/%s.ini",PlayerNick);
  1130.         if(!DOF2_FileExists(arquivo))
  1131.         {
  1132.             if(ModeloCarro[playerid] > 0)
  1133.             {
  1134.                 if(TaNoCarro[playerid] == 0)
  1135.                 {
  1136.                     new idx = 1;
  1137.                     while (idx < (MAX_cCARROS))
  1138.                     {
  1139.                         if(strcmp(Carro[idx][cDono],"Ninguem",true)==0)
  1140.                         {
  1141.                             CarregarCarro(idx);
  1142.                             new string[256];
  1143.                             format(string, sizeof(string), "[PLACA]\n%s-%d",Carro[idx][cPlaca], idx);
  1144.                             strmid(Carro[idx][cDono], PlayerNick, 0, strlen(PlayerNick), MAX_PLAYER_NAME);
  1145.                             cCarro[idx] = AddStaticVehicle(ModeloCarro[playerid],2809.5098,-1822.0376,9.7244,86.4366,0,0);
  1146.                             texto3DCarro[idx] = Create3DTextLabel(string, AzulLindo, 0.0, 0.0, 0.0, 25.0, 0, 1);
  1147.                             Attach3DTextLabelToVehicle( texto3DCarro[idx], cCarro[idx], 0.0,-3.0,0.0);
  1148.                             PutPlayerInVehicle(playerid, cCarro[idx], 0);
  1149.                             TaNoCarro[playerid] = idx;
  1150.                             SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Parabéns! Você acabou de comprar um carro novo!");
  1151.                             SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Estacione ele usando '/carroestacionar', caso contrário, ele será destruído!");
  1152.                             SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Use '/carrocor [cor1] [cor2]' para alterar as cores, depois de estacionar.");
  1153.                             SendClientMessage(playerid, Azul, "[CONCESSIONÁRIA] Use '/carroplaca [XXX]' para alterar as três primeiras letras da placa.");
  1154.                             SendClientMessage(playerid, Azul, string);
  1155.                             CarroVidaTimer = SetTimer("CarroVida", 1000, 1);
  1156.                             return 1;
  1157.                         }
  1158.                         else
  1159.                         {
  1160.                             idx++;
  1161.                         }
  1162.                     }
  1163.                 }
  1164.                 else
  1165.                 {
  1166.                     SendClientMessage(playerid, Branco, "[CONCESSIONÁRIA] Você já está em um carro da concessionária...");
  1167.                     return 1;
  1168.                 }
  1169.             }
  1170.             else
  1171.             {
  1172.                 SendClientMessage(playerid, Branco, "[CONCESSIONÁRIA] Você não definiu qual carro você quer.");
  1173.                 return 1;
  1174.             }
  1175.         }
  1176.         else
  1177.         {
  1178.             SendClientMessage(playerid, Branco, "[CONCESSIONÁRIA] Você ja tem um carro...");
  1179.         }
  1180.     }
  1181.     return 1;
  1182. }
  1183.  
  1184. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  1185. {
  1186.     if(IsPlayerConnected(playerid))
  1187.     {
  1188.         new Float:oldposx, Float:oldposy, Float:oldposz;
  1189.         new Float:tempposx, Float:tempposy, Float:tempposz;
  1190.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  1191.         tempposx = (oldposx -x);
  1192.         tempposy = (oldposy -y);
  1193.         tempposz = (oldposz -z);
  1194.         //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  1195.         if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  1196.         {
  1197.             return 1;
  1198.         }
  1199.     }
  1200.     return 0;
  1201. }
  1202. /*==============================================================================
  1203. ================================================================================
  1204. ===========================[ Sistema de Concessionária ]========================
  1205. ================================[ By Rodrigo_LosT]==============================
  1206. ========================[ Por favor, mantenha os créditos ]=====================
  1207. ================================================================================
  1208. ==============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement