QBCore Frameworkqbcore.netCommunity docs
On this page

Updated 2026-09-26 · 4 min read

How to Set Job on QBCore

Overview

Assign jobs on the server. Client checks decide what to display, not who is authorized. The examples below target the source revision in Sources; they are source-reviewed, not a FiveM test report.

Basic Job Commands

Setting Player Jobs

Use the installed core's admin command after configuring admin permissions:

/setjob 1 police 0

1 is the current server ID, not a citizen ID. Confirm that police and grade 0 exist in your actual shared/jobs.lua; never assume a third-party job uses the same names or grades.

Checking Current Job

Use the installed /job command, or inspect Player.PlayerData.job from an authorized server operation. A job definition alone does not install gameplay, uniforms, targets or a management UI.

Default QBCore Jobs

Available Jobs

QBCore.Shared.Jobs is the authority for the installed job names. Read your checked-out definitions instead of copying a static table of supposed default jobs and grades from another server.

Job Grades Explained

Shared grade keys are strings such as ['0']; the resolved Player grade has a numeric .level. At this revision, salary is PlayerData.job.grade.payment. A previous audit incorrectly treated that path as universally invalid. Older layouts can differ; use the pinned Player implementation.

Creating Custom Jobs

Step 1: Define Job in Shared Config

Add this entry inside the existing jobs table in qb-core/shared/jobs.lua:

['delivery'] = {
    label = 'Delivery',
    defaultDuty = false,
    offDutyPay = false,
    grades = {
        ['0'] = { name = 'Courier', payment = 0 },
        ['1'] = { name = 'Supervisor', payment = 0, isboss = true }
    }
},

The zero salary is deliberate for a task-paid example; it is not a recommended economy value. Restart the affected server stack in staging to load changed shared data. refresh alone does not reload a Lua table already held by running resources.

Step 2: Job Configuration Options

label is display text; defaultDuty is the initial duty state; offDutyPay controls off-duty salary eligibility; grades defines ranks and pay. Resource-specific access still needs explicit server authorization. See create a job resource.

Step 3: Add Job Permissions

A job or isboss flag does not grant QBCore admin permissions. Check administrative permissions with the server API, and gameplay access with the server-owned Player job, rank and duty state.

Server-Side Job Management

Setting Jobs via Script

This example belongs in a resource's server.lua, with dependency 'qb-core' in its manifest. It registers a separate docs_setjob command rather than replacing the built-in command.

local QBCore = exports['qb-core']:GetCoreObject()

local function AssignJob(targetId, jobName, grade)
    if type(targetId) ~= 'number' or targetId % 1 ~= 0 or targetId < 1 then return false end
    if type(jobName) ~= 'string' then return false end
    if type(grade) ~= 'number' or grade % 1 ~= 0 or grade < 0 then return false end
    local definition = QBCore.Shared.Jobs[jobName]
    if not definition or not definition.grades[tostring(grade)] then return false end
    local Player = QBCore.Functions.GetPlayer(targetId)
    if not Player then return false end
    return Player.Functions.SetJob(jobName, grade)
end

QBCore.Commands.Add('docs_setjob', 'Assign a validated job', {
    { name = 'id', help = 'Online server ID' },
    { name = 'job', help = 'Shared job name' },
    { name = 'grade', help = 'Existing grade number' }
}, true, function(src, args)
    if src ~= 0 and not QBCore.Functions.HasPermission(src, 'admin') then return end
    local ok = AssignJob(tonumber(args[1]), args[2], tonumber(args[3]))
    local message = ok and 'Job assigned' or 'Invalid player, job or grade'
    if src == 0 then
        print(message)
    else
        TriggerClientEvent('QBCore:Notify', src, message, ok and 'success' or 'error')
    end
end, 'admin')

The method returns false for an unknown job, but can construct fallback grade values. Validate both the job and grade before invoking it; do not claim success merely because a Player exists.

Job-Based Callbacks

-- server.lua, after the QBCore initialization above.
QBCore.Functions.CreateCallback('docs_jobs:server:list', function(src, cb, jobName)
    if not QBCore.Functions.HasPermission(src, 'admin') or type(jobName) ~= 'string' then
        cb({})
        return
    end
    local result = {}
    for id, Player in pairs(QBCore.Functions.GetQBPlayers()) do
        if Player.PlayerData.job.name == jobName then
            result[#result + 1] = { source = id, grade = Player.PlayerData.job.grade.level }
        end
    end
    cb(result)
end)

An admin: prefix does not secure a callback. Authorization must occur before returning privileged information. This example returns only IDs and grades, not the full Player object.

Client-Side Job Handling

Job Change Events

-- client.lua: presentation only.
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(job)
    if type(job) ~= 'table' or type(job.grade) ~= 'table' then return end
    print(('Job: %s; grade: %s; salary: %s'):format(job.label, job.grade.name, job.grade.payment))
end)

