[HELP] fuel skip
#1

Hello I have this ony for motocycles so first it's go from 15.0 L and then fuel it should be 14.9 but instead is 14.8 and from there it's go fuel down normal. So why fuel go from 15 to 14.8 but it should 15.0 14.9 and then 14.8. Thanks
Reply
#2

Please provide your code along with your question. This is like posting a post that says 'Have you seen my cat?' and nothing else. What does your cat look like? What name does it go by?

Provide your relevant code (that is, the part of your fuel system; more importantly where it calculates the fuel left) and we will be able to help
Reply
#3

here is the code where if fuel lower for cars and everything works fine and works also for motocycles just skip 14.9 and go to 14.8 and from 14.8 fuel lower normal 14.7 14.6 14.5 etc..

pawn Код:
forward GorivoTimer();
public GorivoTimer()
{
    foreach(Player,i)
    {
        if(GetPlayerState(i) == 2)
        {
            new vid = GetPlayerVehicleID(i);
            if(VoziloJeBiciklo(vid)) continue;
            new engine,lights,alarm,doors,bonnet,boot,objective;
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            if(engine == 1) Fuel[vid] = Fuel[vid] -0.1;
            new string[64];
            format(string,sizeof string,"%.1fl",Fuel[vid]);
            TextDrawSetString(Speedometar0[i],string);
            TextDrawShowForPlayer(i,Speedometar0[i]);
        }
    }
    return 1;
}
Reply
#4

Thats really weird of what you said, like it just works on the code you provided it, Its really unusual unless you script it to, Are you really sure that happens? Or is there any other defination existing for fuel system which takes fuel according to vehicles?
Reply
#5

yes I was sit for example on nrg and drive for a while fuel is set to 15.0 and it goes 15.0 then 14.8 instead of 14.9 I don't know why. thanks
Reply
#6

It's problem with the floats, not your code. Instead of 14.9, it goes to 14.899999 (14.8 with %.1f placeholder).
Reply
#7

why is this only show for bikes I mean nrg freeway etc with cars and the others it go 40.0 39.9 etc and is it a way to fix this. Thanks
Reply
#8

Because 14.9 cannot be represented I guess. Anyways, you can fix it by adding 0.01 on the result but do it only if the fuel is 15.0
pawn Код:
if(engine == 1 && Fuel[vid] == 15.0) Fuel[vid] = (Fuel[vid] - 0.1) + 0.01;
Reply
#9

Quote:

So why fuel go from 15 to 14.8 but it should 15.0 14.9 and then 14.8

Because 14.9 it's 14.899999

Just use:
PHP код:
Fuel[vid] -= 0.01
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Because 14.9 cannot be represented I guess. Anyways, you can fix it by adding 0.01 on the result but do it only if the fuel is 15.0
pawn Код:
if(engine == 1 && Fuel[vid] == 15.0) Fuel[vid] = (Fuel[vid] - 0.1) + 0.01;
What if a player has fuel 14.7 ? I think ,the fuel will not get decreased for him according to your code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)