Skip to Content
Cobalt

cobalt_management

Jobs, gangs, duty and society funds.

ExportSideWhat it does
GetJobServer, ClientThe player's job, or nil before their character loads.
GetGangServer, ClientThe player's gang with its rank's permissions, or nil outside a gang.
SetJobServerPuts an online player in a job at a grade; false when the job or grade doesn't exist.
SetGangServerPuts an online player in a gang at a grade (none to remove them); false when the gang or grade doesn't exist.
GetAffiliationsServerJob and gang per character, online or not, read from metadata.job and metadata.gang, for character lists.
GetDutyServer, ClientTrue when the player is on duty for their job, false when off.
GetDutyCountServerHow many online members of the job are on duty and how many are off.
SetDutyServerPuts the player on or off duty and starts or ends their shift.
HasPermissionServerWhether the player's rank in the job holds a menu permission.
GetEmployeesServerEveryone in a job or gang, online or not, highest grade first.
GetOnlineMembersServerServer ids of online players in the job or gang.
SetGradeServerMoves an employee to another grade, online or not.
GetDutyMinutesServerMinutes a character spent on duty for a job in the last days (7 when left out), the shift in progress included.
HasGangPermissionServerWhether the player's gang rank holds a permission.
GetFleetServerVehicles the job bought from its menu.
OpenMenuServer, ClientOpens a menu for a player.
GetJobStatusServerWhether each job is open and what it paid out today, from the jobs table.
SetJobOpenServerOpens or closes a job; city hall stops starting shifts for a closed one.
AddJobPayoutServerAdds a payout to the job's total for today, which starts over at midnight, server time.

GetJob

Server

The player's job, or nil before their character loads.

exports.cobalt_management:GetJob(source)
ParameterTypeOptionalDescription
sourceintegerNo
ReturnsDescription
ManagementJob?
Example
local job = exports.cobalt_management:GetJob(source)

Client

The local player's job.

exports.cobalt_management:GetJob()
ReturnsDescription
ManagementJob?
Example
local job = exports.cobalt_management:GetJob()

GetGang

Server

The player's gang with its rank's permissions, or nil outside a gang.

exports.cobalt_management:GetGang(source)
ParameterTypeOptionalDescription
sourceintegerNo
ReturnsDescription
ManagementGang?
Example
local gang = exports.cobalt_management:GetGang(source)

Client

The local player's gang, or nil outside a gang.

exports.cobalt_management:GetGang()
ReturnsDescription
ManagementGang?
Example
local gang = exports.cobalt_management:GetGang()

SetJob

Server

Puts an online player in a job at a grade; false when the job or grade doesn't exist.

exports.cobalt_management:SetJob(source, name, grade)
ParameterTypeOptionalDescription
sourceintegerNo
namestringNo
gradeintegerYes
ReturnsDescription
boolean
Example
local ok = exports.cobalt_management:SetJob(source, 'police', 2)

SetGang

Server

Puts an online player in a gang at a grade (none to remove them); false when the gang or grade doesn't exist.

exports.cobalt_management:SetGang(source, name, grade)
ParameterTypeOptionalDescription
sourceintegerNo
namestringNo
gradeintegerYes
ReturnsDescription
boolean
Example
local ok = exports.cobalt_management:SetGang(source, 'ballas', 2)

GetAffiliations

Server

Job and gang per character, online or not, read from metadata.job and metadata.gang, for character lists. Characters with neither are left out.

exports.cobalt_management:GetAffiliations(citizenids)
ParameterTypeOptionalDescription
citizenidsstring[]No
ReturnsDescription
table<string, { job?: ManagementJob, gang?: ManagementGang }>
Example
local affiliations = exports.cobalt_management:GetAffiliations({ 'ABC12345', 'XYZ67890' })

GetDuty

Server

True when the player is on duty for their job, false when off.

exports.cobalt_management:GetDuty(source)
ParameterTypeOptionalDescription
sourceintegerNo
ReturnsDescription
boolean
Example
local ok = exports.cobalt_management:GetDuty(source)

Client

True when the local player is on duty, false when off.

exports.cobalt_management:GetDuty()
ReturnsDescription
boolean
Example
local ok = exports.cobalt_management:GetDuty()

GetDutyCount

Server

How many online members of the job are on duty and how many are off. Matches the job's name or its type (leo, ems).

exports.cobalt_management:GetDutyCount(job)
ParameterTypeOptionalDescription
jobstringNojob name or type
ReturnsDescription
integeronDuty
integeroffDuty
Example
local onDuty, offDuty = exports.cobalt_management:GetDutyCount('police')

SetDuty

Server

Puts the player on or off duty and starts or ends their shift. The change stays in memory; characters log in on their job's default duty while cobalt_core's forceDefaultDutyAtLogin is on.

exports.cobalt_management:SetDuty(source, onDuty)
ParameterTypeOptionalDescription
sourceintegerNo
onDutybooleanNo
ReturnsDescription
boolean
Example
local ok = exports.cobalt_management:SetDuty(source, true)

HasPermission

Server

Whether the player's rank in the job holds a menu permission. Boss ranks hold all of them; in a gang only the boss holds them.

exports.cobalt_management:HasPermission(source, name, permission)
ParameterTypeOptionalDescription
sourceintegerNo
namestringNojob or gang
permissionManagementPermissionNo
ReturnsDescription
boolean
Example
local ok = exports.cobalt_management:HasPermission(source, 'police', 'open_menu')

