How To Make Max Fuel?
#4

If you wanna make a fuel capacity per vehicle model you can set that all up yourself, or you can use this one with a 30 max capacity just like your SS.

pawn Код:
new Float:Fuel[MAX_VEHICLES];
new FuelTimer[MAX_VEHICLES] = -1;
new VehicleOccupied[MAX_VEHICLES] = -1;
#define MAX_FUEL 30.0 // Max fuel capacity
#define FUEL_TIMER_MIN 1 // Minutes per fuel depletion (1 minute loses 1 fuel)

public OnVehicleSpawn(vehicleid)
{
    if(FuelTimer[vehicleid] != -1) KillTimer(FuelTimer[vehicleid]);
    Fuel[vehicleid] = MAX_FUEL;
    SetTimerEx("Fuel_down", FUEL_TIMER_MIN * 60000, true, "i", vehicleid);
    VehicleOccupied[vehicleid] = -1;
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    KillTimer(FuelTimer[vehicleid]);
    Fuel[vehicleid] = 0.0;
    return 1;
}

forward Fuel_down(vehicleid);
public Fuel_down(vehicleid)
{
    Fuel[vehicleid] -= 1.0;
    if(Fuel[vehicleid] <= 1 && VehicleOccupied[vehicleid] != -1) RemovePlayerFromVehicle(VehicleOccupied[vehicleid]);
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(Fuel[GetPlayerVehicleID(playerid)] <= 0) RemovePlayerFromVehicle(GetPlayerVehicleID(playerid));
        else VehicleOccupied[GetPlayerVehicleID(playerid)] = playerid;
    }
    if(oldstate == PLAYER_STATE_DRIVER && newstate != PLAYER_STATE_DRIVER)
    {
        VehicleOccupied[GetPlayerVehicleID(playerid)] = -1;
    }
    return 1;
}
Reply


Messages In This Thread
How To Make Max Fuel? - by kloning1 - 24.07.2014, 02:39
Re: How To Make Max Fuel? - by coole210 - 24.07.2014, 02:50
Re: How To Make Max Fuel? - by kloning1 - 24.07.2014, 02:53
Re: How To Make Max Fuel? - by coole210 - 24.07.2014, 03:00
Re: How To Make Max Fuel? - by Juvanii - 24.07.2014, 03:13
Re: How To Make Max Fuel? - by kloning1 - 24.07.2014, 03:14
Re: How To Make Max Fuel? - by Juvanii - 24.07.2014, 03:17
Re: How To Make Max Fuel? - by kloning1 - 24.07.2014, 03:26
Re: How To Make Max Fuel? - by Juvanii - 24.07.2014, 03:34
Re: How To Make Max Fuel? - by kloning1 - 24.07.2014, 03:39

Forum Jump:


Users browsing this thread: 2 Guest(s)