pawn Код:
CMD:refuel(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOUR_GREY, "You are not in a vehicle.");
printf("Checked if in vehicle");
new string[128];
if(!IsPlayerInRangeOfPoint(playerid, 20.0, -240.2907,1209.9883,19.7422)&& !IsPlayerInRangeOfPoint(playerid, 50.0,-1327.7439,2675.7014,50.0625) && !IsPlayerInRangeOfPoint(playerid, 10.0, 609.0861,1698.3657,6.9922)) return SendClientMessage(playerid, COLOUR_GREY, "You must be at a Gas Station to refuel.");
new vehicleid = GetPlayerVehicleID(playerid);
new amount, sum, num;
num = 100;
sum = num -= VehFuel[vehicleid]; //This is the sum.
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 1) return SendClientMessage(playerid, COLOUR_GREY, "Please turn your engine off before refuelling.");
if(amount > sum) return SendClientMessage(playerid, COLOUR_GREY, "Your vehicle cannot hold this much fuel."); // This part will not return if I put the amount > sum, i.e If I put 60% instead of 50% it will still fuel the vehicle.
if(VehFuel[vehicleid] == num)return SendClientMessage(playerid, COLOUR_GREY, "Your vehicle's fuel tank is full.");
format(string, sizeof(string), "Usage: /refuel [amount] - Use /refuel %d to fill the tank. (You have %d percent fuel left.) (Cost's $2 per %%)", sum, VehFuel[vehicleid]);
if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOUR_GREY, string);
RefuelTimer[playerid] = SetTimerEx("RefuelUpdate", 1000, true, "i", playerid);
RefuelAmount[playerid] = amount;
printf("Executed timer and set fuel amount");
format(string, sizeof(string), "* %s has begun refuelling the vehicle. *", GetNameEx(playerid));
ProxDetector(10.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
return 1;
}