Fuel drops instantly.
#1

Hello, After a few players have joined i am not sure if its because of that but the fuelbar drops in 30 seconds the timer isnt set for that and i have the same problem with the hunger system (i use the same system)

So if anyone could help me i would really appreciate that
This is my code thingie for the timer only
pawn Код:
public timer_fuel_lower(playerid)
{
        new vid = GetPlayerVehicleID(playerid);
        if (GetPlayerVehicleSeat(playerid) == 0){
           GetVehicleParamsEx(playerid,engine,lights,alarm,doors,bonnet,boot,objective);
            fuel[vid] = fuel[vid] -1;
            if (fuel[vid]<1)
            {
                fuel[vid] = 0;
                SetVehicleParamsEx(vid,0,lights,alarm,doors,bonnet,boot,objective);
                VehEngine[vid] =0;
                SCM(playerid, red,"[System] You are out of fuel");
        }
        }
    SetProgressBarValue(bar_fuel[playerid], fuel[vid]);
    UpdateProgressBar(bar_fuel[playerid], playerid);
        }
Reply
#2

The code for the timer?
Reply
#3

pawn Код:
CMD:engine(playerid, params[]){
    new vehID = GetPlayerVehicleID(playerid);
    if(fuel[vehID]<=1)return SCM(playerid, red, "[System] You are out of fuel");
    if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER){
        if(VehEngine[vehID]<=0){
            SetTimerEx("startengine", 3000, 0, "i", playerid);
                timerfuel[playerid] = SetTimerEx("timer_fuel_lower",8500,true,"i",playerid); //sets the timer to drop the fuel
        }else if(VehEngine[vehID]==1) {
            ToggleVehEngine(vehID);
            KillTimer((timerfuel)[playerid]);
            SendClientMessage(playerid,0xFFFFFFFF,"engine off.");
        }
    }
    return 1;
}
Reply
#4

pawn Код:
public timer_fuel_lower(playerid)
{
    new vid = GetPlayerVehicleID(playerid);
    if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if(fuel[vid] > 0)
        {
            fuel[vid]--;
        }
        else
        {
            GetVehicleParamsEx(playerid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,0,lights,alarm,doors,bonnet,boot,objective);
            VehEngine[vid] = 0;
            SCM(playerid, red,"[System] You are out of fuel");
        }
    }
    SetProgressBarValue(bar_fuel[playerid], fuel[vid]);
    UpdateProgressBar(bar_fuel[playerid], playerid);
}
should work
Reply
#5

This on OnGameModeEnit

pawn Код:
for(new i=0;i<MAX_VEHICLES;i++){
    fuel[i] = 100; //sets every car's fuel to 100 in a loop
    }
    SetTimer("timer_fuel_lower",35500,true); //sets the timer to drop the fuel
and this as Public fuel_lower

pawn Код:
public timer_fuel_lower()
{
    for(new i=0;i<MAX_PLAYERS;i++) { //loop for all players
        if (isrefuelling[i]) continue; //stop when a player is already refuelling
        new vid = GetPlayerVehicleID(i); //getting vehicle ID
        if (GetPlayerVehicleSeat(i) == 0) { //if the player is a driver (it should only lower the fuel when theres an driver!)
            fuel[vid] = fuel[vid] -1; //lowering fuel value
            if (fuel[vid]<1) //if fuel is empty
            {
                fuel[vid] = 0; //setting fuel to 0 (else the timer will set it to -1 -2 -3 etc before removing player)
                RemovePlayerFromVehicle(i); //remove player out of vehicle
                GameTextForPlayer(i,"~r~You are out of ~w~fuel~r~!",5000,4); //show text
            }
        }
        new string[125];format(string,sizeof string,"Fuel:%i",fuel[vid]); //preparing string with next fuel value
        TextDrawSetString(td_fuel[i],string); //updating textdraw
    }
    return 1;
}
You mihgt have to define some stuff, not sure. but it should work
Reply
#6

you initialized the timerfuel[playerid], i assume correctly, but look here:
pawn Код:
KillTimer((timerfuel)[playerid]);
isnt it supposed to be
pawn Код:
KillTimer(timerfuel[playerid]);
? is the fueltimer bug (dropping to ofast) happening for playerid 0 only?
Reply
#7

Quote:
Originally Posted by Voldemort
Посмотреть сообщение
pawn Код:
public timer_fuel_lower(playerid)
{
    new vid = GetPlayerVehicleID(playerid);
    if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if(fuel[vid] > 0)
        {
            fuel[vid]--;
        }
        else
        {
            GetVehicleParamsEx(playerid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,0,lights,alarm,doors,bonnet,boot,objective);
            VehEngine[vid] = 0;
            SCM(playerid, red,"[System] You are out of fuel");
        }
    }
    SetProgressBarValue(bar_fuel[playerid], fuel[vid]);
    UpdateProgressBar(bar_fuel[playerid], playerid);
}
should work
Thanks but where exactly does it drop the fuel ?
Reply
#8

Quote:
Originally Posted by Babul
Посмотреть сообщение
you initialized the timerfuel[playerid], i assume correctly, but look here:
pawn Код:
KillTimer((timerfuel)[playerid]);
isnt it supposed to be
pawn Код:
KillTimer(timerfuel[playerid]);
? is the fueltimer bug (dropping to ofast) happening for playerid 0 only?
Yes sometimes ID 0 bugs alot but sometimes it are all the players it depends.
Reply
#9

Tried my code?
Reply
#10

It was from a tutorial that used textdraws and stuff and i would keep the same problem so no.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)