Advertisement
JonathanFeitosa

JFS Concessionária v1.0 [0.3x]

Jan 23rd, 2013
1,636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 26.38 KB | None | 0 0
  1. // Créditos: Jonathan Feitosa
  2.  
  3. #include <a_samp>
  4. #include <dof2>
  5. #include <zcmd>
  6. #include "../include/gl_common.inc"
  7.  
  8. #define PRESSED(%0)             \
  9.                                     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  10. #define JFSCON                  \
  11.                                     "JFSConcessionaria/Veiculo_%s.ini"
  12. #define AdicionarVIP            \
  13.                                     0 // Restrição para VIP Comprar carros ! Bote 1 se quiser usar !
  14. #define VariavelVIP             \
  15.                                     VIP[playerid] // Ao ativar a restrição, bote a sua variavel para apenas eles comprarem carro !
  16. #define GranaAoEntrar           \
  17.                                     1000 // Ganha Que irá perder ao entrar no carro
  18. #define MaxCarros               \
  19.                                     50  // MaxCarros  = 50 + 1 NULL !!!!
  20. #define PrecoCarros             \
  21.                                     20000 // Preço dos Carros ao Comprar
  22. #define GranaVenderCarro        \
  23.                                     15000 // Grana ao Vender seu Carro !
  24. #define JFSQuantCarrosTextD     \
  25.                                     98
  26. #define CARROSPAGINA            \
  27.                                     21
  28. #define CARROSLINHA             \
  29.                                     7
  30.  
  31. new Float:VRandSpawn[][4] =
  32. {
  33.     {2148.6836,-1148.0562,24.1682,268.8489},
  34.     {2148.5146,-1152.8904,23.6661,270.3880},
  35.     {2148.1873,-1161.5844,23.5503,268.5666},
  36.     {2147.8203,-1170.8265,23.5474,267.7164},
  37.     {2147.6870,-1180.4973,23.5474,269.9578},
  38.     {2147.4980,-1189.7125,23.5474,270.0607},
  39.     {2147.6921,-1194.3140,23.5594,272.2749},
  40.     {2147.6689,-1203.4419,23.5818,269.2569}
  41. };
  42.  
  43. new gItemList[JFSQuantCarrosTextD] =
  44. {
  45.     400,401,402,404,405,410,411,412,413,414,415,418,419,421,422,424,426,429,434,436,439,440,442,
  46.     443,445, 451,458,459,461,462,463,466,467,468,471,474,475, 477,478,479,480,
  47.     482,483,485,489,491,492,494,495,496,500,502, 503, 504,505,506,507,508, 516,517,518,521,522,
  48.     526,527,529,533,534,535, 526, 540, 541,542,543, 547,549,550,551,555,559,560,561,562, 565,566,
  49.     567,575,576,579,579,580,581, 585,587,589,600,602,603,
  50. };
  51.  
  52. enum JFSInformacoes
  53. {
  54.     JFSModelo,
  55.     JFSDono[MAX_PLAYER_NAME],
  56.     Float:JFSCorX,
  57.     Float:JFSCorY,
  58.     Float:JFSCorZ,
  59.     Float:JFSAngulo,
  60.     JFSCor1,
  61.     JFSCor2,
  62.     JFSCofre,
  63.     JFSPlaca
  64. };
  65.  
  66. new
  67.     JFSCarros[MaxCarros][JFSInformacoes],
  68.     JFSID[MaxCarros],
  69.     CarroJFS[MaxCarros],
  70.     gTotalItems = JFSQuantCarrosTextD,
  71.     PlayerText:gCurrentPageTextDrawId[MaxCarros],
  72.     PlayerText:gHeaderTextDrawId[MaxCarros],
  73.     PlayerText:gBackgroundTextDrawId[MaxCarros],
  74.     PlayerText:gNextButtonTextDrawId[MaxCarros],
  75.     PlayerText:gPrevButtonTextDrawId[MaxCarros],
  76.     PlayerText:gSelectionItems[MaxCarros][CARROSPAGINA],
  77.     gSelectionItemsTag[MaxCarros][CARROSPAGINA],
  78.     gItemAt[MaxCarros],
  79.     Celulas[124],
  80.     JFSCheck[MaxCarros]
  81. ;
  82.  
  83.  
  84. public OnFilterScriptInit()
  85. {
  86.     CreatePickup(1239, 23, 2132.0010,-1149.9999,24.2075);
  87.     Create3DTextLabel("Sistema de Concessionária\nAperte 'F'", -1, 2132.0010,-1149.9999,24.207, 40.0, 0);
  88.     format(Celulas, sizeof(Celulas), "/JFSConcessionaria");
  89.     if(!DOF2::FileExists(Celulas))
  90.     {
  91.         for(new x=0; x < 20; x++) {
  92.         print("[JFS Concessionária] - NÃO EXISTE A PASTA JFSConcessionaria NO SCRIPTFILES ! CRIE AGORA !");
  93.         }
  94.     } else print("[JFS Concessionária] - Carregado com Sucesso !");
  95.     return true;
  96. }
  97.  
  98. public OnFilterScriptExit()
  99. {
  100.     DOF2::Exit();
  101.     return true;
  102. }
  103.  
  104. public OnPlayerConnect(playerid)
  105. {
  106.     CarregarCarro(playerid);
  107.     gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  108.     gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  109.     gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  110.     gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  111.     gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  112.  
  113.     for(new x=0; x < CARROSPAGINA; x++) {
  114.         gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
  115.     }
  116.    
  117.     gItemAt[playerid] = 0;
  118.    
  119.     return true;
  120. }
  121. public OnPlayerDisconnect(playerid)
  122. {
  123.     JFSDestroyVehicle(playerid);
  124.     return true;
  125. }
  126.  
  127. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  128. {
  129.     if(GetPVarInt(playerid, "JFSTextAtivado") == 0) return false;
  130.    
  131.     if(clickedid == Text:INVALID_TEXT_DRAW) {
  132.         DestroySelectionMenu(playerid);
  133.         SetPVarInt(playerid, "JFSTextAtivado", 0);
  134.         PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  135.         return true;
  136.     }
  137.     return false;
  138. }
  139.  
  140. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  141. {
  142.     if(GetPVarInt(playerid, "JFSTextAtivado") == 0) return false;
  143.     new curpage = GetPVarInt(playerid, "JFSPagina");
  144.    
  145.     if(playertextid == gNextButtonTextDrawId[playerid])
  146.     {
  147.         if(curpage < (GETNumeroPaginas() - 1))
  148.         {
  149.             SetPVarInt(playerid, "JFSPagina", curpage + 1);
  150.             ShowPlayerModelPreviews(playerid);
  151.             UpdatePageTextDraw(playerid);
  152.             PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  153.         } else {
  154.             PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  155.         }
  156.         return true;
  157.     }
  158.     if(playertextid == gPrevButtonTextDrawId[playerid])
  159.     {
  160.         if(curpage > 0)
  161.         {
  162.             SetPVarInt(playerid, "JFSPagina", curpage - 1);
  163.             ShowPlayerModelPreviews(playerid);
  164.             UpdatePageTextDraw(playerid);
  165.             PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
  166.         } else {
  167.             PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  168.         }
  169.         return true;
  170.     }
  171.     new x=0;
  172.     while(x != CARROSPAGINA)
  173.     {
  174.         if(GetPlayerMoney(playerid) < PrecoCarros) return SendClientMessage(playerid, -1, "Você não tem dinheiro suficiente ! R$20.000");
  175.         if(playertextid == gSelectionItems[playerid][x])
  176.         {
  177.             JFSComprouVeiculo(playerid, x);
  178.             PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  179.             DestroySelectionMenu(playerid);
  180.             CancelSelectTextDraw(playerid);
  181.             SetPVarInt(playerid, "JFSTextAtivado", 0);
  182.             return true;
  183.         }
  184.         x++;
  185.     }
  186.     return false;
  187. }
  188.  
  189. public OnPlayerCommandText(playerid, cmdtext[]) return false;
  190.  
  191. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  192. {
  193.     if (PRESSED(KEY_SECONDARY_ATTACK))
  194.     {
  195.         if(IsPlayerInRangeOfPoint(playerid, 1.0, 2132.0010, -1149.9999, 24.2075))
  196.         {
  197.             if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "Você Não comprar veiculo dentro de um.");
  198.             if((CarroJFS[playerid] == 1)) return SendClientMessage(playerid, -1, "Você Já Tem um Veiculo.");
  199.             #if(AdicionarVIP == 1)
  200.             if(VariavelVIP < 1)  return SendClientMessage(playerid, -1, "Você Não é VIP.");
  201.             #endif
  202.             DestroySelectionMenu(playerid);
  203.             SetPVarInt(playerid, "JFSTextAtivado", 1);
  204.             CreateSelectionMenu(playerid);
  205.             SelectTextDraw(playerid, 0xACCBF1FF);
  206.         }
  207.     }
  208.     return true;
  209. }
  210.  
  211. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  212. {
  213.       if(dialogid == 7337)
  214.       {
  215.             if(response)
  216.             {
  217.                 if(listitem == 0)
  218.                 {
  219.                     new VeiculoID = JFSID[playerid];
  220.                     new Float:CordX, Float:CordY, Float:CordZ, Float:Angulo;
  221.                     GetVehiclePos(VeiculoID, CordX, CordY, CordZ);
  222.                     GetVehicleZAngle(VeiculoID, Angulo);
  223.                     JFSCarros[playerid][JFSCorX] = CordX;
  224.                     JFSCarros[playerid][JFSCorY] = CordY;
  225.                     JFSCarros[playerid][JFSCorZ] = CordZ;
  226.                     JFSCarros[playerid][JFSAngulo] = Angulo;
  227.                     DestroyVehicle(VeiculoID);
  228.                     JFSID[playerid] = CreateVehicle(JFSCarros[playerid][JFSModelo], JFSCarros[playerid][JFSCorX], JFSCarros[playerid][JFSCorY], JFSCarros[playerid][JFSCorZ], JFSCarros[playerid][JFSAngulo], JFSCarros[playerid][JFSCor1] , JFSCarros[playerid][JFSCor2], 0);
  229.                     PutPlayerInVehicle(playerid, JFSID[playerid], 0);
  230.                     SendClientMessage(playerid, -1, "Seu Veiculo vai da Spawn Aqui Agora!");
  231.                     SalvarArquivos(playerid);
  232.                 }
  233.                 if(listitem == 1)
  234.                 {
  235.                     ShowPlayerDialog(playerid, 3773, DIALOG_STYLE_INPUT, "JFS Concessionária v1.0 - Cor", "DIGITE O ID DA COR 1 DE SEU VEICULO\n\n\nPS: As Cores Foram Modificadas na versão 0.3x.", "Comprar", "Cancelar");
  236.                 }
  237.                 if(listitem == 2)
  238.                 {
  239.                     format(Celulas, sizeof(Celulas), "[JFS Concessionária] - Seu Veiculo Será Vendido Por %d.\n\nCaso Queria Vender seu Veículo, Confirme Abaixo.\n\n", GranaVenderCarro);
  240.                     ShowPlayerDialog(playerid, 4217, DIALOG_STYLE_MSGBOX, "JFS Concessionária v1.0 - Vender Veiculo", Celulas, "Confirmar", "Cancelar");
  241.                 }
  242.                 if(listitem == 3)
  243.                 {
  244.                     ShowPlayerDialog(playerid, 2461, DIALOG_STYLE_INPUT, "JFS Concessionária v1.0 - Placa", "DIGITE A PLACA DO SEU VEICULO\n\n", "Trocar", "Cancelar");
  245.                 }
  246.                 if(listitem == 4)
  247.                 {
  248.                     GivePlayerMoney(playerid, JFSCarros[playerid][JFSCofre]);
  249.                     new string[128];
  250.                     format(string, sizeof(string), "[JFS Concessionária] - Você retirou %d de seu veiculo.", JFSCarros[playerid][JFSCofre]);
  251.                     SendClientMessage(playerid, -1, string);
  252.                     JFSCarros[playerid][JFSCofre] = 0;
  253.                     SalvarArquivos(playerid);
  254.                 }
  255.             }
  256.             return true;
  257.       }
  258.       if(dialogid == 4217)
  259.       {
  260.             if(response)
  261.             {
  262.                 format(Celulas, sizeof(Celulas), JFSCON, PlayerName(playerid));
  263.                 DOF2::RemoveFile(Celulas);
  264.                 DOF2::SaveFile();
  265.                 DestroyVehicle(JFSID[playerid]);
  266.                 CarroJFS[playerid] = 0;
  267.                 RemovePlayerFromVehicle(playerid);
  268.                 format(Celulas, sizeof(Celulas), "[JFS Concessionária] - Você Vendeu seu veiculo e ganhou %d.", GranaVenderCarro);
  269.                 SendClientMessage(playerid, -1, Celulas);
  270.                 GivePlayerMoney(playerid, GranaVenderCarro);
  271.             }
  272.             return true;
  273.       }
  274.       if(dialogid == 2461)
  275.       {
  276.             if(response)
  277.             {
  278.                 if(strlen(inputtext) > 1 && strlen(inputtext) < 9)
  279.                 {
  280.                     format(Celulas,sizeof(Celulas),"%s", inputtext);
  281.                     new Float:CordX, Float:CordY, Float:CordZ, Float:Angulo;
  282.                     new VeiculoID = JFSID[playerid];
  283.                     SetVehicleNumberPlate(VeiculoID, Celulas);
  284.                     GetVehiclePos(VeiculoID, CordX, CordY, CordZ);
  285.                     GetVehicleZAngle(VeiculoID, Angulo);
  286.                     SetVehicleToRespawn(VeiculoID);
  287.                     SetVehiclePos(VeiculoID, CordX, CordY, CordZ);
  288.                     SetVehicleZAngle(VeiculoID, Angulo);
  289.                     PutPlayerInVehicle(playerid, VeiculoID, 0);
  290.                     format(JFSCarros[playerid][JFSPlaca] , 9,"%s", inputtext);
  291.                     SalvarArquivos(playerid);
  292.                 }
  293.                 else SendClientMessage(playerid, -1, "Apenas Caractéristicas de 2 a 8 !");
  294.             }
  295.             return true;
  296.       }
  297.       if(dialogid == 3773)
  298.       {
  299.             if(response)
  300.             {
  301.                 new VeiculoID = JFSID[playerid];
  302.                 if(!strval(inputtext)) return SendClientMessage(playerid, -1, "Apenas Numeros!"), true;
  303.                 if(strval(inputtext) < 0 || strval(inputtext) > 255) return SendClientMessage(playerid, -1, "Existes Cores Apenas Entre 0 á 255."), true;
  304.                 JFSCarros[playerid][JFSCor1] = strval(inputtext);
  305.                 ChangeVehicleColor(VeiculoID, JFSCarros[playerid][JFSCor1], -1);
  306.                 ShowPlayerDialog(playerid, 7733, DIALOG_STYLE_INPUT, "JFS Concessionária v1.0 - Cor", "DIGITE O ID DA COR 2 DE SEU VEICULO\n\n\nPS: As Cores Foram Modificadas na versão 0.3x.", "Comprar", "Cancelar");
  307.             }
  308.             return true;
  309.       }
  310.       if(dialogid == 7733)
  311.       {
  312.             if(response)
  313.             {
  314.                 new VeiculoID = JFSID[playerid];
  315.                 if(!strval(inputtext)) return SendClientMessage(playerid, -1, "Apenas Numeros!"), ShowPlayerDialog(playerid, 7733, DIALOG_STYLE_INPUT, "JFS Concessionária v1.0 - Cor", "DIGITE O ID DA COR 2 DE SEU VEICULO\n\n\nPS: As Cores Foram Modificadas na versão 0.3x.", "Comprar", "Cancelar"), true;
  316.                 if(strval(inputtext) < 0 || strval(inputtext) > 255) return SendClientMessage(playerid, -1, "Existes Cores Apenas Entre 0 á 255."), ShowPlayerDialog(playerid, 7733, DIALOG_STYLE_INPUT, "JFS Concessionária v1.0 - Cor", "DIGITE O ID DA COR 2 DE SEU VEICULO\n\n\nPS: As Cores Foram Modificadas na versão 0.3x.", "Comprar", "Cancelar"), true;
  317.                 JFSCarros[playerid][JFSCor2] = strval(inputtext);
  318.                 ChangeVehicleColor(VeiculoID, JFSCarros[playerid][JFSCor1], JFSCarros[playerid][JFSCor2]);
  319.                 SendClientMessage(playerid, -1, "Cores Definidas com Sucesso!");
  320.                 SalvarArquivos(playerid);
  321.             }
  322.             else ShowPlayerDialog(playerid, 7733, DIALOG_STYLE_INPUT, "JFS Concessionária v1.0 - Cor", "DIGITE O ID DA COR 2 DE SEU VEICULO\n\n\nPS: As Cores Foram Modificadas na versão 0.3x.", "Comprar", "Cancelar");
  323.             return true;
  324.       }
  325.       return true;
  326. }
  327.  
  328. public OnPlayerStateChange(playerid, newstate, oldstate)
  329. {
  330.         if(newstate == PLAYER_STATE_DRIVER)
  331.         {
  332.             for(new carro, JFS = sizeof(JFSCarros); carro != JFS; carro++)
  333.             {
  334.                 if(JFSID[carro] == GetPlayerVehicleID(playerid) && strcmp(PlayerName(playerid), JFSCarros[carro][JFSDono], true))
  335.                 {
  336.                     format(Celulas, sizeof(Celulas), "[JFS Concessionária] - Você pagou para %s R$%d por entrar no seu veiculo.", JFSCarros[carro][JFSDono], GranaAoEntrar);
  337.                     SendClientMessage(playerid, -1, Celulas);
  338.                     GivePlayerMoney(playerid, -GranaAoEntrar);
  339.                     JFSCarros[playerid][JFSCofre] += GranaAoEntrar;
  340.                     SalvarArquivos(playerid);
  341.                 }
  342.                 if(JFSID[carro] == GetPlayerVehicleID(playerid) && !strcmp(PlayerName(playerid), JFSCarros[carro][JFSDono], true))
  343.                 {
  344.                     SendClientMessage(playerid, -1, "[JFS Concessionária] - Bem Vindo ao Seu Veiculo! Use: /veiculomenu");
  345.                 }
  346.             }
  347.         }
  348.         return true;
  349. }
  350.  
  351. public OnPlayerEnterCheckpoint (playerid)
  352. {
  353.     if (JFSCheck[playerid] == 1 )
  354.     {
  355.         SendClientMessage (playerid , -1 , "[JFS Concessionária] - Aqui Está Seu Veículo!");
  356.         DisablePlayerCheckpoint (playerid);
  357.         return true;
  358.     }
  359.     return true;
  360. }
  361.  
  362. CMD:excluirveiculo(playerid, params[])
  363. {
  364.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xDEEE20FF, "Apenas Para Administrador Logado na RCON!");
  365.     format(Celulas, sizeof(Celulas), JFSCON, params);
  366.     if(!DOF2::FileExists(Celulas)) return SendClientMessage(playerid, -1, "Esse Úsuario não tem veiculo!");
  367.     format(Celulas, sizeof(Celulas), "Arquivo Veiculo_%s.ini Excluido com Sucesso dos ScriptFiles !", params);
  368.     SendClientMessage(playerid, -1, Celulas);
  369.     DOF2::RemoveFile(Celulas);
  370.     DOF2::SaveFile();
  371.     if(IsPlayerConnected(strlen(params)))
  372.     {
  373.         JFSID[strlen(params)] = 0;
  374.         DestroyVehicle(JFSID[strlen(params)]);
  375.     }
  376.     return true;
  377. }
  378.  
  379. CMD:veiculomenu(playerid, params[])
  380. {
  381.     format(Celulas, sizeof(Celulas), JFSCON, PlayerName(playerid));
  382.     if (!DOF2::FileExists(Celulas)) return SendClientMessage ( playerid , -1 , "Você não tem um veiculo!" ) ;
  383.     if (!IsPlayerInVehicle(playerid, JFSID[playerid])) return SendClientMessage (playerid , -1 , "Você não está em seu veiculo." ) ;
  384.     ShowPlayerDialog(playerid, 7337, DIALOG_STYLE_LIST, "JFS Concessionária - Menu", "Estacionar Neste Lugar\nCor do Veiculo\nVender Veiculo\nPlaca Veiculo\nGrana Veiculo", "Selecionar", "Cancelar");
  385.     return true;
  386. }
  387.  
  388. CMD:grana(playerid, params[])
  389. {
  390.     GivePlayerMoney(playerid, 500000);
  391.     return true;
  392. }
  393. CMD:irla(playerid, params[])
  394. {
  395.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xDEEE20FF, "Apenas Para Administrador Logado na RCON!");
  396.     SetPlayerPos(playerid, 2132.0010,-1149.9999,24.2075);
  397.     return true;
  398. }
  399. CMD:localizarveiculo(playerid, params[])
  400. {
  401.     format(Celulas, sizeof(Celulas), JFSCON, PlayerName(playerid));
  402.     if (!DOF2::FileExists(Celulas)) return SendClientMessage ( playerid , -1 , "Você não tem um veiculo!" ) ;
  403.     JFSCheck[playerid] = 1;
  404.     new Float:CordX, Float:CordY, Float:CordZ;
  405.     GetVehiclePos(JFSID[playerid], CordX, CordY, CordZ);
  406.     SetPlayerCheckpoint (playerid , CordX, CordY, CordZ, 10.0);
  407.     SendClientMessage(playerid , -1, "Seu Veículo Está Marcado no Mapa !");
  408.     return true;
  409. }
  410.  
  411. stock PlayerName(playerid)
  412. {
  413.     new Name[MAX_PLAYER_NAME];
  414.     GetPlayerName(playerid, Name, sizeof(Name));
  415.     return Name;
  416. }
  417.  
  418. stock SalvarArquivos(playerid)
  419. {
  420.     format(Celulas, sizeof(Celulas), JFSCON, PlayerName(playerid));
  421.     if(!DOF2::FileExists(Celulas)) DOF2::CreateFile(Celulas), DOF2::SetString(Celulas,"Dono", PlayerName(playerid));
  422.     JFSCarros[playerid][JFSDono] = PlayerName(playerid);
  423.     format(JFSCarros[playerid][JFSDono], MAX_PLAYER_NAME, DOF2::GetString(Celulas, "Dono"));
  424.     DOF2::SetString(Celulas,"Dono", JFSCarros[playerid][JFSDono]);
  425.     DOF2::SetInt(Celulas,"Modelo", JFSCarros[playerid][JFSModelo]);
  426.     DOF2::SetFloat(Celulas,"CorX", JFSCarros[playerid][JFSCorX]);
  427.     DOF2::SetFloat(Celulas,"CorY", JFSCarros[playerid][JFSCorY]);
  428.     DOF2::SetFloat(Celulas,"CorZ", JFSCarros[playerid][JFSCorZ]);
  429.     DOF2::SetFloat(Celulas,"Angulo", JFSCarros[playerid][JFSAngulo]);
  430.     DOF2::SetInt(Celulas,"Cor1", JFSCarros[playerid][JFSCor1]);
  431.     DOF2::SetInt(Celulas,"Cor2", JFSCarros[playerid][JFSCor2]);
  432.     DOF2::SetString(Celulas,"Placa", JFSCarros[playerid][JFSPlaca]);
  433.     DOF2::SetInt(Celulas,"Cofre", JFSCarros[playerid][JFSCofre]);
  434.  
  435.     format(JFSCarros[playerid][JFSDono], MAX_PLAYER_NAME, DOF2::GetString(Celulas, "Dono"));
  436.     DOF2::GetString(Celulas, "Dono", JFSCarros[playerid][JFSDono]);
  437.     JFSCarros[playerid][JFSModelo] = DOF2::GetInt(Celulas, "Modelo");
  438.     JFSCarros[playerid][JFSCorX] = DOF2::GetFloat(Celulas, "CorX");
  439.     JFSCarros[playerid][JFSCorY] = DOF2::GetFloat(Celulas, "CorY");
  440.     JFSCarros[playerid][JFSCorZ] = DOF2::GetFloat(Celulas, "CorZ");
  441.     JFSCarros[playerid][JFSAngulo] = DOF2::GetFloat(Celulas, "Angulo");
  442.     JFSCarros[playerid][JFSCor1] = DOF2::GetInt(Celulas, "Cor1");
  443.     JFSCarros[playerid][JFSCor2] = DOF2::GetInt(Celulas, "Cor2");
  444.     DOF2::GetString(Celulas, "Placa", JFSCarros[playerid][JFSPlaca]);
  445.     JFSCarros[playerid][JFSCofre] = DOF2::GetInt(Celulas, "Cofre");
  446.     DOF2::SaveFile();
  447.     return true;
  448. }
  449.  
  450. stock CarregarCarro(playerid)
  451. {
  452.     format(Celulas, sizeof(Celulas), JFSCON, PlayerName(playerid));
  453.     if(DOF2::FileExists(Celulas))
  454.     {
  455.         format(JFSCarros[playerid][JFSDono], MAX_PLAYER_NAME, DOF2::GetString(Celulas, "Dono"));
  456.         DOF2::GetString(Celulas, "Dono", JFSCarros[playerid][JFSDono]);
  457.         JFSCarros[playerid][JFSModelo] = DOF2::GetInt(Celulas, "Modelo");
  458.         JFSCarros[playerid][JFSCorX] = DOF2::GetFloat(Celulas, "CorX");
  459.         JFSCarros[playerid][JFSCorY] = DOF2::GetFloat(Celulas, "CorY");
  460.         JFSCarros[playerid][JFSCorZ] = DOF2::GetFloat(Celulas, "CorZ");
  461.         JFSCarros[playerid][JFSAngulo] = DOF2::GetFloat(Celulas, "Angulo");
  462.         JFSCarros[playerid][JFSCor1] = DOF2::GetInt(Celulas, "Cor1");
  463.         JFSCarros[playerid][JFSCor2] = DOF2::GetInt(Celulas, "Cor2");
  464.         JFSCarros[playerid][JFSCofre] = DOF2::GetInt(Celulas, "Cofre");
  465.         DOF2::GetString(Celulas, "Placa", JFSCarros[playerid][JFSPlaca]);
  466.         DOF2::SaveFile();
  467.         JFSCreateVehicle(playerid);
  468.     }
  469.     return true;
  470. }
  471.  
  472. stock JFSCreateVehicle(playerid)
  473. {
  474.     CarroJFS[playerid] = 1;
  475.     JFSID[playerid] = CreateVehicle(JFSCarros[playerid][JFSModelo], JFSCarros[playerid][JFSCorX], JFSCarros[playerid][JFSCorY], JFSCarros[playerid][JFSCorZ], JFSCarros[playerid][JFSAngulo], JFSCarros[playerid][JFSCor1] , JFSCarros[playerid][JFSCor2], 0);
  476.     SetVehicleNumberPlate(JFSID[playerid], JFSCarros[playerid][JFSPlaca]);
  477.     return true;
  478. }
  479.  
  480. stock JFSDestroyVehicle(playerid)
  481. {
  482.     format(Celulas, sizeof(Celulas), JFSCON, PlayerName(playerid));
  483.     if(DOF2::FileExists(Celulas)) DestroyVehicle(JFSID[playerid]), CarroJFS[playerid] = 0;
  484.     return true;
  485. }
  486.  
  487. GETNumeroPaginas()
  488. {
  489.     if((gTotalItems >= CARROSPAGINA) && (gTotalItems % CARROSPAGINA) == 0)
  490.     {
  491.         return (gTotalItems / CARROSPAGINA);
  492.     }
  493.     else return (gTotalItems / CARROSPAGINA) + 1;
  494. }
  495.  
  496. PlayerText:CreateCurrentPageTextDraw(playerid, Float:Xpos, Float:Ypos)
  497. {
  498.     new PlayerText:txtInit;
  499.     txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, "0/0");
  500.     PlayerTextDrawUseBox(playerid, txtInit, 0);
  501.     PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
  502.     PlayerTextDrawFont(playerid, txtInit, 1);
  503.     PlayerTextDrawSetShadow(playerid, txtInit, 0);
  504.     PlayerTextDrawSetOutline(playerid, txtInit, 1);
  505.     PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
  506.     PlayerTextDrawShow(playerid, txtInit);
  507.     return txtInit;
  508. }
  509. PlayerText:CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, button_text[])
  510. {
  511.     new PlayerText:txtInit;
  512.     txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, button_text);
  513.     PlayerTextDrawUseBox(playerid, txtInit, 1);
  514.     PlayerTextDrawBoxColor(playerid, txtInit, 60);
  515.     PlayerTextDrawBackgroundColor(playerid, txtInit,5);
  516.     PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
  517.     PlayerTextDrawFont(playerid, txtInit, 1);
  518.     PlayerTextDrawSetShadow(playerid, txtInit, 0);
  519.     PlayerTextDrawSetOutline(playerid, txtInit, 0);
  520.     PlayerTextDrawColor(playerid, txtInit, 0x4A5A6BFF);
  521.     PlayerTextDrawSetSelectable(playerid, txtInit, 1);
  522.     PlayerTextDrawAlignment(playerid, txtInit, 2);
  523.     PlayerTextDrawTextSize(playerid, txtInit, Height, Width);
  524.     PlayerTextDrawShow(playerid, txtInit);
  525.     return txtInit;
  526. }
  527.  
  528. PlayerText:CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, header_text[])
  529. {
  530.     new PlayerText:txtInit;
  531.     txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, header_text);
  532.     PlayerTextDrawUseBox(playerid, txtInit, 0);
  533.     PlayerTextDrawLetterSize(playerid, txtInit, 1.25, 3.0);
  534.     PlayerTextDrawFont(playerid, txtInit, 0);
  535.     PlayerTextDrawSetShadow(playerid, txtInit, 0);
  536.     PlayerTextDrawSetOutline(playerid, txtInit, 1);
  537.     PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
  538.     PlayerTextDrawShow(playerid, txtInit);
  539.     return txtInit;
  540. }
  541.  
  542. PlayerText:CreatePlayerBackgroundTextDraw(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height)
  543. {
  544.     new PlayerText:txtBackground = CreatePlayerTextDraw(playerid, Xpos, Ypos,
  545.     "                                            ~n~");
  546.     PlayerTextDrawUseBox(playerid, txtBackground, 1);
  547.     PlayerTextDrawBoxColor(playerid, txtBackground, 60);
  548.     PlayerTextDrawLetterSize(playerid, txtBackground, 5.0, 5.0);
  549.     PlayerTextDrawFont(playerid, txtBackground, 0);
  550.     PlayerTextDrawSetShadow(playerid, txtBackground, 0);
  551.     PlayerTextDrawSetOutline(playerid, txtBackground, 0);
  552.     PlayerTextDrawColor(playerid, txtBackground,0x000000FF);
  553.     PlayerTextDrawTextSize(playerid, txtBackground, Width, Height);
  554.     PlayerTextDrawBackgroundColor(playerid, txtBackground, 0x00000099);
  555.     PlayerTextDrawShow(playerid, txtBackground);
  556.     return txtBackground;
  557. }
  558.  
  559. PlayerText:CreateModelPreviewTextDraw(playerid, modelindex, Float:Xpos, Float:Ypos, Float:width, Float:height)
  560. {
  561.     new PlayerText:txtPlayerSprite = CreatePlayerTextDraw(playerid, Xpos, Ypos, "");
  562.     PlayerTextDrawFont(playerid, txtPlayerSprite, TEXT_DRAW_FONT_MODEL_PREVIEW);
  563.     PlayerTextDrawColor(playerid, txtPlayerSprite, 0xFFFFFFFF);
  564.     PlayerTextDrawBackgroundColor(playerid, txtPlayerSprite, 0x000000EE);
  565.     PlayerTextDrawTextSize(playerid, txtPlayerSprite, width, height);
  566.     PlayerTextDrawSetPreviewModel(playerid, txtPlayerSprite, modelindex);
  567.     PlayerTextDrawSetPreviewRot(playerid,txtPlayerSprite, -16.0, 0.0, -55.0);
  568.     PlayerTextDrawSetSelectable(playerid, txtPlayerSprite, 1);
  569.     PlayerTextDrawShow(playerid,txtPlayerSprite);
  570.     return txtPlayerSprite;
  571. }
  572.  
  573. JFSComprouVeiculo(playerid, Modelo)
  574. {
  575.     new rand = random(sizeof(VRandSpawn));
  576.     JFSCarros[playerid][JFSModelo] = gSelectionItemsTag[playerid][Modelo];
  577.     JFSCarros[playerid][JFSCorX] = VRandSpawn[rand][0];
  578.     JFSCarros[playerid][JFSCorY] = VRandSpawn[rand][1];
  579.     JFSCarros[playerid][JFSCorZ] = VRandSpawn[rand][2];
  580.     JFSCarros[playerid][JFSAngulo] = VRandSpawn[rand][3];
  581.     JFSCarros[playerid][JFSCor1] = -1;
  582.     JFSCarros[playerid][JFSCor2] = -1;
  583.     JFSID[playerid] = CreateVehicle(JFSCarros[playerid][JFSModelo], JFSCarros[playerid][JFSCorX], JFSCarros[playerid][JFSCorY], JFSCarros[playerid][JFSCorZ], JFSCarros[playerid][JFSAngulo], JFSCarros[playerid][JFSCor1] , JFSCarros[playerid][JFSCor2], 0);
  584.     PutPlayerInVehicle(playerid, JFSID[playerid], 0);
  585.     CarroJFS[playerid] = 1;
  586.     GivePlayerMoney(playerid, -PrecoCarros);
  587.     format(Celulas, sizeof(Celulas), "~w~VEICULO COMPRADO POR ~r~%dR$", PrecoCarros);
  588.     GameTextForPlayer(playerid, Celulas , 5000,4);
  589.     SalvarArquivos(playerid);
  590. }
  591.  
  592. DestroyPlayerModelPreviews(playerid)
  593. {
  594.     new x=0;
  595.     while(x != CARROSPAGINA) {
  596.         if(gSelectionItems[playerid][x] != PlayerText:INVALID_TEXT_DRAW) {
  597.             PlayerTextDrawDestroy(playerid, gSelectionItems[playerid][x]);
  598.             gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
  599.         }
  600.         x++;
  601.     }
  602. }
  603. ShowPlayerModelPreviews(playerid)
  604. {
  605.     new x=0;
  606.     new Float:BaseX = 75.0;
  607.     new Float:BaseY = 130.0 - (70.0 * 0.33);
  608.     new linetracker = 0;
  609.  
  610.     new itemat = GetPVarInt(playerid, "JFSPagina") * CARROSPAGINA;
  611.  
  612.     DestroyPlayerModelPreviews(playerid);
  613.     while(x != CARROSPAGINA && itemat < gTotalItems) {
  614.         if(linetracker == 0) {
  615.             BaseX = 75.0 + 25.0;
  616.             BaseY += 70.0 + 1.0;
  617.         }
  618.         gSelectionItems[playerid][x] = CreateModelPreviewTextDraw(playerid, gItemList[itemat], BaseX, BaseY, 60.0, 70.0);
  619.         gSelectionItemsTag[playerid][x] = gItemList[itemat];
  620.         BaseX += 60.0 + 1.0;
  621.         linetracker++;
  622.         if(linetracker == CARROSLINHA) linetracker = 0;
  623.         itemat++;
  624.         x++;
  625.     }
  626. }
  627. UpdatePageTextDraw(playerid)
  628. {
  629.     new PageText[64+1];
  630.     format(PageText, 64, "%d/%d", GetPVarInt(playerid,"JFSPagina") + 1, GETNumeroPaginas());
  631.     PlayerTextDrawSetString(playerid, gCurrentPageTextDrawId[playerid], PageText);
  632. }
  633. CreateSelectionMenu(playerid)
  634. {
  635.     gBackgroundTextDrawId[playerid] = CreatePlayerBackgroundTextDraw(playerid, 75.0, 130.0 + 20.0, 550.0, 180.0);
  636.     gHeaderTextDrawId[playerid] = CreatePlayerHeaderTextDraw(playerid, 75.0, 130.0, "JFS Concessionaria");
  637.     gCurrentPageTextDrawId[playerid] = CreateCurrentPageTextDraw(playerid, 550.0 - 30.0, 130.0 + 15.0);
  638.     gNextButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, 550.0 - 30.0, 130.0+180.0+100.0, 50.0, 16.0, "Proximo");
  639.     gPrevButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, 550.0 - 90.0, 130.0+180.0+100.0, 50.0, 16.0, "Anterior");
  640.  
  641.     ShowPlayerModelPreviews(playerid);
  642.     UpdatePageTextDraw(playerid);
  643.     SendClientMessage(playerid, -1, "Para Sair aperte ESC !");
  644. }
  645. DestroySelectionMenu(playerid)
  646. {
  647.     DestroyPlayerModelPreviews(playerid);
  648.  
  649.     PlayerTextDrawDestroy(playerid, gHeaderTextDrawId[playerid]);
  650.     PlayerTextDrawDestroy(playerid, gBackgroundTextDrawId[playerid]);
  651.     PlayerTextDrawDestroy(playerid, gCurrentPageTextDrawId[playerid]);
  652.     PlayerTextDrawDestroy(playerid, gNextButtonTextDrawId[playerid]);
  653.     PlayerTextDrawDestroy(playerid, gPrevButtonTextDrawId[playerid]);
  654.  
  655.     gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  656.     gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  657.     gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  658.     gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  659.     gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  660. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement