if Config.framework == "esx" or Config.framework == "newesx" then
    if Config.framework == "newesx" then
        ESX = exports["es_extended"]:getSharedObject()

        Citizen.CreateThread(function()
            while ESX.GetPlayerData().job == nil do
                Citizen.Wait(10)
            end
            if ESX.IsPlayerLoaded() then
                ESX.PlayerData = ESX.GetPlayerData()

            end
        end)
    else
        ESX = nil
        Citizen.CreateThread(function()
            while ESX == nil do
                TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
                Citizen.Wait(10)
            end
            while ESX.GetPlayerData().job == nil do
                Citizen.Wait(10)
            end
            if ESX.IsPlayerLoaded() then
                ESX.PlayerData = ESX.GetPlayerData()
            end
        end)
    end

    RegisterNetEvent('esx:setJob')
    AddEventHandler('esx:setJob', function(job)
        ESX.PlayerData.job = job
        if Config.usetarget == true then
            createtargetjob() -- don't delete
        end
    end)

    
    function getPlayerJob()
        if ESX and ESX.PlayerData and ESX.PlayerData.job then
            return ESX.PlayerData.job.name
        else
            return nil 
        end
    end

    function TriggerServerCallback(name, cb, ...)
        ESX.TriggerServerCallback(name, cb, ...)
    end

    function notificationfunction(message, typeNotif)
        if Config.notif == "ESX" then
            ESX.ShowNotification(message)
        elseif Config.notif == "OX" then
            lib.notify({
                description = message,
                position = 'top',
                type = typeNotif,
            })
        elseif Config.notif == "custom" then
            Config.customnotif(message, typeNotif)
        end
    end

    function helpnotificationfunction(message, position)
        if Config.interact == "esx" then
            ESX.ShowHelpNotification(message)
        elseif Config.interact == "floating" then
            AddTextEntry('HelpText', message)
            SetFloatingHelpTextWorldPosition(1, position)
            SetFloatingHelpTextStyle(1, 1, 2, -1, 3, 0)
            BeginTextCommandDisplayHelp('HelpText')
            EndTextCommandDisplayHelp(2, false, false, -1)
        elseif Config.interact == "draw3dtext" then
            DrawText3D(position.x, position.y, position.z, message)
        end
    end

    function DrawText3D(x, y, z, text)
        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.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
        ClearDrawOrigin()
    end

    RegisterNetEvent('esx:playerLoaded')
    AddEventHandler('esx:playerLoaded', function(xPlayer)
        initialiseScripts()
    end)
end