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()
        MapPlayerLoaded()
    end)
end)

function Draw3DText(data)
    local text = data.text
    local x = data.coords.x
    local y = data.coords.y
    local z = data.coords.z
    SetTextScale(0.35, 0.35)
    SetTextFont(4)
    SetTextProportional(1)
    SetTextColour(255, 255, 255, 215)
    SetTextEntry("STRING")
    SetTextCentre(true)
    AddTextComponentString(text)
    SetDrawOrigin(x,y,z, 0)
    DrawText(0.0, 0.0)
    local factor = (string.len(text)) / 370
    DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
    ClearDrawOrigin()
end

function Notify(type, text, duration)
    SendNUIMessage({
        action = "Notify",
        type = type,
        text = text,
        duration = duration
    })
end

Last updated