[HELP] fuel down timer
#1

Hello I was that every 40 seconds fuel down for 0.01 for example 15.0 then it will go 14.9 etc know the problem I turn gamemode and I sit in vehicle and driver for a while and then fuel is set to 14.9 of if is a car it was 40.0 then 39.9 and then 40 seconds are passed and fuel is still standing at 39.9 instead to go on 39.8

edit: I was put for timer 1000 miliseconds which is one second and know it lower down fuel but I want to lower every 30 or 40 seconds and if I put for 30 seconds or more it just lover fuel to 39.9 and it's stay like this

first in ongamemodeinit I have timer

SetTimer("FuelTimer",Sec(45),1);

then I have fueltimer


pawn Код:
forward FuelTimer();
public FuelTimer()
{
    for(new car = 1; car < MAX_VOZILA; car++)
    {
        if(VoziloJeBiciklo(car)) continue;
        new engine,lights,alarm,doors,bonnet,boot,objective;
        GetVehicleParamsEx(car,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == 1 && Gorivo[car] > 0.00) Gorivo[car] = floatsub(Gorivo[car],0.01); here is that so if the engine of vehicle is turned on then it set fuel down for 0.01
    }
    foreach(Player,i)
    {
        if(IsPlayerInAnyVehicle(i))
        {
            new string[128];
            format(string,sizeof string,"%.1fl",Gorivo[GetPlayerVehicleID(i)]); and here I update my fuel textdraw.
            TextDrawSetString(Speedometar0[i],string);
        }
    }
    return 1;
}
Reply
#2

SetTimerEx - so it has a direct connection with the player and not making a public timer
Reply
#3

Exactly ^^ Otherwise you are making a connection to a ublic timer and it therefore does not work as there are different players on for different amounts of time. Link it directly to the player using SetTimerEx and it should work!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)