How can i check the job

Hello, i need to chceck if player have a job and if he have then add the ox_target to the position but when he doesnt have role then he cant access it ( if i change the job it must update ) thx for respond my code is this

ESX = exports["es_extended"]:getSharedObject()


RegisterNetEvent('bx:test')
AddEventHandler('bx:test', function()
    print("Úspěšně si kliknul na očičko :-)")
end)

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
	if ESX.PlayerData.job and ESX.PlayerData.job.name == 'exotic' then
        exports.ox_target:addBoxZone({
            coords = vec3(82.9045, -1009.6147, 29.3085),
            size = vec3(2,2,2),
            rotation = 29.3570,
            options = {
                {
                    icon = 'fa-solid fa-store',
                    label = 'Otevřít Menu',
                    event = 'bx:test',
                },
            },
            distance = 2
        })
        end
    end
end)

its server or client i think its server am i right ?

The above code is unnecessary. Try this.
you also don’t need to get the shared object unless it is being called later in the script.

ESX = exports["es_extended"]:getSharedObject()

RegisterNetEvent('bx:test')
AddEventHandler('bx:test', function()
    print("Úspěšně si kliknul na očičko :-)")
end)

Citizen.CreateThread(function()
        exports.ox_target:addBoxZone({
            coords = vec3(82.9045, -1009.6147, 29.3085),
            size = vec3(2,2,2),
            rotation = 29.3570,
            options = {
                {
                    icon = 'fa-solid fa-store',
                    label = 'Otevřít Menu',
                    event = 'bx:test',
                    groups = 'exotic'
                },
            },
            distance = 2
        })
end)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.