Help with my fuel system :S - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with my fuel system :S (
/showthread.php?tid=223664)
Help with my fuel system :S -
YungGee - 10.02.2011
Ok i have a callback to remove fuel and when it gets to 0 its continues to -1 etc
pawn Код:
public FuelUpdate()
{
new string[128];
for(new i=0;i<MAX_PLAYERS;i++)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
if(IsPlayerInAnyVehicle(i))
{
if(IsPlayerConnected(i))
{
new PVeh = GetPlayerVehicleID(i);
if(VFuel[PVeh] >= 1 || VFuel[PVeh] <= 100)//If inbettween 1 and 100...
{
VFuel[PVeh] -= 1;//Remove 1 fuel///
format(string, sizeof(string),"~n~~n~~n~~n~~n~~n~~n~~n~~g~Fuel: ~w~%d%",VFuel[PVeh]);//And show it
GameTextForPlayer(i,string,18000,3);//In GameText
}
else//Else if its 0
{
RemovePlayerFromVehicle(i);//Remove Player
SendClientMessage(i,RED,"This Vehicle Is Out Of Fuel!");//Tell Them Its Empty.
}
}
}
}
}
}
Now how come if you in a vehicle and run the fuel empty (Not Getting Of IT Yet) it continues -1 -2 etc and keeps going not removing them and telling them its empty
Please help :S
EDIT: if you run it to 0 or -1 then get of then try get back on THEN it tells u its empty :S
Re: Help with my fuel system :S -
JamesC - 10.02.2011
|| = OR
&& = AND
pawn Код:
if(VFuel[PVeh] >= 1 && VFuel[PVeh] <= 100)
Re: Help with my fuel system :S -
Backwardsman97 - 10.02.2011
pawn Код:
public FuelUpdate()
{
new string[128];
for(new i=0;i<MAX_PLAYERS;i++)
{
if(GetPlayerState(i) == 2)
{
new PVeh = GetPlayerVehicleID(i);
if(VFuel[PVeh])//If inbettween 1 and 100
{
VFuel[PVeh] -= 1;//Remove 1 fuel///
format(string, 128,"~n~~n~~n~~n~~n~~n~~n~~n~~g~Fuel: ~w~%d%",VFuel[PVeh]);//And show it
GameTextForPlayer(i,string,18000,3);//In GameText
}
else//Else if its 0
{
RemovePlayerFromVehicle(i);//Remove Player
SendClientMessage(i,RED,"This Vehicle Is Out Of Fuel!");//Tell Them Its Empty.
}
}
}
return 1;
}
Try that. It should be more optimized. You really need to only check if the fuel is over 0.
Re: Help with my fuel system :S -
YungGee - 10.02.2011
Код:
if(VFuel[PVeh])//If inbettween 1 and 100
Please explain how this tells it thats its not at 0?
EDIT: And if i use If(GetPlayerState[playerid] == PLAYER_STATE_DRIVER) i dont have to use IsPlayerInAnyVehicle becuase it already knows there in one?? Loll makes sence xD
Re: Help with my fuel system :S -
Mean - 10.02.2011
EDIT: I haven't read your post much...
BUUUT, you should change to:
pawn Код:
new fuel = 30; // 30 fuel
pawn Код:
fuel--; // Taking 1 fuel away, you should use this instead of the thingy u'r usin'