Advertisement
Hardware

Sistema de Posto - 1.1

May 5th, 2015
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 15.84 KB | None | 0 0
  1.  /*
  2.                          ~~~~~~~~~~~~~~~~ • Sistema de Posto •  ~~~~~~~~~~~~~~~~
  3.  
  4.  
  5.                                         » Autor: Deus;
  6.                                         » Programador: Bryan (Hardware);
  7.                                         » Ideia: Wendell Rocha.
  8.  
  9.  
  10.                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11.  
  12.  
  13. */
  14. #include <a_samp>
  15. #include <sscanf2>
  16. #include <zcmd>
  17. #include <cpstream>
  18.  
  19. #define PrecoGNV            1.70
  20. #define PrecoGasC           2.45
  21. #define PrecoGasA           2.50
  22. #define PrecoDiesel         2.10
  23. #define PrecoEtanol         2.00
  24.  
  25. #define DialogCombustivel   7
  26. #define DialogGNV           8
  27. #define DialogGasC          9
  28. #define DialogGasA          10
  29. #define DialogDiesel        11
  30. #define DialogEtanol        12
  31.  
  32. #define ExtratoCombustivel  13
  33.  
  34. #undef MAX_PLAYERS
  35. #define MAX_PLAYERS 50
  36.  
  37. enum TiposC
  38. {
  39.     GNV,
  40.     GasolinaC,
  41.     GasolinaA,
  42.     Diesel,
  43.     Etanol
  44. };
  45. new TCombustivel[MAX_VEHICLES][TiposC];
  46.  
  47. new Float:CoordPostos[3][3] = {
  48.     {2115.5330,928.2172,10.8203},
  49.     {1936.8785,-1769.0784,13.3828},
  50.     {2557.9978,2194.5671,10.8203}
  51. };
  52.  
  53. new bool:CilindroGNV[MAX_PLAYERS];
  54. new CheckCilindro;
  55.  
  56. public OnFilterScriptInit()
  57. {
  58.     print("\n\n~~~~~~~~~~ Sistema Combustível carregado! ~~~~~~~~~~");
  59.     print("» Programador: Bryan (Hardware)");
  60.     print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  61.  
  62.     CheckCilindro = CPS_AddCheckpoint(1352.2036,-1758.7800,13.5078,2.0,80);
  63.     return 1;
  64. }
  65.  
  66. public OnFilterScriptExit()
  67. {
  68.     print("~~~~~~~~~~ Sistema Combustível descarregado ~~~~~~~~~~");
  69.     return 1;
  70. }
  71.  
  72. public OnPlayerSpawn(playerid) {
  73.     SetTimerEx("PlayerNoPosto",2000,true, "d", playerid);
  74. }
  75.  
  76. public OnPlayerEnterCheckpoint(playerid)
  77. {
  78.     if(CPS_IsPlayerInCheckpoint(playerid,CheckCilindro))
  79.     {
  80.         SendClientMessage(playerid,-1,"| INFO | Digite /comprarcilindro");
  81.         SendClientMessage(playerid,-1,"| INFO | Valor: R$ 750,00.");
  82.     }
  83.     return 1;
  84. }
  85.  
  86. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  87. {
  88.     new vehicleid = GetPlayerVehicleID(playerid);
  89.     new Valor,Float:Gastou,sGas[100];
  90.     if(dialogid == DialogCombustivel)
  91.     {
  92.         if(response)
  93.         {
  94.             if(listitem == 0)
  95.             {
  96.                 if(!CilindroGNV[playerid]) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Para abastecer GNV, precisar ter o Cilíndro antes!");
  97.                 if((Aeronaves(vehicleid) || Motocicletas(vehicleid))) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Este veículo não pode ser abastecido de GNV!");
  98.                 ShowPlayerDialog(playerid,DialogGNV,DIALOG_STYLE_INPUT,"- Gás Natural Veicular (GNV)","{FF8080}Obs:O GNV é medido por cm³. Então, 1000 cm³ = 1 Litro.\n{FFFFFF}Digite a quantidade que deseja de GNV:","Confirmar","Sair");
  99.             }
  100.             if(listitem == 1)
  101.             {
  102.                 ShowPlayerDialog(playerid,DialogGasC,DIALOG_STYLE_INPUT,"- Gasolina Comum","{FFFFFF}Digite a quantidade de Gasolina Comum:","Confirmar","Sair");
  103.             }
  104.             if(listitem == 2)
  105.             {
  106.                 ShowPlayerDialog(playerid,DialogGasA,DIALOG_STYLE_INPUT,"- Gasolina Aditivada","{FFFFFF}Digite a quantidade Gasolina Aditivada:","Confirmar","Sair");
  107.             }
  108.             if(listitem == 3)
  109.             {
  110.                 if(VeiculoDiesel(vehicleid))
  111.                 {
  112.                     ShowPlayerDialog(playerid,DialogDiesel,DIALOG_STYLE_INPUT,"- Diesel","{FFFFFF}Digite a quantidade de Diesel:","Confirmar","Sair");
  113.                 }
  114.                 else
  115.                 {
  116.                     SendClientMessage(playerid,0xFF0000AA,"| ERRO | O combustível Diesel é somente para caminhões, ônibus e vans.");
  117.                 }
  118.             }
  119.             if(listitem == 4)
  120.             {
  121.                 if(Aeronaves(vehicleid)) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Este veículo não pode ser abastecido de Etanol!");
  122.                 ShowPlayerDialog(playerid,DialogEtanol,DIALOG_STYLE_INPUT,"- Etanol","{FFFFFF}Digite a quantidade de Etanol:","Confirmar","Sair");
  123.             }
  124.         }
  125.     }
  126.     if(dialogid == DialogGNV)
  127.     {
  128.         Valor = strval(inputtext);
  129.         if(Valor > 80) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Valor máximo para abastecer GNV é de 80cm³/80Litros");
  130.         else if(TCombustivel[vehicleid][GNV] + Valor > 80 ) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Desculpe, mas você já está com o cilíndro cheio!");
  131.         if(Valor < 0) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não pode abastecer um valor negativo!");
  132.         Gastou = Valor * PrecoGNV;
  133.         if(GetPlayerMoney(playerid) < Gastou) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não tem dinheiro suficiente!");
  134.         format(sGas,sizeof sGas,"{FFFFFF}Você tinha {8080FF}%d{FFFFFF} e abasteceu {8080FF}%d. {FFFFFF}Valor pago: {8080FF}R$ %d", TCombustivel[vehicleid][GNV],Valor,floatround(Gastou,floatround_round));
  135.         ShowPlayerDialog(playerid,ExtratoCombustivel,DIALOG_STYLE_MSGBOX,"Extrato do combustível",sGas,"Fechar","");
  136.         TCombustivel[vehicleid][GNV] += Valor;
  137.         GivePlayerMoney(playerid, floatround(Gastou,floatround_round));
  138.         return 1;
  139.     }
  140.     if(dialogid == DialogGasC)
  141.     {
  142.         Valor = strval(inputtext);
  143.         if(Motocicletas(vehicleid))
  144.         {
  145.             if(Valor > 50) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Valor máximo para abastecer uma Motocicleta é 50Litros!");
  146.             if(TCombustivel[vehicleid][GasolinaC] + Valor > 50) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Desculpe, mas você já está com o tanque cheio!");
  147.         }
  148.         else if(Aeronaves(vehicleid))
  149.         {
  150.             if(Valor > 350) SendClientMessage(playerid,0xFF0000AA,"| ERRO | Valor máximo para abastecer uma Aeronave é 350 Litros!");
  151.             if(TCombustivel[vehicleid][GasolinaC] + Valor > 350) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Desculpe, mas você já está com o tanque cheio!");
  152.         }
  153.         else
  154.         {
  155.             if(Valor > 100) SendClientMessage(playerid,0xFF0000AA,"| ERRO | Valor máximo para abastecer um Automóvel é 100 Litros!");
  156.             if(TCombustivel[vehicleid][GasolinaC] + Valor > 100) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Desculpe, mas você já está com o tanque cheio!");
  157.         }
  158.         if(Valor < 0) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não pode abastecer um valor negativo!");
  159.         Gastou = Valor * PrecoGasC;
  160.         if(GetPlayerMoney(playerid) < Gastou) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não tem dinheiro suficiente!");
  161.         format(sGas,sizeof sGas,"{FFFFFF}Você tinha {8080FF}%d{FFFFFF} e abasteceu {8080FF}%d. {FFFFFF}Valor pago: {8080FF}R$ %d", TCombustivel[vehicleid][GasolinaC],Valor,floatround(Gastou,floatround_round));
  162.         ShowPlayerDialog(playerid,ExtratoCombustivel,DIALOG_STYLE_MSGBOX,"Extrato do combustível",sGas,"Fechar","");
  163.         TCombustivel[vehicleid][GasolinaC] += Valor;
  164.         GivePlayerMoney(playerid, floatround(Gastou,floatround_round));
  165.         return 1;
  166.     }
  167.     if(dialogid == DialogGasA)
  168.     {
  169.         Valor = strval(inputtext);
  170.         if(Motocicletas(vehicleid))
  171.         {
  172.             if(Valor > 50) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Valor máximo para abastecer uma Motocicleta é 50Litros!");
  173.             if(TCombustivel[vehicleid][GasolinaA] + Valor > 50) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Desculpe, mas você já está com o tanque cheio!");
  174.         }
  175.         else if(Aeronaves(vehicleid))
  176.         {
  177.             if(Valor > 350) SendClientMessage(playerid,0xFF0000AA,"| ERRO | Valor máximo para abastecer uma Aeronave é 350 Litros!");
  178.             if(TCombustivel[vehicleid][GasolinaA] + Valor > 350) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Desculpe, mas você já está com o tanque cheio!");
  179.         }
  180.         else
  181.         {
  182.             if(Valor > 100) SendClientMessage(playerid,0xFF0000AA,"| ERRO | Valor máximo para abastecer um Automóvel é 100 Litros!");
  183.             if(TCombustivel[vehicleid][GasolinaA] + Valor > 100) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Desculpe, mas você já está com o tanque cheio!");
  184.         }
  185.         if(Valor < 0) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não pode abastecer um valor negativo!");
  186.         Gastou = Valor * PrecoGasA;
  187.         if(GetPlayerMoney(playerid) < Gastou) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não tem dinheiro suficiente!");
  188.         format(sGas,sizeof sGas,"{FFFFFF}Você tinha {8080FF}%d{FFFFFF} e abasteceu {8080FF}%d. {FFFFFF}Valor pago: {8080FF}R$ %d", TCombustivel[vehicleid][GasolinaA],Valor,floatround(Gastou,floatround_round));
  189.         ShowPlayerDialog(playerid,ExtratoCombustivel,DIALOG_STYLE_MSGBOX,"Extrato do combustível",sGas,"Fechar","");
  190.         TCombustivel[vehicleid][GasolinaA] += Valor;
  191.         GivePlayerMoney(playerid, floatround(Gastou,floatround_round));
  192.         return 1;
  193.     }
  194.     if(dialogid == DialogDiesel)
  195.     {
  196.         Valor = strval(inputtext);
  197.         if(Valor > 150) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Valor máximo para abastecer um caminhão, ônibus e afins é 150 Litros!");
  198.         if(TCombustivel[vehicleid][Diesel] + Valor > 150) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Desculpe, mas você já está com o tanque cheio!");
  199.         if(Valor < 0) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não pode abastecer um valor negativo!");
  200.         Gastou = Valor * PrecoDiesel;
  201.         if(GetPlayerMoney(playerid) < Gastou) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não tem dinheiro suficiente!");
  202.         format(sGas,sizeof sGas,"{FFFFFF}Você tinha {8080FF}%d{FFFFFF} e abasteceu {8080FF}%d. {FFFFFF}Valor pago: {8080FF}R$ %d", TCombustivel[vehicleid][Diesel],Valor,floatround(Gastou,floatround_round));
  203.         ShowPlayerDialog(playerid,ExtratoCombustivel,DIALOG_STYLE_MSGBOX,"Extrato do combustível",sGas,"Fechar","");
  204.         TCombustivel[vehicleid][Diesel] += Valor;
  205.         GivePlayerMoney(playerid, floatround(Gastou,floatround_round));
  206.         return 1;
  207.     }
  208.     if(dialogid == DialogEtanol)
  209.     {
  210.         Valor = strval(inputtext);
  211.         if(Motocicletas(vehicleid))
  212.         {
  213.             if(Valor > 50) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Valor máximo para abastecer uma Motocicleta é 50Litros!");
  214.             if(TCombustivel[vehicleid][Etanol] + Valor > 50) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Desculpe, mas você já está com o tanque cheio!");
  215.         }
  216.         else
  217.         {
  218.             if(Valor > 100) return  SendClientMessage(playerid,0xFF0000AA,"| ERRO | Valor máximo para abastecer um Automóvel é 100 Litros!");
  219.             if(TCombustivel[vehicleid][Etanol] + Valor > 100) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Desculpe, mas você já está com o tanque cheio!");
  220.         }
  221.         if(Valor < 0) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não pode abastecer um valor negativo!");
  222.         Gastou = Valor * PrecoEtanol;
  223.         if(GetPlayerMoney(playerid) < Gastou) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não tem dinheiro suficiente!");
  224.         format(sGas,sizeof sGas,"{FFFFFF}Você tinha {8080FF}%d{FFFFFF} e abasteceu {8080FF}%d. {FFFFFF}Valor pago: {8080FF}R$ %d", TCombustivel[vehicleid][Etanol],Valor,floatround(Gastou,floatround_round));
  225.         ShowPlayerDialog(playerid,ExtratoCombustivel,DIALOG_STYLE_MSGBOX,"Extrato do combustível",sGas,"Fechar","");
  226.         TCombustivel[vehicleid][Etanol] += Valor;
  227.         GivePlayerMoney(playerid, floatround(Gastou,floatround_round));
  228.         return 1;
  229.     }
  230.     return 1;
  231. }
  232. CMD:abastecer(playerid,params[])
  233. {
  234.     new vehicleid = GetPlayerVehicleID(playerid);
  235.     for(new y=0; y < sizeof(CoordPostos); y++) {
  236.         if(IsPlayerInRangeOfPoint(playerid,15.0,CoordPostos[y][0],CoordPostos[y][1],CoordPostos[y][2]))
  237.         {
  238.             if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não está em um veículo!");
  239.             if(Bicicleta(vehicleid)) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Não pode abastecer uma bicicleta!");
  240.             ShowPlayerDialog(playerid,DialogCombustivel,DIALOG_STYLE_LIST,"Tipos de Combustíveis","- Gás Natural Veicular (GNV)\n- Gasolina Comum\n- Gasolina Aditivada\n- Diesel\n- Etanol","Escolher","Sair");
  241.         }
  242.     }
  243.     return 1;
  244. }
  245. CMD:tabelapreco(playerid,params[])
  246. {
  247.     SendClientMessage(playerid,0xFFFFFFAA,"~~~~~~~{FF8040} Tabela de preços {FFFFFF}~~~~~~~");
  248.     SendClientMessage(playerid,0xFFFFFFAA,"• Gás Natural Veicular(GNV):{808080} R$ 1,70");
  249.     SendClientMessage(playerid,0xFFFFFFAA,"• Gasolina Comum:{808080} R$ 2,45");
  250.     SendClientMessage(playerid,0xFFFFFFAA,"• Gasolina Aditivada:{808080} R$ 2,50");
  251.     SendClientMessage(playerid,0xFFFFFFAA,"• Diesel:{808080} R$ 2,10");
  252.     SendClientMessage(playerid,0xFFFFFFAA,"• Etanol:{808080} R$ 2,00");
  253.     SendClientMessage(playerid,0xFFFFFFAA,"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  254.     return 1;
  255. }
  256.  
  257. // Comandos para ir até as coordenadas dos Postos
  258. CMD:irposto(playerid,params[])
  259. {
  260.     SetPlayerPos(playerid,1936.8785,-1769.0784,13.3828);
  261.     SetPlayerFacingAngle(playerid,191.1616);
  262.     SetPlayerInterior(playerid,0);
  263.     return 1;
  264. }
  265. CMD:irposto2(playerid,params[]) {
  266.     SetPlayerPos(playerid, 2115.5330,928.2172,10.8203);
  267.     SetPlayerInterior(playerid,0);
  268.     return 1;
  269. }
  270.  
  271. CMD:irposto3(playerid,params[]) {
  272.     SetPlayerPos(playerid, 2557.9978,2194.5671,10.8203);
  273.     SetPlayerInterior(playerid,0);
  274.     return 1;
  275. }
  276.  
  277. //Comando para ir na coordenada do checkpoint
  278. CMD:ircilindro(playerid,params[])
  279. {
  280.     SetPlayerPos(playerid,1348.3889,-1758.0930,13.5078);
  281.     SetPlayerFacingAngle(playerid,179.5847);
  282.     SetPlayerInterior(playerid,0);
  283.     return 1;
  284. }
  285. CMD:criarveiculo(playerid,params[]) {
  286.     new Float:a[4];
  287.     GetPlayerFacingAngle(playerid,a[3]);
  288.     GetPlayerPos(playerid,a[0], a[1], a[2]);
  289.     CreateVehicle(522, a[0], a[1], a[2],a[3], -1, -1, 10000);
  290.     return 1;
  291. }
  292. CMD:comprarcilindro(playerid,params[])
  293. {
  294.     if(!CPS_IsPlayerInCheckpoint(playerid,CheckCilindro)) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não está no Checkpoint!");
  295.     if(GetPlayerMoney(playerid) < 750) return SendClientMessage(playerid,0xFF0000AA,"| ERRO | Você não tem dinheiro suficiente!");
  296.     CilindroGNV[playerid] = true;
  297.     SendClientMessage(playerid,0x008040AA,"| INFO | Parabéns, você adquiriu um cilíndro de 'Gás Natural Veicular' (GNV)!");
  298.     GivePlayerMoney(playerid,-750);
  299.     return 1;
  300. }
  301. stock Motocicletas(vehicleid)
  302. {
  303.     switch(GetVehicleModel(vehicleid))
  304.     {
  305.         case 461,462,463,468,471,521,522,523,581,586: return 1;
  306.     }
  307.     return 0;
  308. }
  309. stock Aeronaves(vehicleid)
  310. {
  311.     switch(GetVehicleModel(vehicleid))
  312.     {
  313.         case 593,592,577,563,553,548,520,519,513, 512,511,497,488,487,476,469,460,447,425,417:return 1;
  314.     }
  315.     return 0;
  316. }
  317. stock Bicicleta(vehicleid)
  318. {
  319.     switch(GetVehicleModel(vehicleid))
  320.     {
  321.         case 481,509,510:return 1;
  322.     }
  323.     return 0;
  324. }
  325. stock VeiculoDiesel(vehicleid)
  326. {
  327.     switch(GetVehicleModel(vehicleid))
  328.     {
  329.         case 403,406,407,408,414,416,423,427,428,433,437,444,455,456,498,499,508,514,515,524,525,544,552,556,557,573,578,681,609: return 1;
  330.     }
  331.     return 0;
  332. }
  333. forward PlayerNoPosto(playerid);
  334. public PlayerNoPosto(playerid)
  335. {
  336.     for(new i = 0; i < sizeof(CoordPostos); i++)
  337.     {
  338.         if(IsPlayerInRangeOfPoint(playerid,20.0,CoordPostos[i][0],CoordPostos[i][1],CoordPostos[i][2]))
  339.         {
  340.             GameTextForPlayer(playerid,"[~r~P~w~osto de ~r~G~w~asolina ~n~ Use ~g~/abastecer",1000,3);
  341.         }
  342.     }
  343.     return 1;
  344. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement