SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 21/02/2020, 06:53 PM   #1
salev13
Big Clucker
 
Join Date: May 2013
Location: England
Posts: 176
Reputation: 0
Default 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 is offline   Reply With Quote
Old 22/02/2020, 01:44 PM   #2
salev13
Big Clucker
 
Join Date: May 2013
Location: England
Posts: 176
Reputation: 0
Default Re: Fuel bug

Bump
salev13 is offline   Reply With Quote
Old 25/02/2020, 01:19 PM   #3
salev13
Big Clucker
 
Join Date: May 2013
Location: England
Posts: 176
Reputation: 0
Default Re: Fuel bug

Someone?
salev13 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fuel system problem all vehicles use same fuel(enum variables, timers) grymtn Scripting Help 7 09/04/2017 08:16 PM
Fuel System - No Fuel Scottylad Scripting Help 3 31/10/2015 12:51 AM
[FilterScript] Fuel System [Fuel/Speed/Vehicle Name/Health] reddromero Filterscripts 5 10/05/2014 02:50 AM
Custom Fuel system taking 2 fuel instead of 1. ricardo178 Scripting Help 6 27/04/2013 10:16 AM
Fuel[i] -= 1; (Insted of taking 1, takes all fuel) HondaCBR Scripting Help 2 15/04/2012 01:03 PM


All times are GMT. The time now is 12:02 PM.


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