How To Make Max Fuel?
#1

How To Make Max Fuel in vehicle??

its like Realistic :3 right every vehicle has a different fuel

This SS/ Exlampe
Reply
#2

Try and just use a timer and a variable I guess?
Reply
#3

look pic , there restrictions of fuel *fuel capacity
Reply
#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
#5

I see that this is wrong! if u make the timer under OnVehicleSpawn callback, it will decrease the vehicle's fuel even with no driver in the vehicle. So you better use it under OnPlayerStateChange like:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        FuelTimer[playerid] = SetTimerEx("Fuel_Down", FUEL_TIMER_MIN * 60000, true, "i", playerid);
    }
    return 1;
}
Reply
#6

but, every car is different fuels limits >,<
Reply
#7

Quote:
Originally Posted by kloning1
Посмотреть сообщение
but, every car is different fuels limits >,<
so? what do u want exactly?
Reply
#8

so gini, I would * imagine: v LOL

hm, fuel, like in the real world,
did you see? each vehicle must have a fuel capacity will vary,

* so? Can you help?
Reply
#9

if u mean that you want every vehicle model has different max fuel capacity, i think you could make it under OnGameModeInIt callback by looping all the vehicles then make a fuel capacity to each vehicle model but it'll take so much time.
Reply
#10

well as that, (y)
function-function what should be learned ??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)