Weird bug with fuel system
#1

When your fuel goes to 0 and you enter in other car it doesn't decrease the fuel:

Код:
public DecreaseFuel()
{
	for(new t=0;t<MAX_PLAYERS;t++)
	{
		if(IsPlayerInAnyVehicle(t))
		{
			if(GetPlayerVehicleSeat(t) == 0)
			{
				new vid = GetPlayerVehicleID(t);
				if(GetVehicleComponentInSlot(GetPlayerVehicleID(t),GetVehicleComponentType(1010)) != 1010)
				{ agas[vid]--; }
				else
				{ agas[vid]--; agas[vid]--; }
				if(agas[vid] == 15 || agas[vid] == 10 || agas[vid] == 5)
				{
					GameTextForPlayer(t, "~r~Low Fuel", 5000, 5);
					return 1;
				}
				if(agas[vid] <= 0)
				{
					agas[vid] = 0;
					GetVehicleParamsEx(vid,engine,lightsss,alarm,doorsss,bonnet,boot,objective);
					SetVehicleParamsEx(vid,0,lightsss,alarm,doorsss,bonnet,boot,objective);
					return 1;
				}
			}
		}
	}
	return 1;
}
Reply
#2

Anyone?
Reply
#3

It's not a weird bug, you are looping through all players; checking if they are in a vehicle, checking if they are driver and then processing it.

What you probably want to do is have the fuel decrease for all vehicles where the engine is on. This can be done by instead looping through all vehicles, checking if their engine is on and decreasing the fuel accordingly. You also don't check if the vehicle's engine is on(not sure if you forgot about this or not - the fuel will go down even if the engine is off).
Reply
#4

@decrease for all vehicles where the engine is on

What will happend when there is no driver in the car? Will continue to decrease the fuel....
Reply
#5

Quote:
Originally Posted by dan40o
Посмотреть сообщение
@decrease for all vehicles where the engine is on

What will happend when there is no driver in the car? Will continue to decrease the fuel....
Then make it so that if there is no driver in the car, it will not execute the callback... ez.
Reply
#6

Quote:
Originally Posted by d1git
Посмотреть сообщение
Then make it so that if there is no driver in the car, it will not execute the callback... ez.
How?
Reply
#7

You know that in real life, just because someone isn't in the car or it's not being driven(but the engine is on), fuel still goes away, just saying that. The method I gave you takes care of this as well as decreases fuel for all vehicles even if the player has left the car.
Reply
#8

Quote:
Originally Posted by dan40o
Посмотреть сообщение
How?
Loop through all of the current connected players and check if there's somebody in the vehicle (I assume you've made a callback already where you loop through all of the vehicles and make sure the fuel decreases when somebody is in the vehicle, ect ect... you get where i'm going.), if there is... break the code (make it stop).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)