stop refueling loop problem
#1

ok, i go to gas station, i type the command refuel, with my engine off and then it shows me the message Your vehicle engine hasbeen refilled for $100, but this last message should show just once, instead of that the message loops infinite and keeps GivePlayerCash(playerid, -100) everytime the message shows" this is the command code
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;
}
This is the "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 this is the stop refueling:

pawn Код:
stock StopRefueling(playerid)
{
    GivePlayerCash(playerid, -100);
    SendFormattedMessage(playerid, COLOR_WHITE,"Your vehicle's tank has been refilled for $100.");

    new mypoint = -1;
    for (new i=0; i<MAX_POINTS; i++)
    {
        if(strcmp(Points[i][Name], "Fossil Fuel Company", true) == 0)
        {
            mypoint = i;
        }
    }
    for(new i = 0; i < sizeof(FamilyInfo); i++)
    {
        if(strcmp(Points[mypoint][Owner], FamilyInfo[i][FamilyName], true) == 0)
        {
            FamilyInfo[i][FamilyBank] = FamilyInfo[i][FamilyBank]+(RefuelingVehiclePrice[playerid]/10);
        }
    }

    RefuelingVehicle[playerid] = 0; RefuelingVehiclePrice[playerid] = 0; KillTimer(RefuelingVehicleTimer[playerid] = 6000);
    return true;
}
Reply
#2

pawn Код:
forward ReFill(playerid);
public ReFill(playerid)
{
    if(!IsAtFuelStation(playerid) || !IsPlayerInAnyVehicle(playerid) || VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0 || GetPlayerCash(playerid) < 1)
    {
        StopRefueling(playerid);
        KillTimer(RefuelingVehicleTimer[playerid]); //Try killing the timer here
    }
    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;
}
Reply
#3

Keeps doing the same...when adding the killtimer you gave me, should i remove the kill timer in here?

pawn Код:
stock StopRefueling(playerid)
{
    GivePlayerCash(playerid, -100);
    SendFormattedMessage(playerid, COLOR_WHITE,"Your vehicle's tank has been refilled for $100.");

    new mypoint = -1;
    for (new i=0; i<MAX_POINTS; i++)
    {
        if(strcmp(Points[i][Name], "Fossil Fuel Company", true) == 0)
        {
            mypoint = i;
        }
    }
    for(new i = 0; i < sizeof(FamilyInfo); i++)
    {
        if(strcmp(Points[mypoint][Owner], FamilyInfo[i][FamilyName], true) == 0)
        {
            FamilyInfo[i][FamilyBank] = FamilyInfo[i][FamilyBank]+(RefuelingVehiclePrice[playerid]/10);
        }
    }

    RefuelingVehicle[playerid] = 0; RefuelingVehiclePrice[playerid] = 0; KillTimer(RefuelingVehicleTimer[playerid] = 6000); // should i remove this???!!!
    return true;
}
Reply
#4

the problem was here KillTimer(RefuelingVehicleTimer[playerid] = 6000); <--- i removed the" = 6000);" im not sure if it will affect but it solved the prblem...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)