GetEmployees

Server

Everyone in a job or gang, online or not, highest grade first. It lists main jobs only, not second jobs. summary skips the duty, leave and bonus totals, so weekMinutes, lastWeekMinutes and monthBonuses are 0, onLeave is false and shiftStartedAt is nil. Gangs always get those defaults.

exports.cobalt_management:GetEmployees(name, options)
ParameterTypeOptionalDescription
namestringNojob or gang
optionstableYes
ReturnsDescription
ManagementEmployee[]
Example
local employees = exports.cobalt_management:GetEmployees('police', { summary = true })

GetOnlineMembers

Server

Server ids of online players in the job or gang.

exports.cobalt_management:GetOnlineMembers(name)
ParameterTypeOptionalDescription
namestringNojob or gang
ReturnsDescription
integer[]
Example
local onlineMembers = exports.cobalt_management:GetOnlineMembers('police')

SetGrade

Server

Moves an employee to another grade, online or not. Someone holding the job as a second job keeps it as one.

exports.cobalt_management:SetGrade(citizenid, job, grade)
ParameterTypeOptionalDescription
citizenidstringNo
jobstringNo
gradeintegerNo
ReturnsDescription
booleanok
string?error
Example
local ok, error = exports.cobalt_management:SetGrade('ABC12345', 'police', 2)

GetDutyMinutes

Server

Minutes a character spent on duty for a job in the last days (7 when left out), the shift in progress included. Jobs keep daily totals for twice dutyPeriodDays (14 days by default); a longer days returns every minute on record. Pass a list of citizenids to get them all at once, as a table keyed by citizenid with 0 for each one without duty time.

exports.cobalt_management:GetDutyMinutes(citizenid, job, days)
ParameterTypeOptionalDescription
citizenidstringNo
jobstringNo
daysintegerYes
ReturnsDescription
integer
Example
local dutyMinutes = exports.cobalt_management:GetDutyMinutes('ABC12345', 'police', 7)

Server

Minutes a character spent on duty for a job in the last days (7 when left out), the shift in progress included. Jobs keep daily totals for twice dutyPeriodDays (14 days by default); a longer days returns every minute on record. Pass a list of citizenids to get them all at once, as a table keyed by citizenid with 0 for each one without duty time.

exports.cobalt_management:GetDutyMinutes(citizenids, job, days)
ParameterTypeOptionalDescription
citizenidsstring[]No
jobstringNo
daysintegerYes
ReturnsDescription
table<string, integer>
Example
local dutyMinutes = exports.cobalt_management:GetDutyMinutes(
    { 'ABC12345', 'XYZ67890' },
    'police',
    7
)

HasGangPermission

Server

Whether the player's gang rank holds a permission. The boss holds all of them.

exports.cobalt_management:HasGangPermission(source, permission)
ParameterTypeOptionalDescription
sourceintegerNo
permissionGangPermissionNo
ReturnsDescription
boolean
Example
local ok = exports.cobalt_management:HasGangPermission(source, 'vault_withdraw')

GetFleet

Server

Vehicles the job bought from its menu. cobalt_garages lists them in the job's garage.

exports.cobalt_management:GetFleet(job)
ParameterTypeOptionalDescription
jobstringNo
ReturnsDescription
ManagementFleetVehicle[]
Example
local fleetVehicles = exports.cobalt_management:GetFleet('police')

OpenMenu

Server

Opens a menu for a player. apply takes { job = name }.

exports.cobalt_management:OpenMenu(source, menu, data)
ParameterTypeOptionalDescription
sourceintegerNo
menuManagementMenuYesjob when left out
datatableYes
Example
exports.cobalt_management:OpenMenu(source, 'apply', { job = 'police' })

Client

Opens a menu for the local player; false when it isn't available to them.

exports.cobalt_management:OpenMenu(menu, data)
ParameterTypeOptionalDescription
menuManagementMenuYesjob when left out
datatableYes
ReturnsDescription
boolean
Example
local ok = exports.cobalt_management:OpenMenu('apply', { job = 'police' })

GetJobStatus

Server

Whether each job is open and what it paid out today, from the jobs table. A job with no row is open with nothing paid.

exports.cobalt_management:GetJobStatus(names)
ParameterTypeOptionalDescription
namesstring[]No
ReturnsDescription
table<string, ManagementJobStatus>statuses by job name
Example
local statuses = exports.cobalt_management:GetJobStatus({ 'taxi', 'trucking' })

SetJobOpen

Server

Opens or closes a job; city hall stops starting shifts for a closed one. False when the name or flag is invalid.

exports.cobalt_management:SetJobOpen(name, open)
ParameterTypeOptionalDescription
namestringNo
openbooleanNo
ReturnsDescription
boolean
Example
local ok = exports.cobalt_management:SetJobOpen('taxi', true)

AddJobPayout

Server

Adds a payout to the job's total for today, which starts over at midnight, server time. False when the name or amount is invalid.

exports.cobalt_management:AddJobPayout(name, amount)
ParameterTypeOptionalDescription
namestringNo
amountintegerNowhole dollars above 0
ReturnsDescription
boolean
Example
local ok = exports.cobalt_management:AddJobPayout('taxi', 250)

On this page