Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(strcmp(cmd, "/gasolina", true) == 0)
- {
- new tmp[256], vehicleid;
- new gas, string[128], offset, total;
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_RED, "/gasolina [quantia]");
- return 1;
- }
- gas = strval(tmp);
- if(AreaPosto[playerid] == 0)
- {
- SendClientMessage(playerid, COLOR_RED, "Você não está no posto!");
- return 1;
- }
- if(!(vehicleid = GetPlayerVehicleID(playerid)))
- {
- SendClientMessage(playerid, COLOR_RED, "Você não está em um veículo!");
- return 1;
- }
- if(gas > 100 || gas <= 0)
- {
- SendClientMessage(playerid, COLOR_RED, "Quantia inválida! Gas apenas de 1 à 100");
- return 1;
- }
- if(GetVehicleGas(vehicleid) >= 100)
- {
- SendClientMessage(playerid, COLOR_RED, "O tanque de seu carro já está cheio!");
- return 1;
- }
- offset = 100 - GetVehicleGas(vehicleid);
- total = (gas + GetVehicleGas(vehicleid) > 100) ? gas - offset : gas;
- if(GetPlayerMoney(playerid) < total)
- {
- format(string, sizeof string, "Você não tem dinheiro para abastecer %d litros. Custo: $1 cada litro!", total);
- SendClientMessage(playerid, COLOR_RED, string);
- return 1;
- }
- GivePlayerMoney(playerid, -total);
- AddVehicleGas(vehicleid, total);
- if(GetVehicleGas(vehicleid) >= 100)
- {
- format(string, sizeof string, "Foram abastecidos %d litros, tanque cheio agora!", total);
- SendClientMessage(playerid, COLOR_GREEN, string);
- }
- else
- {
- format(string, sizeof string, "Foram abastecidos %d litros, total: %d", total, GetVehicleGas(vehicleid));
- SendClientMessage(playerid, COLOR_GREEN, string);
- }
- return 1;
- }
Add Comment
Please, Sign In to add comment