Goal

Learn how jobs are defined and assigned in QB-Core.

Job definitions

QBCore = exports['qb-core']:GetCoreObject()
 
QBCore.Shared.Jobs['tow'] = {
  label = 'Tow Truck',
  defaultDuty = true,
  grades = {
    ['0'] = { label = 'Rookie', salary = 50 },
    ['1'] = { label = 'Driver', salary = 75 }
  }
}

Assigning a job

local QBCore = exports['qb-core']:GetCoreObject()
 
QBCore.Functions.CreateCallback('tutorial:setJob', function(source, cb)
  local Player = QBCore.Functions.GetPlayer(source)
  Player.Functions.SetJob('tow', 0)
  cb(true)
end)

Going on duty

RegisterCommand('duty', function()
  TriggerServerEvent('QBCore:ToggleDuty')
end)

Verification

  • Player job shows as tow in /status
  • Duty status toggles with /duty

See also

Next steps

Explore Permissions and other Core Concepts.