Vehicle Fuel
#1

So I'm having another issue, and its with something that's a little bit complicated.

I have a public to decrease fuel every so long.
pawn Код:
public DecreaseFuel(playerid)
{
    new string[255];
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == VEHICLE_PARAMS_ON)
        {
            Fuel[i] = Fuel[i] - 1;
            printf("%d",Fuel[i]);
            if(Fuel[i] <= 0)
            {
                Fuel[i] = 0;
                SetVehicleParamsEx(i,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                format(string, sizeof(string), "** The vehicle has run out of fuel. (( %s )).", GetName(playerid));
                NearByMessage(playerid, SCRIPTPURPLE, string);
            }

        }
    }
}
However, when it's meant to update on the game text here:

pawn Код:
format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~n~ ~R~%d KM/H ~n~~r~%d FUEL", GetPlayerSpeed(i, 0), Fuel[i]);
It just stays at zero.. even though when I print on the public it goes down and Fuel[MAX_VEHICLES] is defined as a global variable.

Help (REP+)
Reply
#2

How to make a basic fuel system by gamer
This could help you lad
Reply
#3

Quote:
Originally Posted by vassilis
Посмотреть сообщение
Thanks, I looked at this before I made this thread and it didn't really provide any insightful answers.
Still, thanks though.
Reply
#4

Quote:
Originally Posted by BornHuman
Посмотреть сообщение
Thanks, I looked at this before I made this thread and it didn't really provide any insightful answers.
Still, thanks though.
Show me the refuel you are making because here is only when vehicle loses fuel..
I cant actually get what your gametext do... so explain it better if you don't mind.
Reply
#5

Quote:
Originally Posted by vassilis
Посмотреть сообщение
Show me the refuel you are making because here is only when vehicle loses fuel..
I cant actually get what your gametext do... so explain it better if you don't mind.
OH WOOPS! Nevermind. I was looping through PLAYERS not the vehicles so 'i' became irrelevant.
Reply
#6

You are looping through whole function with "i" use vehicle id... for vehicles
EDIT:JUST SAW YOUR REPLY

EDIT2: Try that this is how i use it:
pawn Код:
function Decreasing_Fuel()
{
    for(new i=0;i<MAX_PLAYERS;i++)
     {
        if (isrefuelling[i]) continue;
        new vid = GetPlayerVehicleID(i);
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
        if (GetPlayerVehicleSeat(i) == 0)
        {
            fuel[vid] = fuel[vid] -1;
            if (fuel[vid]<1)
            {
                fuel[vid] = 0;
                SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective);
                GameTextForPlayer(i,"~r~You are out of ~w~fuel~r~!",5000,3);
            }
        }
        new string[125];format(string,sizeof string,"Vehicle Fuel:%i",fuel[vid]);
        TextDrawSetString(td_fuel[i],string);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)