cl_utils.lua

Framework = nil
loadEvent = "QBCore:Client:OnPlayerLoaded"

CreateThread(function()
    if not Framework then
        if GetResourceState("qbx_core") == "started" then
            Framework = "qb"
        elseif GetResourceState("es_extended") == "started" then
            Framework = "esx"
        elseif GetResourceState("qb-core") == "started" then 
            Framework = "qb"
        end
    end
end)

CreateThread(function()
    if Framework == "qb" then
        loadEvent = "QBCore:Client:OnPlayerLoaded"
    elseif Framework == "esx" then
        loadEvent = 'esx:playerLoaded'
    elseif Framework == "oldEsx" then
        loadEvent = 'esx:playerLoaded'
    end

    RegisterNetEvent(loadEvent, function()
        
    end)
end)

function GetFuel(veh)
    return exports["LegacyFuel"]:GetFuel(veh)
end

function GetEngineHealth(veh)
    if veh == 0 then return 0 end
    local health = GetVehicleEngineHealth(veh)
    return health / 10
end


local weatherTemps = {
    [GetHashKey("EXTRASUNNY")] = 30, 
    [GetHashKey("CLEAR")] = 28,      
    [GetHashKey("NEUTRAL")] = 25, 
    [GetHashKey("SMOG")] = 25,    
    [GetHashKey("FOGGY")] = 17,
    [GetHashKey("OVERCAST")] = 18,
    [GetHashKey("CLOUDY")] = 22,  
    [GetHashKey("CLEARIN")] = 20,
    [GetHashKey("RAIN")] = 15,  
    [GetHashKey("THUNDER")] = 14,
    [GetHashKey("BLIZZARD")] = 5,    
    [GetHashKey("SNOW")] = 0, 
    [GetHashKey("XMAS")] = 0, 
}

function GetWeather()
    local type1, type2, percent = GetWeatherTypeTransition()
    return weatherTemps[type1] or 20
end

Last updated