Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update client.lua #125

Closed
wants to merge 3 commits into from
Closed

Update client.lua #125

wants to merge 3 commits into from

Conversation

ItzMuri
Copy link

@ItzMuri ItzMuri commented Sep 5, 2024

No description provided.

@Lionh34rt
Copy link

I believe that better practice would be to create a setFuel function in the config instead of creating if else statements in the general code

@ItzMuri
Copy link
Author

ItzMuri commented Nov 5, 2024

local lastFuelUpdate = 0
local lastFuelCheck = 0

local function getFuelLevel(vehicle)
    local updateTick = GetGameTimer()
    
    if (updateTick - lastFuelUpdate) > 2000 then
        lastFuelUpdate = updateTick
        
        if Config.FuelScript == "ox_fuel" then
            lastFuelCheck = math.floor(Entity(vehicle).state.fuel or 0) -- Default to 0 if fuel state is not set
        elseif Config.FuelScript == "ps-fuel" then
            lastFuelCheck = math.floor(exports[Config.FuelScript]:GetFuel(vehicle) or 0) -- Default to 0 if GetFuel returns nil
        end
    end
    
    return lastFuelCheck
end


``` like this

@ItzMuri ItzMuri closed this Nov 6, 2024
@ItzMuri ItzMuri deleted the patch-1 branch November 6, 2024 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants