Refuel CMD problem
#1

I do /refuel and i wait then the server starts to spam "your tank has been refilled for (any amount of money)" and spams over and over and i have this error in the server log:
Код:
 AMX backtrace:
 #0 00017180 in ?? () from EG-RP.amx
 #1 00017e78 in public ReFill () from EG-RP.amx
 Run time error 4: "Array index out of bounds"
  Accessing element at negative index -1
 AMX backtrace:
 #0 00017180 in ?? () from EG-RP.amx
 #1 00017e78 in public ReFill () from EG-RP.amx
 Run time error 4: "Array index out of bounds"
  Accessing element at negative index -1
and here is the public function for ReFill:
pawn Код:
forward ReFill(playerid);
public ReFill(playerid)
{
    if(!IsAtFuelStation(playerid) || !IsPlayerInAnyVehicle(playerid) || VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0 || GetPlayerCash(playerid) < 1)
    {
        StopRefueling(playerid);
    }
    else
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == VEHICLE_PARAMS_ON) return StopRefueling(playerid);
        VehicleFuel[GetPlayerVehicleID(playerid)] += 1.0; RefuelingVehiclePrice[playerid] += 30;
        if(VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0) VehicleFuel[GetPlayerVehicleID(playerid)] = 100.0;
    }
    return true;
}
and here is the refuel command:
pawn Код:
CMD:refuel(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new engine,lights,alarm,doors,bonnet,boot,objective;
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == VEHICLE_PARAMS_ON) return SendClientMessageEx(playerid, COLOR_RED, "You need to shut off the engine before filling up (/car engine).");
        if(!IsAtFuelStation(playerid)) return SendClientMessageEx(playerid, COLOR_RED, "You're not at a fuel station.");
        if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
        if(VehicleFuel[vehicleid] >= 100.0) return SendClientMessageEx(playerid, COLOR_RED, "This vehicle's tank is already full.");
        if(RefuelingVehicle[playerid] == 1) return SendClientMessageEx(playerid, COLOR_RED, "You are refilling your vehicle's tank.");
        SendClientMessageEx(playerid, COLOR_WHITE, "Refueling your vehicle's tank, please wait.");
        RefuelingVehicle[playerid] = 1;
        RefuelingVehicleTimer[playerid] = SetTimerEx("ReFill", 1000, true, "i", playerid);
    }
    return 1;
}
by the way, these aren't my codes its my friend's that he works on something for me.
Reply
#2

Try replacing
Quote:

if(!IsAtFuelStation(playerid)) return SendClientMessageEx(playerid, COLOR_RED, "You're not at a fuel station.");

with
Quote:

if(IsAtFuelStation(playerid)) return SendClientMessageEx(playerid, COLOR_RED, "You're not at a fuel station.");

Reply
#3

Still the same
Reply
#4

kill the timer !
pawn Код:
forward ReFill(playerid);
public ReFill(playerid)
{
    if(!IsAtFuelStation(playerid) || !IsPlayerInAnyVehicle(playerid) || VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0 || GetPlayerCash(playerid) < 1)
    {
        StopRefueling(playerid);
    }
    else
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == VEHICLE_PARAMS_ON) return StopRefueling(playerid);
        VehicleFuel[GetPlayerVehicleID(playerid)] += 1.0; RefuelingVehiclePrice[playerid] += 30;
        if(VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0){
            VehicleFuel[GetPlayerVehicleID(playerid)] = 100.0;
            KillTimer(RefuelingVehicleTimer[playerid]);
        }
    }
    return true;
}
Reply
#5

pawn Код:
C:\PC\E\Express Gaming Roleplay Server - Copy\gamemodes\EG-RP.pwn(3300) : warning 217: loose indentation
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
Reply
#6

something is not line properly.
Tab size is not correct show the exact line
Reply
#7

pawn Код:
if(VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0){
            VehicleFuel[GetPlayerVehicleID(playerid)] = 100.0;
            KillTimer(RefuelingVehicleTimer[playerid]);
        }
     }
     return true; // line 3300
}
Reply
#8

pawn Код:
if(VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0) {
    VehicleFuel[GetPlayerVehicleID(playerid)] = 100.0;
    KillTimer(RefuelingVehicleTimer[playerid]);
}
Reply
#9

Wrong because when i remove the the "return true" it shows 26 errors so it is wrong
Reply
#10

i used park4bmx code but when i do /refuel it says "Refueling your vehicle's tank, please wait." and when i drive away of the gas station and i come back and do /refuel again it says "You are refilling your vehicle's tank." yes it stopped spamming but now where is the time it takes to refuel ? it says please wait and the time never ends !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)