07.07.2013, 01:00
This should work for you.
pawn Код:
CMD:stealfuel(playerid, params[])
{
if(PlayerInfo[playerid][pCan] == 1 && PlayerInfo[playerid][pSiphon] == 1)
{
if(PlayerInfo[playerid][pCanFuel] < 20.0)
{
new closestcar = GetClosestCar(playerid);
new string[128];
if(IsPlayerInRangeOfVehicle(playerid, closestcar, 7.0))
{
if(Fuel[closestcar] < 1.0)
{
format(string,sizeof(string),"* %s opens the bottom of the vehicles gas tank, uses their siphon to drain the gasoline into the gascan, but extracts nothing from the empty gastank.",RPN(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE);
}
else
{
new Float:FillAmount = 20.0 - PlayerInfo[playerid][pCanFuel];
if(Fuel[closestcar] - FillAmount < 0.0) FillAmount = Fuel[closestcar];
PlayerInfo[playerid][pCanFuel] += FillAmount;
Fuel[closestcar] -= FillAmount;
format(string,sizeof(string),"* %s opens the bottom of the vehicles gas tank, uses their siphon to drain the gasoline into the gascan.",RPN(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE);
}
}
else SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}You aren't near any vehicle.");
}
else SendClientMessage(playerid, COLOR_YELLOW,"Your gascan is full.");
}
else SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}Make sure you got a gascan and a siphon in order to steal fuel.");
return 1;
}