Fuel Bug -
Lunixx - 09.08.2015
If i type /refuel it starts refueling it but only refuels by 1 unit.
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", 0, false, "i", playerid);
}
return 1;
}
Re: Fuel Bug -
dominik523 - 09.08.2015
Did you want to create a timer that will refill the tank one unit per second or so?
Your timer is not repeating, that's why it refills only one unit. And your interval is 0. Why?
Re: Fuel Bug -
Battlezone - 09.08.2015
RefuelingVehicleTimer[playerid] = SetTimerEx("ReFill", 1000, true, "i", playerid);
1000 is 1000ms = 1s which is the timer interval
But you still have to stop the timer when the fuel is 100, show us your timer function
Re: Fuel Bug -
Lunixx - 09.08.2015
pawn Код:
stock StopRefueling(playerid)
{
GivePlayerCash(playerid, -5);
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;
}
Re: Fuel Bug -
Battlezone - 09.08.2015
Not that function, this one ReFill(playerid);
Re: Fuel Bug -
Vince - 09.08.2015
Would you please stop creating new topics for the same problem and actually read what people say? I've told you yesterday in your other topic that this is the culprit:
pawn Код:
KillTimer(RefuelingVehicleTimer[playerid] = 6000);