28.05.2012, 10:20
Hello there. I made my own fuel system, very simple. I have set a timer under OnPlayerEnterVehicle, that leads to function CFuel every 2 Minutes. That works, but, than, it loses 2 fuel, instead of 1...
Here is the code:
Here is the code:
pawn Код:
Under OnPlayerStateChange, after checking if player is in vehicle...
SetTimer("CFuel", 120000, true);
Than, the function..
forward CFuel(playerid);
public CFuel(playerid)
{
new vid;
vid = GetPlayerVehicleID(playerid);
format(file, sizeof(file), "RRP/vehicles/%d.ini", vid);
if(fexist(file))
{
if(dini_Int(file, "Fuel") <= 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "You are out of fuel.");
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,false,lights,alarm,doors,bonnet,boot,objective);
return 1;
}
if(dini_Int(file, "Fuel") <= 100)
{
dini_IntSet(file, "Fuel", dini_Int(file, "Fuel")-1);
return 1;
}
return 1;
}
return 1;
}