SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Fuel bug (https://forum.sa-mp.com/showthread.php?t=672627)

salev13 21/02/2020 06:53 PM

Fuel bug
 
Well my fuel stay in 100 even if I drive for hours.

PHP Code:

Server:Fuel()
{
    for(new 
1GetVehiclePoolSize(); <= ji++)
    {
        if(
IsValidPlayerCar(i) && !AdminCar[i] && !IsValidFactionCar(i) && CarEngine[i] && GetVehicleSpeed(i) > 1)
        { 
            static
                
marker_time
                
            if(!
marker_time)
                
marker_time gettime();
                
            if(
gettime() - marker_time 240)
            {
                
DecreaseFuel(i);
                
marker_time 0;
            }
        }
    }
}

Server:DecreaseFuel(vehicleid)
{
    new
        
Float:g_fuel_deduction_rate_petrol 0.004,
        
Float:g_fuel_deduction_rate_diesel 0.002,
        
Float:g_vehicle_model_mass,
        
Float:g_total_loss;
        
    
GetVehicleMass(vehicleidg_vehicle_model_mass);
    
    if(
GetVehicleModelInfoAsInt(GetVehicleModel(vehicleid), "TransMissionData_nEngineType") == 'P')
        
g_total_loss = (g_vehicle_model_mass/30.0) * g_fuel_deduction_rate_petrol
        
    else if(
GetVehicleModelInfoAsInt(GetVehicleModel(vehicleid), "TransMissionData_nEngineType") == 'D')
        
g_total_loss = (g_vehicle_model_mass/30.0) * g_fuel_deduction_rate_diesel
        
    else 
g_total_loss = (g_vehicle_model_mass/30.0) * 0.009+0.002// 0.004 -> 0.009, 10.0 -> 30.0
    
    
CarData[vehicleid][carFuel]-= g_total_loss;
    if(
CarData[vehicleid][carFuel] < 1)
    {
        
ToggleVehicleEngine(vehicleidfalse);
        foreach(new 
Player) if(IsPlayerInVehicle(ivehicleid) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
            
SendClientMessage(iCOLOR_ADM"Your car ran out of fuel!");
    }
    return 
1;



salev13 22/02/2020 01:44 PM

Re: Fuel bug
 
Bump

salev13 25/02/2020 01:19 PM

Re: Fuel bug
 
Someone?


All times are GMT. The time now is 07:38 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.