Why does the fuel go down ? - 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: Why does the fuel go down ? (
/showthread.php?tid=349638)
Why does the fuel go down ? -
Geniuss - 09.06.2012
Why does the fuel go down even if the engine is off please help me
pawn Код:
public timer_fuel_lower()
{
new engine, lights, alarm, doors, bonnet, boot, objective;
for(new i=0;i<MAX_PLAYERS;i++) { //loop for all players
new PlayerVehicle = GetVehicleFileID(GetPlayerVehicleID(i));
if (isrefuelling[i]) continue; //stop when a player is already refuelling
new vid = GetPlayerVehicleID(i); //getting vehicle ID
if (GetPlayerVehicleSeat(i) == 0 && EngineOn[vid] == 1 || IsPlayerInHotWiredCar == 1 || Vehicles[PlayerVehicle][CarGroup] >= 0 && Vehicles[PlayerVehicle][CarGroup] == Player[i][Group]) { //if the player is a driver (it should only lower the fuel when theres an driver!)
fuel[vid] = fuel[vid] -1; //lowering fuel value
if (fuel[vid]<1) //if fuel is empty
{
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
fuel[vid] = 0; //setting fuel to 0 (else the timer will set it to -1 -2 -3 etc before removing player)
SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, 0);
}
}
new string[125];format(string,sizeof string,"Fuel:%i",fuel[vid]); //preparing string with next fuel value
TextDrawSetString(td_fuel[i],string); //updating textdraw
}
}
Thank You
AW: Why does the fuel go down ? -
JhnzRep - 09.06.2012
As I said, you need to do this..
pawn Код:
new engine, lights, alarm, doors, bonnet, boot, objective;
for(new ix=0;ix<MAX_VEHICLES;ix++)
{
new fuelx = fuel[ix];
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 0)
{
fuel[ix] = fuelx
}
}