Advertisement
Guest User

Gasolina System

a guest
Dec 14th, 2010
3,977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.20 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define VALOR_LITRO 2.0                           //- Definir valor por litro da gasolina
  4. #define RETIRAR_KM  16                            //- A Cada 16 KM ,retirar 1 de gasolina
  5. #define DIALOG_GAS  24                            //- ID Do Dialog para Colocar Gasolina
  6.  
  7. new
  8. Gasosa[MAX_VEHICLES],
  9. bool:Avisado[500],
  10. Float:velokm[3],
  11. Retirada[500]
  12. ;
  13.  
  14. public OnPlayerCommandText(playerid, cmdtext[])
  15. {
  16.     if(!strcmp(cmdtext, "/gasolina", true)) {
  17.         if(!IsPlayerInAnyVehicle(playerid))
  18.             return SendClientMessage(playerid, 0xFFFFFFFF, "Você não esta em um carro");
  19.         ShowPlayerDialog(playerid,DIALOG_GAS,DIALOG_STYLE_INPUT,"Colocar Gasolina","Por favor digite a quantidade de litros para colocar \n o Preço  atual da Gasolina é 2$ por litro","Sim","Nao");
  20.         return 1;
  21.     }
  22.     return 0;
  23. }
  24.  
  25.  
  26. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  27. {
  28.     if(dialogid == DIALOG_GAS) {
  29.         if(!response)
  30.             return SendClientMessage(playerid, 0xFFFFFFFF, "Você não colocou gasolina");
  31.  
  32.         new sGasolinaT = strval(inputtext),string[64],quantia = sGasolinaT*floatround(VALOR_LITRO);
  33.  
  34.         if(GetPlayerMoney(playerid) < quantia)
  35.             return SendClientMessage(playerid, 0xFFFFFFFF, "Você não tem dinheiro para isto");
  36.  
  37.         if(sGasolinaT > 100 || sGasolinaT <= 0)
  38.             return SendClientMessage(playerid, 0xFFFFFFFF, "Quantia Inválida");
  39.  
  40.         format(string,60, "* Você abastaceu %d Litros por %d$",sGasolinaT,quantia);
  41.         SendClientMessage(playerid,0xFFFF00AA, string);
  42.         Gasosa[GetPlayerVehicleID(playerid)] = sGasolinaT;
  43.         GivePlayerMoney(playerid,-quantia);
  44.         Retirada[playerid] = 0;
  45.         Avisado[playerid] = false;
  46.         TogglePlayerControllable(playerid, true);
  47.         return 1;
  48.     }
  49.     return 0;
  50. }
  51.  
  52.  
  53. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  54. {
  55.     new str[128];
  56.     format(str, sizeof(str), "* Este carro esta com %d Litros de gasolina", Gasosa[vehicleid]);
  57.     SendClientMessage(playerid,0xFFFF00AA, str);
  58.     return 1;
  59.  
  60. }
  61.  
  62.  
  63. public OnPlayerUpdate(playerid)
  64. {
  65.     if(IsPlayerInAnyVehicle(playerid)) {
  66.         new string[50],carid = GetPlayerVehicleID(playerid);
  67.         GetVehicleVelocity(carid, velokm[0], velokm[1], velokm[2]);
  68.         format(string, sizeof(string), "~w~Gasolina: ~r~%i", Gasosa[carid]);
  69.         GameTextForPlayer(playerid,string,300,1);
  70.         if(floatround(((floatsqroot(((velokm[0] * velokm[0]) + (velokm[1] * velokm[1]) + (velokm[2] * velokm[2]))) * (170.0))) * 1) > 5) {
  71.             if(Gasosa[carid] == 0 && Avisado[playerid] == false) {
  72.                 SendClientMessage(playerid,0xFFFF00AA,"A Gasolina Deste carro acabou | Chame o Guincho ou /gasolina");
  73.                 TogglePlayerControllable(playerid, false);
  74.                 Avisado[playerid] = true;
  75.             }
  76.             if(Gasosa[carid] > 0) {
  77.                 Retirada[playerid]+=1;
  78.                 if(Retirada[playerid] >= (RETIRAR_KM*13)) {
  79.                     Gasosa[carid]--;
  80.                     Retirada[playerid]=0;
  81.                     Avisado[playerid] = false;
  82.                 }
  83.             }
  84.         }
  85.     }
  86.     return 1;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement