cobalt_management
Jobs, gangs, duty and society funds.
| Export | Side | What it does |
|---|---|---|
GetJob | Server, Client | The player's job, or nil before their character loads. |
GetGang | Server, Client | The player's gang with its rank's permissions, or nil outside a gang. |
SetJob | Server | Puts an online player in a job at a grade; false when the job or grade doesn't exist. |
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. |
GetAffiliations | Server | Job and gang per character, online or not, read from metadata.job and metadata.gang, for character lists. |
GetDuty | Server, Client | True when the player is on duty for their job, false when off. |
GetDutyCount | Server | How many online members of the job are on duty and how many are off. |
SetDuty | Server | Puts the player on or off duty and starts or ends their shift. |
HasPermission | Server | Whether the player's rank in the job holds a menu permission. |
GetEmployees | Server | Everyone in a job or gang, online or not, highest grade first. |
GetOnlineMembers | Server | Server ids of online players in the job or gang. |
SetGrade | Server | Moves an employee to another grade, online or not. |
GetDutyMinutes | Server | Minutes a character spent on duty for a job in the last days (7 when left out), the shift in progress included. |
HasGangPermission | Server | Whether the player's gang rank holds a permission. |
GetFleet | Server | Vehicles the job bought from its menu. |
OpenMenu | Server, Client | Opens a menu for a player. |
GetJobStatus | Server | Whether each job is open and what it paid out today, from the jobs table. |
SetJobOpen | Server | Opens or closes a job; city hall stops starting shifts for a closed one. |
AddJobPayout | Server | Adds a payout to the job's total for today, which starts over at midnight, server time. |
GetJob
ServerThe player's job, or nil before their character loads.
exports.cobalt_management:GetJob(source)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No |
| Returns | Description |
|---|---|
ManagementJob? |
local job = exports.cobalt_management:GetJob(source)Client
The local player's job.
exports.cobalt_management:GetJob()| Returns | Description |
|---|---|
ManagementJob? |
local job = exports.cobalt_management:GetJob()GetGang
ServerThe player's gang with its rank's permissions, or nil outside a gang.
exports.cobalt_management:GetGang(source)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No |
| Returns | Description |
|---|---|
ManagementGang? |
local gang = exports.cobalt_management:GetGang(source)Client
The local player's gang, or nil outside a gang.
exports.cobalt_management:GetGang()| Returns | Description |
|---|---|
ManagementGang? |
local gang = exports.cobalt_management:GetGang()SetJob
ServerPuts 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
name | string | No | |
grade | integer | Yes |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_management:SetJob(source, 'police', 2)SetGang
ServerPuts 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
name | string | No | |
grade | integer | Yes |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_management:SetGang(source, 'ballas', 2)GetAffiliations
ServerJob 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
citizenids | string[] | No |
| Returns | Description |
|---|---|
table<string, { job?: ManagementJob, gang?: ManagementGang }> |
local affiliations = exports.cobalt_management:GetAffiliations({ 'ABC12345', 'XYZ67890' })GetDuty
ServerTrue when the player is on duty for their job, false when off.
exports.cobalt_management:GetDuty(source)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_management:GetDuty(source)Client
True when the local player is on duty, false when off.
exports.cobalt_management:GetDuty()| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_management:GetDuty()GetDutyCount
ServerHow 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
job | string | No | job name or type |
| Returns | Description |
|---|---|
integer | onDuty |
integer | offDuty |
local onDuty, offDuty = exports.cobalt_management:GetDutyCount('police')SetDuty
ServerPuts 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
onDuty | boolean | No |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_management:SetDuty(source, true)HasPermission
ServerWhether 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
name | string | No | job or gang |
permission | ManagementPermission | No |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_management:HasPermission(source, 'police', 'open_menu')GetEmployees
ServerEveryone 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
name | string | No | job or gang |
options | table | Yes |
| Returns | Description |
|---|---|
ManagementEmployee[] |
local employees = exports.cobalt_management:GetEmployees('police', { summary = true })GetOnlineMembers
ServerServer ids of online players in the job or gang.
exports.cobalt_management:GetOnlineMembers(name)| Parameter | Type | Optional | Description |
|---|---|---|---|
name | string | No | job or gang |
| Returns | Description |
|---|---|
integer[] |
local onlineMembers = exports.cobalt_management:GetOnlineMembers('police')SetGrade
ServerMoves 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
citizenid | string | No | |
job | string | No | |
grade | integer | No |
| Returns | Description |
|---|---|
boolean | ok |
string? | error |
local ok, error = exports.cobalt_management:SetGrade('ABC12345', 'police', 2)GetDutyMinutes
ServerMinutes 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
citizenid | string | No | |
job | string | No | |
days | integer | Yes |
| Returns | Description |
|---|---|
integer |
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)| Parameter | Type | Optional | Description |
|---|---|---|---|
citizenids | string[] | No | |
job | string | No | |
days | integer | Yes |
| Returns | Description |
|---|---|
table<string, integer> |
local dutyMinutes = exports.cobalt_management:GetDutyMinutes(
{ 'ABC12345', 'XYZ67890' },
'police',
7
)HasGangPermission
ServerWhether the player's gang rank holds a permission. The boss holds all of them.
exports.cobalt_management:HasGangPermission(source, permission)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
permission | GangPermission | No |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_management:HasGangPermission(source, 'vault_withdraw')GetFleet
ServerVehicles the job bought from its menu. cobalt_garages lists them in the job's garage.
exports.cobalt_management:GetFleet(job)| Parameter | Type | Optional | Description |
|---|---|---|---|
job | string | No |
| Returns | Description |
|---|---|
ManagementFleetVehicle[] |
local fleetVehicles = exports.cobalt_management:GetFleet('police')OpenMenu
ServerOpens a menu for a player. apply takes { job = name }.
exports.cobalt_management:OpenMenu(source, menu, data)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
menu | ManagementMenu | Yes | job when left out |
data | table | Yes |
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)| Parameter | Type | Optional | Description |
|---|---|---|---|
menu | ManagementMenu | Yes | job when left out |
data | table | Yes |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_management:OpenMenu('apply', { job = 'police' })GetJobStatus
ServerWhether 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
names | string[] | No |
| Returns | Description |
|---|---|
table<string, ManagementJobStatus> | statuses by job name |
local statuses = exports.cobalt_management:GetJobStatus({ 'taxi', 'trucking' })SetJobOpen
ServerOpens 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
name | string | No | |
open | boolean | No |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_management:SetJobOpen('taxi', true)AddJobPayout
ServerAdds 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
name | string | No | |
amount | integer | No | whole dollars above 0 |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_management:AddJobPayout('taxi', 250)cobalt_mysql
The MariaDB layer, which also answers as oxmysql, mysql-async and ghmattimysql, so exports.oxmysql, exports.ghmattimysql, exports['mysql-async'] and the @oxmysql/lib/MySQL.lua include (MySQL.Async, MySQL.Sync, MySQL.ready) all reach it.
cobalt_interfaces
Draws notifications, progress bars, prompts and menus; other resources reach it through cobalt_core's interface exports.