When vehicle is not moving, gas will fill up.(BUG)
#1

Note:This is a part of GodFather RPG.

I've been working on a fuel script, editing one of GF. But, for some reason, if the vehicle isn't moving, it will fillup the fuel..

This is the code I use to decrease the fuel:
OnGameModeInit
pawn Код:
SetTimer("DecreaseGas", 20000, 1);
DecreaseGas:
pawn Код:
public DecreaseGas()
{
for(new i = i;i < MAX_PLAYERS; i++)
{
new vehicle = GetPlayerVehicleID(i);
Gas[vehicle]--;
    }
return 1;
}
I don't get it, I've been looking for something to add a value to the gas, but the only thing was if you fillup. I hope you can help me fix this problem. Thank you.
Reply
#2

pawn Код:
public DecreaseGas()
{
for(new i = i;i < MAX_PLAYERS; i++)
{
new vehicle = GetPlayerVehicleID(i);
Gas[vehicle]--;
TogglePlayerControllable(playerid,1);
}
return 1;
}
Reply
#3

Quote:
Originally Posted by NewbBeginner
Посмотреть сообщение
pawn Код:
public DecreaseGas()
{
for(new i = i;i < MAX_PLAYERS; i++)
{
new vehicle = GetPlayerVehicleID(i);
Gas[vehicle]--;
TogglePlayerControllable(playerid,1);
}
return 1;
}
That won't work, when the vehicle is not moving(frozen or not), the gas will raise.
And I already tried that though. It failed.

But thanks.
Reply
#4

This is seriously weird. Nothing should fill the gas, only if you type /fill...
Reply
#5

Still looking for help, please help me solve this.
Reply
#6

show us the /fill command and functions.. maybe that's the problem.
Reply
#7

Fillup timer:

pawn Код:
public Fillup()
{
    //foreach(Player, i)
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new VID;
            new FillUp;
            new string[128];
            VID = GetPlayerVehicleID(i);
            FillUp = 100 - Gas[VID];
            if(Refueling[i] == 1)
            {
                if(PlayerInfo[i][pCash] >= FillUp+4)
                {
                    Gas[VID] += FillUp;
                    FillUp = FillUp * 8;
                    format(string,sizeof(string),"* You filled your vehicle up for: $%d.",FillUp);
                    SendClientMessage(i,COLOR_LIGHTBLUE,string);
                    TogglePlayerControllable(i, 1);
                    PlayerInfo[i][pCash] = PlayerInfo[i][pCash]-FillUp;
                    GivePlayerMoney(i, - FillUp);
                    if(PointInfo[0][PointTaken] != 255) //fossil fuel
                    {
                        FamilyInfo[PointInfo[0][PointTaken]][FamilyBank] += FillUp;
                    }
                    Refueling[i] = 0;
                }
                else
                {
                    SendClientMessage(i,COLOR_GREY,"   You can't afford that !");
                }
            }
        }
    }
    return 1;
}
/fill:
pawn Код:
if(strcmp(cmd, "/fill", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsAtGasStation(playerid))
            {
                GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~Filling Vehicle, please wait...",2000,3);
                SetTimer("Fillup",12000,0);
                SendClientMessage(playerid, COLOR_YELLOW, "Your vehicle is being filled with fuel.");
                SendClientMessage(playerid, COLOR_YELLOW, "You're frozen until the fuel percentage reaches to 100.");
                TogglePlayerControllable(playerid, 0);
                Refueling[playerid] = 1;
            }
            else
            {
                SendClientMessage(playerid,COLOR_GREY,"   You are not at a Gas Station !");
            }
        }
        return 1;
    }
Check gas timer:
pawn Код:
public CheckInfo()
{
    for(new i = 0;i < MAX_PLAYERS; i++)
    {
        if (IsPlayerInAnyVehicle(i) && IsPlayerConnected(i))
        {
        new vehicle = GetPlayerVehicleID(i);
        if(IsNonFuelVehicle(vehicle)) { return 1; }
        if(Gas[vehicle] >= 1)
        {
            if(Gas[vehicle] <= 10) { PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0); }
            if(gGas[i] == 1) {
            new speed = GetPlayerSpeed(i),string[138];
            format(string,sizeof(string)," %d%~n~ %d%",speed, Gas[vehicle]);
            TextDrawSetString(FSpeedRes[i],string);
        }
            if(Gas[vehicle] <= 1)
        {
                NoFuel[i] = 1;
                RemovePlayerFromVehicle(i);
                SendClientMessage(i, COLOR_RED, "Vehicle is out of fuel!");
                return 1;
                }
            }
        }
    }
    return 1;
}
Reply
#8

Still looking for possible support.
Reply
#9

pawn Код:
public CheckInfo()
{
    new string[256];
    for(new i=0;i<PLAYERS;i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                new vehicle = GetPlayerVehicleID(i);
                if(Gas[vehicle] >= 1)
                {
                    if(Gas[vehicle] > 100)
                        Gas[vehicle] = 100;
                    if(Gas[vehicle] <= 10)
                    {
                        PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
                        if(gGas[i] == 0) {
                            GameTextForPlayer(i,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel is low",5000,3);
                        }
                    }
                    if(gGas[i] == 1) {
                    if(IsAPlane(vehicle) || IsABoat(vehicle) || IsAHarvest(vehicle) || IsADrugHarvest(vehicle) || IsASweeper(vehicle) || GetVehicleModel(vehicle) == 481)
                    {
                        format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ N/A");
                    }
                    else
                    {
                        format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ %d%",Gas[vehicle]);
                    }
                    GameTextForPlayer(i,string,20500,3); }
                    if(IsAPlane(vehicle) || IsABoat(vehicle) || IsAHarvest(vehicle) || IsADrugHarvest(vehicle) || IsASweeper(vehicle) || GetVehicleModel(vehicle) == 481 || engineOn[vehicle] == 0) { Gas[vehicle]++; }
                    Gas[vehicle]--;
                }
                else
                {
                    NoFuel[i] = 1;
                    TogglePlayerControllable(i, 0);
                    GameTextForPlayer(i,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~No fuel in Vehicle",1500,3);
                }
            }
        }
    }
    return 1;
}
Try this one, perhaps it will help you ...
Reply
#10

@EliranPesahov
Nope, it didn't. I am using the same way as you posted. I modified it though, as you see. I do not wish to use that method as I modified it.
Anyway, I can't see anything that's related to my problem in that script. :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)