View Single Post
Old 28/05/2012, 10:20 AM   #1
ricardo178
High-roller
 
ricardo178's Avatar
 
Join Date: Dec 2010
Posts: 1,598
Reputation: 91
Default Custom Fuel system taking 2 fuel instead of 1.

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:

pawn Code:
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;
}
ricardo178 is offline   Reply With Quote