29.06.2016, 15:44
In timer_fuel_lower, use GetVehicleParamsEx function and check if "engine" is 0 or -1*. If it is, then don't lower the fuel as the engine of the vehicle is off.
* It is returned -1 when a parameter (such as engine) has not been set. I'm not entirely sure if ManualVehicleEngineAndLights has not been used and it hasn't been set to any value, whether the engine is off or not (you'll need to test it to make sure).
Some things to change:
- When declaring "fuel" array, set a default value.
instead of using a loop when the gamemode starts (2000 iterations) to set a value:
- Avoid declaring variables inside loops.
- Use foreach/y_iterate for player-loops. If not, at least GetPlayerPoolSize.
* It is returned -1 when a parameter (such as engine) has not been set. I'm not entirely sure if ManualVehicleEngineAndLights has not been used and it hasn't been set to any value, whether the engine is off or not (you'll need to test it to make sure).
Some things to change:
- When declaring "fuel" array, set a default value.
pawn Код:
new fuel[MAX_VEHICLES] = {100, ...};
pawn Код:
for(new i=0;i<MAX_VEHICLES;i++)
{
fuel[i] = 100;
}
- Use foreach/y_iterate for player-loops. If not, at least GetPlayerPoolSize.