Guest User

Sistema de Concessionária - By: LeLeTe

a guest
Aug 1st, 2012
2,864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 24.96 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. #define FILTERSCRIPT
  4.  
  5. #define CARROS 1 //Coloque aqui a quantidade de carros no seu servidor +1
  6. #define MAX_CARROS 10 //Aqui, coloque o limite de carros do FS.
  7. #define SPAWN_X 2128.7856//Aqui, defina a posição X de spawn dos carros recém-comprados da concessionária.
  8. #define SPAWN_Y -1142.3700//Aqui, defina a posição Y de spawn dos carros recém-comprados da concessionária.
  9. #define SPAWN_Z 25.0067//Aqui, defina a posição Z de spawn dos carros recém-comprados da concessionária.
  10. #define ANGULO 359.1015//Aqui, defina o ângulo de spawn dos carros recém-comprados da concessionária.
  11. #define Car_Infernus 30000
  12. #define Car_Cheetah 30000
  13. #define Car_Banshee 30000
  14. #define Car_Hotknife 30000
  15. #define Car_Turismo 30000
  16. #define Car_ZR_350 30000
  17. #define Car_Comet 30000
  18. #define Car_Super_GT 30000
  19. #define Car_Windsor 30000
  20. #define Car_Feltzer 30000
  21. #define Car_Euros 30000
  22.  
  23. #include <a_samp>
  24. #include <core>
  25. #include <float>
  26. #include <time>
  27. #include <file>
  28.  
  29. #pragma tabsize 0
  30.  
  31. new Text:Black0;
  32. new Text:Black1;
  33. new Text:Black2;
  34. new Text:Black3;
  35. new Text:LightBlack;
  36. new Text:VHS[MAX_PLAYERS];
  37. new bool:TextShow[MAX_PLAYERS];
  38. new bool:VHSCreated[MAX_PLAYERS];
  39. new Text3D:Placa[MAX_CARROS];
  40. new gPlaca[MAX_PLAYERS][256];
  41.  
  42. stock strtok(const string[], &index)
  43. {
  44.     new length = strlen(string);
  45.     while ((index < length) && (string[index] <= ' '))
  46.     {
  47.         index++;
  48.     }
  49.  
  50.     new offset = index;
  51.     new result[20];
  52.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  53.     {
  54.         result[index - offset] = string[index];
  55.         index++;
  56.     }
  57.     result[index - offset] = EOS;
  58.     return result;
  59. }
  60.  
  61. stock ReturnPlayerName( playerid )
  62. {
  63.     new
  64.     NameString[ MAX_PLAYER_NAME ],
  65.     stringPos;
  66.     GetPlayerName( playerid, NameString, MAX_PLAYER_NAME );
  67.     stringPos = strfind( NameString, "_" );
  68.     NameString[ stringPos ] = ' ';
  69.     return NameString;
  70. }
  71.  
  72. enum jInfo
  73. {
  74.     jChaveDoCarro,
  75.     jPlaca[128],
  76. }
  77.  
  78. new JogadorDataBase[MAX_PLAYERS][jInfo];
  79.  
  80. forward J_Salvar(playerid);
  81. forward J_Carregar(playerid);
  82. public J_Salvar(playerid)
  83. {
  84.     if(IsPlayerConnected(playerid))
  85.     {
  86.         new string3[64];
  87.         new playername3[MAX_PLAYER_NAME];
  88.         GetPlayerName(playerid, playername3, sizeof(playername3));
  89.         format(string3, sizeof(string3), "LeLeTe/%s.ini", playername3);
  90.         new File: hFile = fopen(string3, io_write);
  91.         if (hFile)
  92.         {
  93.             new var[256];
  94.             format(var, 64, "jChaveDoCarro=%d\r\n", JogadorDataBase[playerid][jChaveDoCarro]);fwrite(hFile, var);
  95.             format(var, 64, "jPlaca=%s\r\n", JogadorDataBase[playerid][jPlaca]);fwrite(hFile, var);
  96.             format(var, 255, "gPlaca=%s\r\n", gPlaca[playerid]);fwrite(hFile, var);
  97.             fclose(hFile);
  98.         }
  99.     }
  100.     return 1;
  101. }
  102.  
  103. public J_Carregar(playerid)
  104. {
  105.     new string2[64];
  106.     new playername2[MAX_PLAYER_NAME];
  107.     new playernamesplit[3][MAX_PLAYER_NAME];
  108.     GetPlayerName(playerid, playername2, sizeof(playername2));
  109.     split(playername2, playernamesplit, '_');
  110.     format(string2, sizeof(string2), "LeLeTe/%s.ini", playername2);
  111.     new File: UserFile = fopen(string2, io_read);
  112.     if ( UserFile )
  113.     {
  114.         new key[256], val[ 256 ];
  115.         new Data[ 256 ];
  116.         while ( fread( UserFile , Data , sizeof( Data ) ) )
  117.         {
  118.             key = ini_GetValue( Data );
  119.             if( strcmp( key , "jChaveDoCarro" , true ) == 0 ) { val = ini_GetValue( Data ); JogadorDataBase[playerid][jChaveDoCarro] = strval( val ); }
  120.             if( strcmp( key , "jPlaca" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(JogadorDataBase[playerid][jPlaca], val, 0, strlen(val)-1, 255); }
  121.             if( strcmp( key , "gPlaca" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(gPlaca[playerid], val, 0, strlen(val)-1, 255); }
  122.         }
  123.         fclose(UserFile);
  124.     }
  125.     return 1;
  126. }
  127.  
  128. forward ini_GetKey( line[] )
  129. forward ini_GetValue( line[] )
  130. stock ini_GetKey( line[] )
  131. {
  132.     new keyRes[256];
  133.     keyRes[0] = 0;
  134.     if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  135.     strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  136.     return keyRes;
  137. }
  138.  
  139. stock ini_GetValue( line[] )
  140. {
  141.     new valRes[256];
  142.     valRes[0]=0;
  143.     if ( strfind( line , "=" , true ) == -1 ) return valRes;
  144.     strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
  145.     return valRes;
  146. }
  147.  
  148. forward split(const strsrc[], strdest[][], delimiter);
  149. public split(const strsrc[], strdest[][], delimiter)
  150. {
  151.     new i, li;
  152.     new aNum;
  153.     new len;
  154.     while(i <= strlen(strsrc)){
  155.         if(strsrc[i]==delimiter || i==strlen(strsrc)){
  156.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  157.             strdest[aNum][len] = 0;
  158.             li = i+1;
  159.             aNum++;
  160.         }
  161.         i++;
  162.     }
  163.     return 1;
  164. }
  165.  
  166. enum Carros
  167. {
  168.     cModelo,
  169.     Float:cx,
  170.     Float:cy,
  171.     Float:cz,
  172.     Float:cangulo,
  173.     cCor1,
  174.     cCor2,
  175.     cDono[MAX_PLAYER_NAME],
  176.     cNome[MAX_PLAYER_NAME],
  177.     cValor,
  178.     cArrayQualquer,
  179.     cRegistrado,
  180.     cComprado,
  181.     cTrava,
  182.     cPlaca[30],
  183. };
  184.  
  185. new CarrosInfo[MAX_CARROS][Carros];
  186.  
  187. forward OnPlayerEnterVehicle(playerid, vehicleid, ispassenger);
  188. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  189. {
  190.     if(CarrosInfo[vehicleid][cTrava] == 1 && CarrosInfo[vehicleid][cComprado] == 1)
  191.     {
  192.         new Float:Cx, Float:Cy, Float:Cz;
  193.         GetPlayerPos(playerid, Cx, Cy, Cz);
  194.         SetPlayerPos(playerid, Cx, Cy, Cz);
  195.     }
  196.     new string[128];
  197.     format(string,sizeof(string),"|| Dono deste carro: %s ||",CarrosInfo[vehicleid][cDono]);
  198.     SendClientMessage(playerid, 0x1A1AFFAA, string);
  199.     return 1;
  200. }
  201.  
  202. forward CarregarCarros();
  203. public CarregarCarros()
  204. {
  205.     new arrCoords[14][64];
  206.     new strFromFile2[256];
  207.     new File: file = fopen("LeLeTe/Concessionaria_Carros.cfg", io_read);
  208.     if (file)
  209.     {
  210.         new idx = CARROS;
  211.         while (idx < sizeof(CarrosInfo))
  212.         {
  213.             fread(file, strFromFile2);
  214.             split(strFromFile2, arrCoords, ',');
  215.             CarrosInfo[idx][cModelo] = strval(arrCoords[0]);
  216.             CarrosInfo[idx][cx] = floatstr(arrCoords[1]);
  217.             CarrosInfo[idx][cy] = floatstr(arrCoords[2]);
  218.             CarrosInfo[idx][cz] = floatstr(arrCoords[3]);
  219.             CarrosInfo[idx][cangulo] = floatstr(arrCoords[4]);
  220.             CarrosInfo[idx][cCor1] = strval(arrCoords[5]);
  221.             CarrosInfo[idx][cCor2] = strval(arrCoords[6]);
  222.             strmid(CarrosInfo[idx][cDono], arrCoords[7], 0, strlen(arrCoords[7]), 255);
  223.             strmid(CarrosInfo[idx][cNome], arrCoords[8], 0, strlen(arrCoords[8]), 255);
  224.             CarrosInfo[idx][cValor] = strval(arrCoords[9]);
  225.             CarrosInfo[idx][cRegistrado] = strval(arrCoords[10]);
  226.             CarrosInfo[idx][cComprado] = strval(arrCoords[11]);
  227.             CarrosInfo[idx][cTrava] = strval(arrCoords[12]);
  228.             strmid(CarrosInfo[idx][cPlaca], arrCoords[13], 0, strlen(arrCoords[13]), 30);
  229.             printf("Nome do Carro: %d Dono:%s Placa %s",idx,CarrosInfo[idx][cDono],CarrosInfo[idx][cPlaca]);
  230.             idx++;
  231.         }
  232.     }
  233.     return 1;
  234. }
  235.  
  236. forward SalvarCarros();
  237. public SalvarCarros()
  238. {
  239.     new File: file2;
  240.     new idx = CARROS;
  241.     while (idx < sizeof(CarrosInfo))
  242.     {
  243.         new coordsstring[256];
  244.         format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d,%d,%d,%s\r\n",
  245.         CarrosInfo[idx][cModelo],//
  246.         CarrosInfo[idx][cx],//
  247.         CarrosInfo[idx][cy],//
  248.         CarrosInfo[idx][cz],//
  249.         CarrosInfo[idx][cangulo],//
  250.         CarrosInfo[idx][cCor1],//
  251.         CarrosInfo[idx][cCor1],//
  252.         CarrosInfo[idx][cDono],//
  253.         CarrosInfo[idx][cNome],//
  254.         CarrosInfo[idx][cValor],//
  255.         CarrosInfo[idx][cRegistrado],//
  256.         CarrosInfo[idx][cComprado],//
  257.         CarrosInfo[idx][cTrava],
  258.         CarrosInfo[idx][cPlaca]);
  259.         if(idx == CARROS)
  260.         {
  261.             file2 = fopen("LeLeTe/Concessionaria_Carros.cfg", io_write);
  262.         }
  263.         else
  264.         {
  265.             file2 = fopen("LeLeTe/Concessionaria_Carros.cfg", io_append);
  266.         }
  267.         fwrite(file2, coordsstring);
  268.         idx++;
  269.         fclose(file2);
  270.     }
  271.     return 1;
  272. }
  273.  
  274. stock CheckPlayerDistanceToVehicle(Float:radi, playerid, vehicleid)
  275. {
  276.     if(IsPlayerConnected(playerid))
  277.     {
  278.         new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z;
  279.         GetPlayerPos(playerid,PX,PY,PZ);
  280.         GetVehiclePos(vehicleid, X,Y,Z);
  281.         new Float:Distance = (X-PX)*(X-PX)+(Y-PY)*(Y-PY)+(Z-PZ)*(Z-PZ);
  282.         if(Distance <= radi*radi)
  283.         {
  284.             return 1;
  285.         }
  286.     }
  287.     return 0;
  288. }
  289.  
  290. stock Concessionaria(playerid, nomedocarro[MAX_PLAYER_NAME], preco, modelo, Float:posX, Float:posY, Float:posZ, Float:angulo)
  291. {
  292.     if(GetPlayerMoney(playerid) >= preco )
  293.     {
  294.         new colorOne = 0 + random(255);
  295.         new colorTwo = 0 + random(255);
  296.         new idcar = AddStaticVehicleEx(modelo,posX,posY,posZ,angulo,colorOne,colorTwo,60000);
  297.         new sendername[MAX_PLAYER_NAME]
  298.         sendername = ReturnPlayerName(playerid);
  299.         strmid(CarrosInfo[idcar][cDono], sendername, 0, strlen(sendername), 999);
  300.         new result[128];
  301.         format(result, sizeof(result), "[Por:LeLeTe]\n[|%s|]", nomedocarro);
  302.         Placa[idcar] = Create3DTextLabel(result, 0xFFFFFFFF, 0.0, 0.0, 0.0, 50.0, -1, 0);
  303.         Attach3DTextLabelToVehicle(Placa[idcar],idcar, 0.0, -2.9, 0.0);
  304.         GivePlayerMoney(playerid,-preco);
  305.         SendClientMessage(playerid, 0xFFFFFFFF, "Parabéns pelo seu carro!");
  306.         JogadorDataBase[playerid][jChaveDoCarro] = idcar;
  307.         CarrosInfo[idcar][cModelo] = modelo;
  308.         CarrosInfo[idcar][cx] = posX;
  309.         CarrosInfo[idcar][cy] = posY;
  310.         CarrosInfo[idcar][cz] = posZ;
  311.         CarrosInfo[idcar][cangulo] = angulo;
  312.         CarrosInfo[idcar][cCor1] = colorOne;
  313.         CarrosInfo[idcar][cCor2] = colorTwo;
  314.         CarrosInfo[idcar][cValor] = preco;
  315.         CarrosInfo[idcar][cNome] = nomedocarro;
  316.         SalvarCarros();
  317.         J_Salvar(playerid);
  318.     }
  319. }
  320.  
  321. public OnFilterScriptInit()
  322. {
  323.     CarregarCarros();
  324.     print("\n--------------------------------------");
  325.     print(" Sistema de Concessionárias por: LeLeTe v1.5");
  326.     print("--------------------------------------\n");
  327.     for(new h = CARROS; h < sizeof(CarrosInfo); h++)
  328.     {
  329.         AddStaticVehicleEx(CarrosInfo[h][cModelo],CarrosInfo[h][cx],CarrosInfo[h][cy],CarrosInfo[h][cz]+1.0,CarrosInfo[h][cangulo],CarrosInfo[h][cCor1],CarrosInfo[h][cCor2],60000);
  330.         new result[200];
  331.         format(result, sizeof(result), "[Placa]\n[|%s|]", CarrosInfo[h][cPlaca]);
  332.         Placa[h] = Create3DTextLabel(result, 0xFFFFFFFF, 0.0, 0.0, 0.0, 50.0, -1, 0);
  333.         Attach3DTextLabelToVehicle(Placa[h], h, 0.0, -2.9, 0.0);
  334.     }
  335.     // TextDraws do Velocímetro
  336.     Black0 = TextDrawCreate(537.000000,133.000000," ");
  337.     Black1 = TextDrawCreate(537.000000,133.000000," ");
  338.     Black2 = TextDrawCreate(537.000000,170.000000," ");
  339.     Black3 = TextDrawCreate(593.000000,133.000000," ");
  340.     LightBlack = TextDrawCreate(541.000000,136.000000," ");
  341.     TextDrawUseBox(Black0,1);
  342.     TextDrawBoxColor(Black0,0x000000ff);
  343.     TextDrawTextSize(Black0,593.000000,0.000000);
  344.     TextDrawUseBox(Black1,1);
  345.     TextDrawBoxColor(Black1,0x000000ff);
  346.     TextDrawTextSize(Black1,537.000000,0.000000);
  347.     TextDrawUseBox(Black2,1);
  348.     TextDrawBoxColor(Black2,0x000000ff);
  349.     TextDrawTextSize(Black2,593.000000,0.000000);
  350.     TextDrawUseBox(Black3,1);
  351.     TextDrawBoxColor(Black3,0x000000ff);
  352.     TextDrawTextSize(Black3,593.000000,0.000000);
  353.     TextDrawUseBox(LightBlack,1);
  354.     TextDrawBoxColor(LightBlack,0x00000033);
  355.     TextDrawTextSize(LightBlack,589.000000,0.000000);
  356.     TextDrawAlignment(Black0,0);
  357.     TextDrawAlignment(Black1,0);
  358.     TextDrawAlignment(Black2,0);
  359.     TextDrawAlignment(Black3,0);
  360.     TextDrawAlignment(LightBlack,0);
  361.     TextDrawBackgroundColor(Black0,0x000000ff);
  362.     TextDrawBackgroundColor(Black1,0x000000ff);
  363.     TextDrawBackgroundColor(Black2,0x000000ff);
  364.     TextDrawBackgroundColor(Black3,0x000000ff);
  365.     TextDrawBackgroundColor(LightBlack,0x000000ff);
  366.     TextDrawFont(Black0,3);
  367.     TextDrawLetterSize(Black0,1.000000,-0.000000);
  368.     TextDrawFont(Black1,3);
  369.     TextDrawLetterSize(Black1,1.300000,4.000000);
  370.     TextDrawFont(Black2,3);
  371.     TextDrawLetterSize(Black2,11.100000,-0.000000);
  372.     TextDrawFont(Black3,3);
  373.     TextDrawLetterSize(Black3,1.000000,4.099998);
  374.     TextDrawFont(LightBlack,3);
  375.     TextDrawLetterSize(LightBlack,1.000000,3.399999);
  376.     TextDrawColor(Black0,0xffffffff);
  377.     TextDrawColor(Black1,0xffffffff);
  378.     TextDrawColor(Black2,0xffffffff);
  379.     TextDrawColor(Black3,0xffffffff);
  380.     TextDrawColor(LightBlack,0xffffffff);
  381.     TextDrawSetOutline(Black0,1);
  382.     TextDrawSetOutline(Black1,1);
  383.     TextDrawSetOutline(Black2,1);
  384.     TextDrawSetOutline(Black3,1);
  385.     TextDrawSetOutline(LightBlack,1);
  386.     TextDrawSetProportional(Black0,1);
  387.     TextDrawSetProportional(Black1,1);
  388.     TextDrawSetProportional(Black2,1);
  389.     TextDrawSetProportional(Black3,1);
  390.     TextDrawSetProportional(LightBlack,1);
  391.     TextDrawSetShadow(Black0,1);
  392.     TextDrawSetShadow(Black1,1);
  393.     TextDrawSetShadow(Black2,1);
  394.     TextDrawSetShadow(Black3,1);
  395.     TextDrawSetShadow(LightBlack,1);
  396.     SetTimer("DashBoard", 50, 1);
  397.     return 0;
  398. }
  399.  
  400. public OnPlayerConnect(playerid)
  401. {
  402.    J_Carregar(playerid);
  403.    return 1;
  404. }
  405.  
  406. forward DashBoard();
  407. public DashBoard()
  408. {
  409.     for(new i=0; i<MAX_PLAYERS; i++)
  410.     {
  411.         if(IsPlayerConnected(i))
  412.         {
  413.             if(IsPlayerInAnyVehicle(i))
  414.             {
  415.                 if(TextShow[i] == false)
  416.                 {
  417.                     TextDrawShowForPlayer(i, Text:Black0);
  418.                     TextDrawShowForPlayer(i, Text:Black1);
  419.                     TextDrawShowForPlayer(i, Text:Black2);
  420.                     TextDrawShowForPlayer(i, Text:Black3);
  421.                     TextDrawShowForPlayer(i, Text:LightBlack);
  422.                     TextShow[i] = true;
  423.                 }
  424.                 new String[128];
  425.                 new Float:X, Float:Y, Float:Z, Float:Speed;
  426.                 GetVehicleVelocity(GetPlayerVehicleID(i), X, Y, Z);
  427.                 Speed = floatmul(floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))), 100.0), 1.5);
  428.                 format(String,sizeof(String),"~b~Velocimetro~n~~r~Velocidade~n~~r~KM/H: ~w~%i", floatround(Speed, floatround_floor));
  429.                 if(VHSCreated[i] == true)
  430.                 {
  431.                     TextDrawDestroy(VHS[i]);
  432.                 }
  433.                 VHS[i] = TextDrawCreate(541.000000,137.000000,String);
  434.                 TextDrawAlignment(VHS[i],0);
  435.                 TextDrawBackgroundColor(VHS[i],0x000000ff);
  436.                 TextDrawFont(VHS[i],1);
  437.                 TextDrawLetterSize(VHS[i],0.299999,1.000000);
  438.                 TextDrawColor(VHS[i],0xffffffff);
  439.                 TextDrawSetOutline(VHS[i],1);
  440.                 TextDrawSetProportional(VHS[i],1);
  441.                 TextDrawSetShadow(VHS[i],1);
  442.                 TextDrawShowForPlayer(i, VHS[i]);
  443.                 VHSCreated[i] = true;
  444.  
  445.             }
  446.             else
  447.             {
  448.                 if(TextShow[i] == true)
  449.                 {
  450.                     TextDrawHideForPlayer(i, Text:Black0);
  451.                     TextDrawHideForPlayer(i, Text:Black1);
  452.                     TextDrawHideForPlayer(i, Text:Black2);
  453.                     TextDrawHideForPlayer(i, Text:Black3);
  454.                     TextDrawHideForPlayer(i, Text:LightBlack);
  455.                     TextDrawHideForPlayer(i, Text:VHS[i]);
  456.                     TextShow[i] = false;
  457.                 }
  458.             }
  459.         }
  460.     }
  461. }
  462.  
  463. public OnFilterScriptExit()
  464. {
  465.     SalvarCarros();
  466.     for(new h = 0; h < sizeof(CarrosInfo); h++)
  467.     {
  468.         DestroyVehicle(h);
  469.         Delete3DTextLabel(Placa[h]);
  470.     }
  471.     return 1;
  472. }
  473.  
  474. public OnPlayerCommandText(playerid, cmdtext[])
  475. {
  476.     new cmd[128], nome[MAX_PLAYER_NAME], preco[128], modelo[128], idx;
  477.     cmd = strtok(cmdtext, idx);
  478.     if(strcmp(cmdtext, "/meucarro", true) == 0)
  479.     {
  480.         if(GetPlayerVehicleID(playerid) == JogadorDataBase[playerid][jChaveDoCarro])
  481.         {
  482.             ShowPlayerDialog(playerid, 100, DIALOG_STYLE_LIST, "Meu Carro", "Placa\nEstacionar\nTrancar", "Acessar", "Cancelar");
  483.             return 1;
  484.         }
  485.         else
  486.         {
  487.             SendClientMessage(playerid, 0xFFFFFFFF, "Você não tem um carro, ou não está nele!");
  488.             return 1;
  489.         }
  490.     }
  491.     if(strcmp(cmd, "/carros", true) == 0)
  492.     {
  493.         nome = strtok(cmdtext, idx);
  494.         if(!strlen(nome)) return SendClientMessage(playerid, 0xFFFFFF, "Uso: /carros [nome] [preço] [modelo]");
  495.         preco = strtok(cmdtext, idx);
  496.         if(!strlen(preco)) return SendClientMessage(playerid, 0xFFFFFF, "Uso: /carros [nome] [preço] [modelo]");
  497.         new price = strval(preco);
  498.         modelo = strtok(cmdtext, idx);
  499.         if(!strlen(modelo)) return SendClientMessage(playerid, 0xFFFFFF, "Uso: /carros [nome] [preço] [modelo]");
  500.         new model = strval(modelo);
  501.         Concessionaria(playerid, nome, price, model, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO)
  502.     }
  503.     if(strcmp(cmdtext, "/concessionaria", true) == 0)
  504.     {
  505.         ShowPlayerDialog(playerid, 10, DIALOG_STYLE_LIST, "Concessionária", "Suvs & Vans\nSedans & Compactos\nSedans de Luxo\nMuscle Cars\nCarros de Rua\nCarros Esporte\nCaminhões, Utilitários e Picapes\nLowriders\nBicicletas e Motocicletas", "Acessar", "Cancelar");
  506.         return 1;
  507.     }
  508.     if(strcmp(cmdtext, "/irconcessionaria", true) == 0)
  509.     {
  510.         SetPlayerPos(playerid, SPAWN_X, SPAWN_Y, SPAWN_Z);
  511.         return 1;
  512.     }
  513.     return 0;
  514. }
  515.  
  516. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  517. {
  518.     new playername[MAX_PLAYER_NAME];
  519.     if(IsPlayerConnected(playerid))
  520.     {
  521.         if(dialogid == 100)
  522.         {
  523.             if(response)
  524.             {
  525.                 if(listitem == 0)
  526.                 {
  527.                     ShowPlayerDialog(playerid, 101,DIALOG_STYLE_INPUT, "Minha Placa", "Digite aqui o texto de sua placa!", "Aceitar", "Cancelar");
  528.                     return 1;
  529.                 }
  530.                 if(listitem == 1)
  531.                 {
  532.                     new Float:x,Float:y,Float:z;
  533.                     new Float:a;
  534.                     new carid;
  535.                     new getcarid;
  536.                     carid = JogadorDataBase[playerid][jChaveDoCarro];
  537.                     getcarid = GetPlayerVehicleID(playerid);
  538.                     GetPlayerName(playerid, playername, sizeof(playername));
  539.                     GetVehiclePos(carid, x, y, z);
  540.                     GetVehicleZAngle(carid, a);
  541.                     if(IsPlayerInVehicle(playerid,carid) && CarrosInfo[carid][cComprado] == 1)
  542.                     {
  543.                         if(carid != getcarid)
  544.                         {
  545.                             SendClientMessage(playerid, 0xFFFFFFFF, "Você não tem um carro, ou não está nele!");
  546.                             return 1;
  547.                         }
  548.                         if(getcarid == carid)
  549.                         {
  550.                             CarrosInfo[carid][cx] = x;
  551.                             CarrosInfo[carid][cy] = y;
  552.                             CarrosInfo[carid][cz] = z;
  553.                             CarrosInfo[carid][cangulo] = a;
  554.                             GameTextForPlayer(playerid, "Voce acaba de estacionar seu carro nessa posicao!", 1000, 3);
  555.                             SalvarCarros();
  556.                             DestroyVehicle(carid);
  557.                             CreateVehicle(CarrosInfo[carid][cModelo],CarrosInfo[carid][cx],CarrosInfo[carid][cy],CarrosInfo[carid][cz]+1.0,CarrosInfo[carid][cangulo],CarrosInfo[carid][cCor1],CarrosInfo[carid][cCor2],60000);
  558.                             TogglePlayerControllable(playerid, 1);
  559.                             return 1;
  560.                         }
  561.                     }
  562.                 }
  563.                 if(listitem == 2)
  564.                 {
  565.                     new CarKey = JogadorDataBase[playerid][jChaveDoCarro];
  566.                     if(CarKey == CarrosInfo[CarKey][cRegistrado])
  567.                     {
  568.                         if(CarrosInfo[CarKey][cTrava] == 1)
  569.                         {
  570.                            for(new i = 0; i < MAX_PLAYERS; i++)
  571.                            {
  572.                                 if (IsPlayerConnected(i))
  573.                                 {
  574.                                     SetVehicleParamsForPlayer(CarKey,i,0,0);
  575.                                 }
  576.                            }
  577.                            GameTextForPlayer(playerid, "~w~Carro~n~~g~Destrancado", 4000, 3);
  578.                            CarrosInfo[CarKey][cTrava] = 0;
  579.                            SalvarCarros();
  580.                            return 1;
  581.                        }
  582.                        else if(CarrosInfo[CarKey][cTrava] == 0)
  583.                        {
  584.                            for(new i = 0; i < MAX_PLAYERS; i++)
  585.                            {
  586.                                if (IsPlayerConnected(i))
  587.                                {
  588.                                     SetVehicleParamsForPlayer(CarKey,i,0,1);
  589.                                }
  590.                            }
  591.                            GameTextForPlayer(playerid, "~w~Carro~n~~r~trancado", 4000, 3);
  592.                            CarrosInfo[CarKey][cTrava] = 1;
  593.                            SalvarCarros();
  594.                            return 1;
  595.                         }
  596.                         else
  597.                         {
  598.                             SendClientMessage(playerid, 0xFFFFFFFF, " Você não está perto de seu carro, ou não tem um carro!");
  599.                             return 1;
  600.                         }
  601.                    }
  602.                 }
  603.             }
  604.         }
  605.         if(dialogid == 101)
  606.         {
  607.             if(response)
  608.             {
  609.                 new plate[128], inputtext0[255];
  610.                 new carid = GetPlayerVehicleID(playerid);
  611.                 format(inputtext0, sizeof(inputtext0), "%s", inputtext);
  612.                 strmid(gPlaca[playerid], inputtext0, 0, 254, 255);
  613.                 strmid(JogadorDataBase[playerid][jPlaca], inputtext, 0, 127);
  614.                 strmid(CarrosInfo[carid][cPlaca], inputtext, 0, 29);
  615.                 J_Salvar(playerid);
  616.                 SalvarCarros();
  617.                 format(plate, sizeof(plate), "Você digitou o texto: %s", inputtext);
  618.                 SendClientMessage(playerid, 0xFFFFFFFF, plate);
  619.                 Placa[carid] = Create3DTextLabel(inputtext, 0xFFFFFFFF, 0.0, 0.0, 0.0, 60, -1, 0);
  620.                 Attach3DTextLabelToVehicle(Placa[carid], carid, 0.0, -2.9, 0.0);
  621.                 ShowPlayerDialog(playerid, 102, DIALOG_STYLE_LIST,"Cores de Placa", "Marrom\nPreto\nAzul\nVerde\nBranco\nVermelho\nAmarelo\nAzul Claro\nVerde Escuro", "Selecionar", "Sair");
  622.             }
  623.             return 1;
  624.         }
  625.         if(dialogid == 102)
  626.         {
  627.             if(response)
  628.             {
  629.                 new carid = GetPlayerVehicleID(playerid);
  630.                 new result[200];
  631.                 format(result, sizeof(result), "[Placa]\n[|%s|]", gPlaca[playerid]);
  632.                 if(listitem == 0)
  633.                 {
  634.                     Update3DTextLabelText(Placa[carid], 0x6D3636FF, result);
  635.                 }
  636.                 if(listitem == 1)
  637.                 {
  638.                     Update3DTextLabelText(Placa[carid], 0x000000FF, result);
  639.                 }
  640.                 if(listitem == 2)
  641.                 {
  642.                     Update3DTextLabelText(Placa[carid], 0x2828FFFF, result);
  643.                 }
  644.                 if(listitem == 3)
  645.                 {
  646.                     Update3DTextLabelText(Placa[carid], 0x00C10AFF, result);
  647.                 }
  648.                 if(listitem == 4)
  649.                 {
  650.                     Update3DTextLabelText(Placa[carid], 0xFFFFFFFF, result);
  651.                 }
  652.                 if(listitem == 5)
  653.                 {
  654.                     Update3DTextLabelText(Placa[carid], 0xFF0006FF, result);
  655.                 }
  656.                 if(listitem == 6)
  657.                 {
  658.                     Update3DTextLabelText(Placa[carid], 0xFFFF00FF, result);
  659.                 }
  660.                 if(listitem == 7)
  661.                 {
  662.                     Update3DTextLabelText(Placa[carid], 0x00FFFFFF, result);
  663.                 }
  664.                 if(listitem == 8)
  665.                 {
  666.                     Update3DTextLabelText(Placa[carid], 0x008000FF, result);
  667.                 }
  668.                 Attach3DTextLabelToVehicle(Placa[GetPlayerVehicleID(playerid)], carid, 0.0,-2.9,0.0);
  669.                 SendClientMessage(playerid, 0xFFFFFFFF, "PARABÉNS! Sua placa está completa e instalada!");
  670.             }
  671.             return 1;
  672.         }
  673.         if(dialogid == 10)
  674.         {
  675.             if(response)
  676.             {
  677.                 if (listitem == 0)
  678.                 {
  679.                     Concessionaria(playerid, "Infernus", Car_Infernus, 411, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO);
  680.                 }
  681.                 if(listitem == 1)
  682.                 {
  683.                     Concessionaria(playerid, "Cheetah", Car_Cheetah, 415, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO);
  684.                 }
  685.                 if(listitem == 2)
  686.                 {
  687.                     Concessionaria(playerid, "Banshee", Car_Banshee, 429, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO);
  688.                 }
  689.                 if(listitem == 3)
  690.                 {
  691.                     Concessionaria(playerid, "Hotknife", Car_Hotknife, 434, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO);
  692.                 }
  693.                 if(listitem == 4)
  694.                 {
  695.                     Concessionaria(playerid, "Turismo", Car_Turismo, 451, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO);
  696.                 }
  697.                 if(listitem == 5)
  698.                 {
  699.                     Concessionaria(playerid, "ZR 350", Car_ZR_350, 477, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO);
  700.                 }
  701.                 if(listitem == 6)
  702.                 {
  703.                     Concessionaria(playerid, "Comet", Car_Comet, 480, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO);
  704.                 }
  705.                 if (listitem == 7)
  706.                 {
  707.                     Concessionaria(playerid, "Super GT", Car_Super_GT, 506, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO);
  708.                 }
  709.                 if (listitem == 8)
  710.                 {
  711.                     Concessionaria(playerid, "Windsor", Car_Windsor, 555, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO);
  712.                 }
  713.                 if (listitem == 9)
  714.                 {
  715.                     Concessionaria(playerid, "Feltzer", Car_Feltzer, 533, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO);
  716.                 }
  717.                 if (listitem == 10)
  718.                 {
  719.                     Concessionaria(playerid, "Euros", Car_Euros, 587, SPAWN_X, SPAWN_Y, SPAWN_Z, ANGULO);
  720.                 }
  721.             }
  722.         }
  723.     }
  724.     else
  725.     {
  726.        return 0;
  727.     }
  728.     return 1;
  729. }
Advertisement
Add Comment
Please, Sign In to add comment