Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include a_samp
- #include streamer
- #include sscanf2
- #include pawn.cmd
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
- #define function%0(%1) \
- forward%0(%1); public%0(%1)
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
- #define PICKUP_FILL_X 1961.5599
- #define PICKUP_FILL_Y 1342.9359
- #define PICKUP_FILL_Z 15.3746
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
- static const Float:AMOUNT_FILL = 1.0; // Retirar ao encher o galão (1.0)
- static const Float:AMOUNT_REFUEL = 1.0; // Retirar ao abastecer (1.0)
- static const Float:PRICE_PER_LITER = 5.0; // Preço p/Litro ($5)
- static bool:HasGallon[MAX_PLAYERS];
- static Float:VehicleFuel[MAX_VEHICLES]; // Variável da Gasolina
- static Float:GasGallon[MAX_PLAYERS]; // Variável do Galão
- static Float:BuyGas[MAX_PLAYERS];
- static GallonTimer[MAX_VEHICLES] = {-1, ...};
- static GallonFillTimer[MAX_PLAYERS] = {-1, ...};
- main(){}
- public OnGameModeInit()
- {
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 270.0000, 0, 0, 0, 0, 0, 0);
- CreateDynamicMapIcon(PICKUP_FILL_X, PICKUP_FILL_Y, PICKUP_FILL_Z, 55, -1, .streamdistance = 75.0);
- CreateDynamicPickup(1650, 1, PICKUP_FILL_X, PICKUP_FILL_Y, PICKUP_FILL_Z+0.25, .streamdistance = 50.0);
- CreateDynamic3DTextLabel("{1E90FF}Encher Galão\n{FFFFFF}Pressione Y ou (/enchergalao)", -1, PICKUP_FILL_X, PICKUP_FILL_Y, PICKUP_FILL_Z+0.75, 25.0, .testlos = 1);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(HasGallon[playerid])
- {
- ResetFillGallon(playerid);
- GasGallon[playerid] = 0.0;
- HasGallon[playerid] = false;
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- new vehicleid = GetPlayerVehicleID(playerid);
- if((newkeys & KEY_YES) && IsPlayerInRangeOfPoint(playerid, 1.0, PICKUP_FILL_X, PICKUP_FILL_Y, PICKUP_FILL_Z))
- {
- callcmd::enchergalao(playerid);
- // Caso usar zcmd faça: cmd_enchergalao(playerid);
- }
- if(newkeys & KEY_NO)
- {
- if(GallonFillTimer[playerid] != -1)
- {
- ResetFillGallon(playerid);
- TogglePlayerControllable(playerid, true);
- SendClientMessage(playerid, -1, "* Você decidiu parar de encher seu galão de combustível (/usargalao).");
- }
- if(GallonTimer[vehicleid] != -1)
- {
- KillTimer(GallonTimer[vehicleid]);
- GallonTimer[vehicleid] = -1;
- ToggleVehicleEngineState(vehicleid, true);
- SendClientMessage(playerid, -1, "* Você decidiu parar de abastecer esse veículo.");
- }
- }
- return 1;
- }
- function OnFillGallon(playerid)
- {
- if((GasGallon[playerid] += AMOUNT_FILL) >= 100.0)
- {
- GasGallon[playerid] = 100.0;
- ResetFillGallon(playerid);
- TogglePlayerControllable(playerid, true);
- SendClientMessage(playerid, -1, "* Você terminou de encher o seu galão de combustível (/usargalao).");
- return 1;
- }
- if(GetPlayerMoney(playerid) < PRICE_PER_LITER)
- {
- ResetFillGallon(playerid);
- ResetPlayerMoney(playerid);
- TogglePlayerControllable(playerid, true);
- SendClientMessage(playerid, -1, "* Você não possui dinheiro suficiente (/g).");
- return 1;
- }
- new string[64];
- BuyGas[playerid] += AMOUNT_FILL;
- GivePlayerMoney(playerid, -floatround(AMOUNT_FILL * PRICE_PER_LITER));
- format(string, sizeof(string), "~b~~h~Enchendo Galao...~n~~n~~g~$%i ~r~- ~y~%.1fL", floatround(BuyGas[playerid] * PRICE_PER_LITER), GasGallon[playerid]);
- GameTextForPlayer(playerid, string, 500, 3);
- return 1;
- }
- function OnGallonRefuel(vehicleid)
- {
- for(new i, j = GetPlayerPoolSize(); i <= j; ++i)
- {
- if(!GetVehicleEngineState(vehicleid) && IsPlayerInVehicle(i, vehicleid) && GetPlayerVehicleSeat(i) == 0)
- {
- if((VehicleFuel[vehicleid] += AMOUNT_REFUEL) >= 100.0)
- {
- KillTimer(GallonTimer[vehicleid]);
- GallonTimer[vehicleid] = -1;
- VehicleFuel[vehicleid] = 100.0;
- SendClientMessage(i, -1, "* Você encheu todo o tanque do seu veículo.");
- break;
- }
- if((GasGallon[i] -= AMOUNT_REFUEL) <= 0.0)
- {
- KillTimer(GallonTimer[vehicleid]);
- GallonTimer[vehicleid] = -1;
- GasGallon[i] = 0.0;
- ToggleVehicleEngineState(vehicleid, true);
- SendClientMessage(i, -1, "* Seu galão não possui mais gasolina.");
- break;
- }
- new string[70];
- format(string, sizeof(string), "~b~~h~Abastecendo...~n~~n~~r~Tanque: ~w~%.1fL~n~~r~Galao: ~w~%.1fL", VehicleFuel[vehicleid], GasGallon[i]);
- GameTextForPlayer(i, string, 500, 3);
- }
- }
- return 1;
- }
- AddVehicle(modelid, Float:x, Float:y, Float:z, Float:a, Float:fuel, color1, color2, respawn_delay = -1)
- {
- new vehicleid = CreateVehicle(modelid, x, y, z, a, color1, color2, respawn_delay);
- VehicleFuel[vehicleid] = fuel;
- return vehicleid;
- }
- ToggleVehicleEngineState(vehicleid, bool:value)
- {
- if(!IsValidVehicle(vehicleid))
- return 0;
- new engine, lights, alarm, doors, bonnet, boot, objective;
- GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
- SetVehicleParamsEx(vehicleid, value ? (VEHICLE_PARAMS_ON) : (VEHICLE_PARAMS_OFF), lights, alarm, doors, bonnet, boot, objective);
- return value;
- }
- GetVehicleEngineState(vehicleid)
- {
- if(!IsValidVehicle(vehicleid))
- return 0;
- new engine, lights, alarm, doors, bonnet, boot, objective;
- GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
- return (engine == VEHICLE_PARAMS_ON);
- }
- ResetFillGallon(playerid)
- {
- if(GallonFillTimer[playerid] != -1)
- {
- KillTimer(GallonFillTimer[playerid]);
- GallonFillTimer[playerid] = -1;
- BuyGas[playerid] = 0.0;
- }
- }
- CMD:usargalao(playerid)
- {
- if(!HasGallon[playerid])
- return SendClientMessage(playerid, -1, "* Você não possui um galão de combustível (/galao).");
- if(!IsPlayerInAnyVehicle(playerid))
- return SendClientMessage(playerid, -1, "* Você não está em um veículo (/v).");
- new vehicleid = GetPlayerVehicleID(playerid);
- if(VehicleFuel[vehicleid] >= 100.0)
- return SendClientMessage(playerid, -1, "* Seu veículo já está com o tanque cheio.");
- if(!GasGallon[playerid])
- return SendClientMessage(playerid, -1, "* Seu galão não possui gasolina (/enchergalao).");
- if(GallonTimer[vehicleid] != -1)
- return SendClientMessage(playerid, -1, "* Você já está abastecendo seu veículo.");
- ToggleVehicleEngineState(vehicleid, false);
- SendClientMessage(playerid, -1, "* Abastecendo veículo... Pressione 'N' para parar.");
- GallonTimer[vehicleid] = SetTimerEx("OnGallonRefuel", 500, true, "i", vehicleid);
- return 1;
- }
- CMD:enchergalao(playerid)
- {
- if(!HasGallon[playerid])
- return SendClientMessage(playerid, -1, "* Você não possui um galão de combustível (/galao).");
- if(!IsPlayerInRangeOfPoint(playerid, 1.0, PICKUP_FILL_X, PICKUP_FILL_Y, PICKUP_FILL_Z))
- return SendClientMessage(playerid, -1, "* Você não está no local de encher o galão de combustível.");
- if(IsPlayerInAnyVehicle(playerid))
- return SendClientMessage(playerid, -1, "* Você está conduzindo um veículo.");
- if(GetPlayerMoney(playerid) < PRICE_PER_LITER)
- return SendClientMessage(playerid, -1, "* Você não possui dinheiro suficiente (/g).");
- if(GallonFillTimer[playerid] != -1)
- return SendClientMessage(playerid, -1, "* Você já está enchendo seu galão de combustível.");
- if(GasGallon[playerid] >= 100.0)
- return SendClientMessage(playerid, -1, "* Seu galão já está cheio.");
- TogglePlayerControllable(playerid, false);
- SendClientMessage(playerid, -1, "* Enchendo galão... Pressione 'N' para parar.");
- GallonFillTimer[playerid] = SetTimerEx("OnFillGallon", 500, true, "i", playerid);
- return 1;
- }
- CMD:galao(playerid)
- {
- if(HasGallon[playerid])
- return SendClientMessage(playerid, -1, "* Você já possui um galão.");
- if(GasGallon[playerid] >= 100.0)
- return SendClientMessage(playerid, -1, "* Você está com o galão cheio.");
- HasGallon[playerid] = true;
- GasGallon[playerid] = 0.0;
- SendClientMessage(playerid, -1, "* Você pegou um galão de gasolina (/enchergalao).");
- return 1;
- }
- CMD:v(playerid, params[])
- {
- new modelid;
- if(sscanf(params, "i", modelid))
- return SendClientMessage(playerid, -1, "* Use: /v [modelo]");
- if(!(400 <= modelid <= 611))
- return SendClientMessage(playerid, -1, "* Use modelos de 400 ao 611.");
- new vehicleid, Float:x, Float:y, Float:z, Float:a;
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, a);
- vehicleid = AddVehicle(modelid, x, y, z, a, 25.0, -1, -1);
- PutPlayerInVehicle(playerid, vehicleid, 0);
- return 1;
- }
- CMD:g(playerid)
- {
- GivePlayerMoney(playerid, 1000);
- GameTextForPlayer(playerid, "~g~+$1000", 1000, 3);
- return 1;
- }
Add Comment
Please, Sign In to add comment