Unsure why it doesn't have this in core, sorta makes sense but doesn't anyway heres what we did for my Server and it works well. If ur clueless and don't know what your doing, DO NOT ASK FOR HELP. I'm not helping you, ask quasar they have very good support trust! 🙏
shared/jobs.lua
Add a subjobs table to the job(s) that should have divisions. For police, add it after offDutyPay.
Replace the police job’s opening so it includes subjobs:
["police"] = {
label = "Police Patrol",
type = "leo",
defaultDuty = true,
offDutyPay = false,
subjobs = {
["patrol"] = {
label = "Patrol",
grades = { [0] = { name = "Patrol Officer", payment = 0 } },
},
["swat"] = {
label = "Special Weapons and Tactics",
grades = {
[0] = { name = "SWAT - Trial Operative", isboss = false, bankAuth = false },
[1] = { name = "SWAT - Operator", isboss = false, bankAuth = false },
-- add more grades as needed
},
},
["cid"] = {
label = "Criminal Investigations Division",
grades = {
[0] = { name = "CID - Trial Detective", isboss = false, bankAuth = false },
-- etc
},
},
["teu"] = {
label = "Traffic Enforcement Unit",
grades = {
[0] = { name = "TEU - Officer I", isboss = false, bankAuth = false },
-- etc
},
},
},
grades = {
Same pattern works for other jobs: add subjobs = { ["subjobname"] = { label = "...", grades = { [0] = { name = "...", ... } } }, ... } to that job.
shared/functions.lua
In GetPlayerGroups https://github.com/Qbox-project/qbx_core/blob/main/shared/functions.lua#L76, after the loop that fills groups from playerData.jobs, add subjob as group so ox_inventory etc. can use it:
After the for job, data in pairs(playerData.jobs) block, before the for gang, data loop, insert:
local mainJob = playerData.job
if mainJob and mainJob.name == "police" and mainJob.subjob and mainJob.subjobGrade then
local subjobAsGroup = { swat = true, cid = true, teu = true }
if subjobAsGroup[mainJob.subjob] then
groups[mainJob.subjob] = mainJob.subjobGrade.level
end
end
If you add subjobs to other jobs, extend subjobAsGroup or derive it from the job’s subjobs table.
server/groups.lua
After exports("GetGang", GetGang) and before local function upsertJobData. https://github.com/Qbox-project/qbx_core/blob/main/server/groups.lua#L287
Add:
---@param jobName string
---@return table<string, Subjob>?
function GetSubjobs(jobName)
local job = jobs[jobName]
return job and job.subjobs or nil
end
exports("GetSubjobs", GetSubjobs)
---@param jobName string
---@param subjobName string
---@return Subjob?
function GetSubjob(jobName, subjobName)
local subjobs = GetSubjobs(jobName)
return subjobs and subjobs[subjobName:lower()] or nil
end
exports("GetSubjob", GetSubjob)