Jobs and gangs
cobalt_core exports: jobs and gangs.
| Export | Side | What it does |
|---|---|---|
GetPlayersByJob | Server | Online players whose cobalt_management job (PlayerData.job) has this name or type, and their count. |
SetTempJob | Server | Gives the player a runtime-only job beside their real one, replacing any temp job they hold. |
ClearTempJob | Server | Ends the player's temporary job. |
GetTempJob | Server | The player's temp job, or nil when they have none. |
AddJob | Server | Adds a job at runtime and sends it to every client. |
AddJobs | Server | Adds several jobs at runtime. |
RemoveJob | Server | Removes a job at runtime. |
UpdateJob | Server | Replaces a job's definition at runtime. |
AddGang | Server | Adds a gang at runtime and sends it to every client. |
AddGangs | Server | Adds several gangs at runtime. |
RemoveGang | Server | Removes a gang at runtime. |
UpdateGang | Server | Replaces a gang's definition at runtime. |
GetPlayersByJob
ServerOnline players whose cobalt_management job (PlayerData.job) has this name or type, and their count.
exports.cobalt_core:GetPlayersByJob(job, checkOnDuty)| Parameter | Type | Optional | Description |
|---|---|---|---|
job | string | No | job name or type |
checkOnDuty | boolean | Yes | only players on duty |
| Returns | Description |
|---|---|
integer[] | players |
integer | count |
local players, count = exports.cobalt_core:GetPlayersByJob('police', true)SetTempJob
ServerGives the player a runtime-only job beside their real one, replacing any temp job they hold. Never saved; cleared on logout and when the calling resource stops. Mirrored to the cobalt:tempjob and cobalt:tempjob:label state bags.
exports.cobalt_core:SetTempJob(src, name, data)| Parameter | Type | Optional | Description |
|---|---|---|---|
src | integer | No | |
name | string | No | |
data | table | table | Yes |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_core:SetTempJob(source, 'taxi', { label = 'Downtown Cab Co.' })ClearTempJob
ServerEnds the player's temporary job.
exports.cobalt_core:ClearTempJob(src)| Parameter | Type | Optional | Description |
|---|---|---|---|
src | integer | No |
| Returns | Description |
|---|---|
boolean | cleared false when the player held no temp job |
local cleared = exports.cobalt_core:ClearTempJob(source)GetTempJob
ServerThe player's temp job, or nil when they have none.
exports.cobalt_core:GetTempJob(src)| Parameter | Type | Optional | Description |
|---|---|---|---|
src | integer | No |
| Returns | Description |
|---|---|
TempJob? |
local job = exports.cobalt_core:GetTempJob(source)AddJob
ServerAdds a job at runtime and sends it to every client.
exports.cobalt_core:AddJob(jobName, job)| Parameter | Type | Optional | Description |
|---|---|---|---|
jobName | string | No | |
job | CoreJobDefinition | No |
| Returns | Description |
|---|---|
boolean | ok |
OrgResult | message |
local ok, message = exports.cobalt_core:AddJob(
'police',
{ label = 'Los Santos Police', type = 'leo', defaultDuty = false, offDutyPay = false, grades = { ['0'] = { name = 'Cadet', payment = 50 }, ['1'] = { name = 'Officer', payment = 75 } } }
)AddJobs
ServerAdds several jobs at runtime.
exports.cobalt_core:AddJobs(jobs)| Parameter | Type | Optional | Description |
|---|---|---|---|
jobs | table<string, CoreJobDefinition> | No |
| Returns | Description |
|---|---|
boolean | ok |
string | message |
local ok, message = exports.cobalt_core:AddJobs(
{ taxi = { label = 'Downtown Cab Co.', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Driver', payment = 40 } } } }
)RemoveJob
ServerRemoves a job at runtime.
exports.cobalt_core:RemoveJob(jobName)| Parameter | Type | Optional | Description |
|---|---|---|---|
jobName | string | No |
| Returns | Description |
|---|---|
boolean | ok |
OrgResult | message |
local ok, message = exports.cobalt_core:RemoveJob('police')UpdateJob
ServerReplaces a job's definition at runtime.
exports.cobalt_core:UpdateJob(jobName, job)| Parameter | Type | Optional | Description |
|---|---|---|---|
jobName | string | No | |
job | CoreJobDefinition | No |
| Returns | Description |
|---|---|
boolean | ok |
OrgResult | message |
local ok, message = exports.cobalt_core:UpdateJob(
'police',
{ label = 'Los Santos Police', type = 'leo', defaultDuty = false, offDutyPay = false, grades = { ['0'] = { name = 'Cadet', payment = 50 }, ['1'] = { name = 'Officer', payment = 75 } } }
)AddGang
ServerAdds a gang at runtime and sends it to every client.
exports.cobalt_core:AddGang(gangName, gang)| Parameter | Type | Optional | Description |
|---|---|---|---|
gangName | string | No | |
gang | GangDefinition | No |
| Returns | Description |
|---|---|
boolean | ok |
OrgResult | message |
local ok, message = exports.cobalt_core:AddGang(
'ballas',
{ label = 'Ballas', grades = { ['0'] = { name = 'Recruit' }, ['1'] = { name = 'Shot caller', isboss = true } } }
)AddGangs
ServerAdds several gangs at runtime.
exports.cobalt_core:AddGangs(gangs)| Parameter | Type | Optional | Description |
|---|---|---|---|
gangs | table<string, GangDefinition> | No |
| Returns | Description |
|---|---|
boolean | ok |
string | message |
local ok, message = exports.cobalt_core:AddGangs(
{ vagos = { label = 'Vagos', grades = { ['0'] = { name = 'Recruit' }, ['1'] = { name = 'Jefe', isboss = true } } } }
)RemoveGang
ServerRemoves a gang at runtime.
exports.cobalt_core:RemoveGang(gangName)| Parameter | Type | Optional | Description |
|---|---|---|---|
gangName | string | No |
| Returns | Description |
|---|---|
boolean | ok |
OrgResult | message |
local ok, message = exports.cobalt_core:RemoveGang('ballas')UpdateGang
ServerReplaces a gang's definition at runtime.
exports.cobalt_core:UpdateGang(gangName, gang)| Parameter | Type | Optional | Description |
|---|---|---|---|
gangName | string | No | |
gang | GangDefinition | No |
| Returns | Description |
|---|---|
boolean | ok |
OrgResult | message |
local ok, message = exports.cobalt_core:UpdateGang(
'ballas',
{ label = 'Ballas', grades = { ['0'] = { name = 'Recruit' }, ['1'] = { name = 'Shot caller', isboss = true } } }
)