SA-MP Forums Archive
Need Help With Fuel Cmd Bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need Help With Fuel Cmd Bug (/showthread.php?tid=449226)



Need Help With Fuel Cmd Bug - eastern - 07.07.2013

my refuel cmd it is bugged and i cannot fix it please help after i refuel it took the money too much times.

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] ===0) 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] = 0;
        RefuelingVehicleTimer[playerid] = SetTimerEx("ReFill", 1000, true, "i", playerid);
     }
    return 1;
}


please help me to fix it.



Re: Need Help With Fuel Cmd Bug - Red_Dragon. - 07.07.2013

I think there's an infinite loop. Put this code in pawn tags [.pawn]THE CODE HERE[./pawn] (without the dots).


Re: Need Help With Fuel Cmd Bug - IstuntmanI - 07.07.2013

Change
pawn Код:
RefuelingVehicleTimer[playerid] = SetTimerEx("ReFill", 1000, true, "i", playerid);
to
pawn Код:
RefuelingVehicleTimer[playerid] = SetTimerEx("ReFill", 1000, false, "i", playerid);



Re: Need Help With Fuel Cmd Bug - DobbysGamertag - 07.07.2013

Inside the timer add
pawn Код:
if(VehicleFuel[vehicleid] >= 100.0)  //checks if the fuel is at 100 or more.
{
    VehicleFuel[vehicleid] = 100; //if it goes above. It'll set it to 100.
    KillTimer(RefuelingVehicleTimer[playerid]) //kills the timer if it is
}
Used VehicleFuel[vehicleid] because that's what it looks like.