At this revision, core receives QBCore:Client:OnPlayerUpdated and forwards job-specific events. Use the payload rather than depending on handler registration order between resources.

Duty System

Request a duty change with TriggerServerEvent('QBCore:ToggleDuty'), then wait for the actual updated job state. Do not display a locally predicted success as if the server confirmed it. A custom duty desk must validate job and proximity on the server if those are requirements.

Advanced Job Features

Job-Specific Vehicles

Use the complete vehicle integration guide. Validate the job, rank, duty, allowed model and location on the server; a client-side model allowlist is not enough. Keep vehicle and key APIs aligned with the deployed resource revisions.

Job-Based Blips

This standalone client pattern owns the blips it creates and removes them before rebuilding:

local QBCore = exports['qb-core']:GetCoreObject()
local blips = {}
local locations = {
    { job = 'police', x = 428.23, y = -984.28, z = 29.76, sprite = 60, label = 'Police Department' }
}

local function RemoveJobBlips()
    for _, blip in ipairs(blips) do
        if DoesBlipExist(blip) then RemoveBlip(blip) end
    end
    blips = {}
end

local function CreateJobBlips(job)
    RemoveJobBlips()
    if not job then return end
    for _, location in ipairs(locations) do
        if job.name == location.job and job.onduty then
            local blip = AddBlipForCoord(location.x, location.y, location.z)
            SetBlipSprite(blip, location.sprite)
            SetBlipAsShortRange(blip, true)
            BeginTextCommandSetBlipName('STRING')
            AddTextComponentString(location.label)
            EndTextCommandSetBlipName(blip)
            blips[#blips + 1] = blip
        end
    end
end

local function Bootstrap()
    local data = QBCore.Functions.GetPlayerData()
    CreateJobBlips(data and data.citizenid and data.job or nil)
end

RegisterNetEvent('QBCore:Client:OnPlayerLoaded', Bootstrap)
RegisterNetEvent('QBCore:Client:OnJobUpdate', CreateJobBlips)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', RemoveJobBlips)
AddEventHandler('onClientResourceStart', function(resource)
    if resource == GetCurrentResourceName() and LocalPlayer.state.isLoggedIn then Bootstrap() end
end)
AddEventHandler('onClientResourceStop', function(resource)
    if resource == GetCurrentResourceName() then RemoveJobBlips() end
end)

Coordinates are example configuration, not a universal police station requirement.

Job-Based Permissions

Check Player.PlayerData.job.name, .grade.level and .onduty in each protected server handler. Opening an authorized menu does not authorize a later purchase, withdrawal or inventory operation.

Admin Tools

Job Management Menu

Use the actual qb-menu contract with header, txt and params, not a made-up submenu schema. The menu is presentation. Keep assignments in an independently authorized server command or handler. QBCore.Functions.HasPermission is not a client API.

Bulk Job Operations

Treat bulk assignment as a separate administrative operation: preview the affected IDs, validate every target, log the outcome and have a rollback record. The single-player command above deliberately does not mutate all online players.

Troubleshooting

Common Issues

SymptomCheck
Job resets after reconnectShared job/grade exists; save completed; correct database and character loaded
Grade appears incorrectString key exists in Shared.Jobs; do not rely on SetJob fallback
Salary is missingInspect the actual grade schema and core paycheck configuration
UI shows the old jobSubscribe to the correct revision's event; bootstrap on resource restart
Boss UI rejects the playerCheck the management resource's own job, rank and duty requirements

Debug Commands

Inspect only the needed fields using an authorized server command. Do not publish full PlayerData, license identifiers or unrelated character metadata in support logs.

Offline players

Do not write a disconnected player's raw job JSON using an assumed schema. Use an explicitly reviewed offline operation, check for a concurrent login, save through the matching core method, and test reconnect behavior. The online command above intentionally rejects offline targets.

Sources

Found an issue in this guide?

Send the page URL, the affected example, and a source or reproduction to the site maintainer. For a server or resource problem, use the support guide.

On this page

Leonida RP server website built with RPWebsite
RPWebsite

Advertisement · RPWebsite

Want a website for your server?

Launch a site with live player status, rules, and a join button in minutes.

Build your website