[HELP] Fuel problem!!
#2

Show us your engine command or how you close the engine?

EDIT: Also,
https://sampwiki.blast.hk/wiki/SetVehicleParamsEx
since 0.3a you will have to reapply this function when OnVehicleStreamIn is called.

EDIT 2:
Optimized version of the code can be...

PHP код:
// top of the script
native IsValidVehicle(vehicleid);
// somewhere in the script
forward FuelTimer();
public 
FuelTimer()
{
    for(new 
vehidveh GetVehiclePoolSize(); vehid <= vehvehid++)
    {
        if(
IsValidVehicle(vehid))
        {
            new 
engineclightscalarmcdoorscbonnetcbootcobjectivec;
            
GetVehicleParamsEx(vehidengineclightscalarmcdoorscbonnetcbootcobjectivec);
            if(
enginec)
            {
                if(
Fuel[vehid] > 0)
                {
                    if(
GetVehicleSpeed(vehid0) != 0)
                    {
                        
FuelVar[vehid] ++;
                        if(
FuelVar[vehid] >= 72/2)
                        {
                            
FuelVar[vehid] = 0;
                            
Fuel[vehid] --;
                        }
                        else if(
FuelVar[vehid] >= 108/2)
                        {
                            
FuelVar[vehid] = 0;
                            
Fuel[vehid] --;
                        }
                    }
                }
            }
        }
    }
    return 
1;

Reply


Messages In This Thread
[HELP] Fuel problem!! - by catal4n - 07.12.2016, 09:47
Re: [HELP] Fuel problem!! - by Logic_ - 07.12.2016, 09:56
Re: [HELP] Fuel problem!! - by catal4n - 07.12.2016, 10:20
Re: [HELP] Fuel problem!! - by catal4n - 07.12.2016, 10:33

Forum Jump:


Users browsing this thread: 3 Guest(s)