SA-MP Forums Archive
Can someome help meh? - 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: Can someome help meh? (/showthread.php?tid=399039)



Can someome help meh? - xxxDeathxxx - 12.12.2012

Код:
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 my refuel code, and it keep sayng ingame "You are refilling your vehicle's tank." but it dosent refill that, how to fix it?

Код:
if(RefuelingVehicle[playerid] == 1) return SendClientMessageEx(playerid, COLOR_RED, "You are refilling your vehicle's tank.");
if i edit that nr 1 to 0 what happens?
Код:
f(RefuelingVehicle[playerid] == 1)



Re: Can someome help meh? - goviscrap - 12.12.2012

Try and see what happends... But I think it means that you have Refueled the car = 0. Refueling = 1


Re: Can someome help meh? - xxxDeathxxx - 12.12.2012

Is in this code something wrong or?


Re: Can someome help meh? - RedCrossER - 12.12.2012

when the refueling started just set it to 1 like this RefuelingVehicle[playerid] = 1;
and in timer set it to RefuelingVehicle[playerid] = 0;
and if the player exit the vehicle also set it to 0 if it was 1


Re: Can someome help meh? - xxxDeathxxx - 12.12.2012

Quote:
Originally Posted by RedCrossER
Посмотреть сообщение
when the refueling started just set it to 1 like this RefuelingVehicle[playerid] = 1;
and in timer set it to RefuelingVehicle[playerid] = 0;
and if the player exit the vehicle also set it to 0 if it was 1
that should work?


Re: Can someome help meh? - Mike_Peterson - 12.12.2012

You might want to post the public 'Refill' function, as you are stating it doesn't refuel the vehicle.


Re: Can someome help meh? - xxxDeathxxx - 12.12.2012

Quote:
Originally Posted by Mike_Peterson
Посмотреть сообщение
You might want to post the public 'Refill' function, as you are stating it doesn't refuel the vehicle.
you mean this?

Код:
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;
}



Re: Can someome help meh? - RedCrossER - 13.12.2012

Did you tried what i said?