SA-MP Forums Archive
Refuel command bugged please help - 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: Refuel command bugged please help (/showthread.php?tid=406172)



Refuel command bugged please help - William1122 - 09.01.2013

I downloaded a gamemode and it included some bugs that I was able to fix.. Except one. It's the /refuel mod to add fuel to your vehicle. The problem is that if you refuel you will get a message that you filled your tank for X amount of money and it spams that message and it keeps taking the money of the player that used the command till he has nothing left. The only way to make it stop is restarting the server but If I use it again it repeats itself. I have the code of the command if you need anything else reply it. A thank you in Advance

Code:
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 gas 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;
}



Re: Refuel command bugged please help - JavoDiaz - 09.01.2013

Put the code of the public ReFill please.


Respuesta: Refuel command bugged please help - William1122 - 09.01.2013

Code:
stock StopRefueling(playerid)
{
	GivePlayerCash(playerid, -100);
  	SendFormattedMessage(playerid, COLOR_WHITE,"Your vehicle's tank has been refilled for $100.");
Code:
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;
}
I didn't exactly know wich one of the two so I posted these two hope this is what you mean


Respuesta: Refuel command bugged please help - William1122 - 09.01.2013

Anyone got any solution?...


Re: Refuel command bugged please help - RedCrossER - 09.01.2013

Kill the timer


Re: Refuel command bugged please help - park4bmx - 09.01.2013

Under the "StopRefulling
pawn Code:
KillTimer(RefuelingVehicleTimer[playerid]);



Respuesta: Refuel command bugged please help - William1122 - 09.01.2013

Thanks alot it works . Thanks for the help.