lua
local Jobs = exports.jcks_jobsExports that read the database yield. Call them from a thread, an event handler or a command.
Server exports
Duty and jobs
| Export | Returns | Description |
|---|---|---|
IsOnDuty(src) |
boolean | |
SetDuty(src, state) |
boolean | Sets duty, returns the new state. Always false for unemployed players |
GetOnDutyCount(job) |
number | Players on duty in a job |
GetShiftSeconds(src) |
number | Length of the current shift, 0 off duty |
GetJob(name) |
{ name, label, data, grades } or nil |
Full job definition |
GetJobs() |
{ name, label, type }[] |
Every job |
GetJobsByType(type) |
string[] |
Job names of one type, for example 'leo' or 'ems' |
HasPermission(src, permission) |
boolean | Grade permission of the current job, see permissions |
IsBoss(src), isBoss(src) |
boolean | Current grade is a boss grade |
GetSetting(key) |
any | Current value of a server setting, for example 'MultiJob.maxJobs' |
IsSettingsReady() |
boolean | Settings are loaded after the start |
SetSettingValues(values, actor?) |
boolean, errors |
Changes server settings, for example { ['MultiJob.maxJobs'] = 4 }. Every value is checked like in Server settings. A player as actor needs jobs.settings |
ClearSettingOverrides(keys) |
boolean | Resets the given settings to the values of the settings files |
IsPayrollActive() |
boolean | Config.Payroll.enabled is on |
Log(category, action, src?, job?, details?) |
nil | Activity log and Discord. Categories: admin, boss, finance, duty, work, tools, security |
SendPulse(src, data) |
boolean | Pulse card, see below |
Employees and company money
| Export | Returns | Description |
|---|---|---|
HireEmployee(identifier, job, grade) |
boolean, err? |
Online or offline. Respects multijob slots |
FireEmployee(identifier, job) |
boolean, err? |
|
SetEmployeeGrade(identifier, job, grade) |
boolean, err? |
|
GetEmployees(job) |
table[] |
{ identifier, name, grade, gradeLabel, isBoss, online, active, onDuty } |
GetPlayerJobs(identifier) |
{ [job] = grade } |
Every job the character holds |
GetSocietyMoney(job) |
number | Company balance |
AddSocietyMoney(job, amount, note?) |
boolean | Deposit, shown in the job's transactions |
RemoveSocietyMoney(job, amount, note?) |
boolean | Withdraw, only when the balance is high enough |
Invoices and service calls
| Export | Returns | Description |
|---|---|---|
CreateInvoice(target, job, amount, reason?, sender?) |
id or nil, err |
target is a server id or an identifier |
BillFromPlayer(src, target, amount, reason?, job?) |
id, true or nil, err |
Invoice from one player to another with every rule of the invoice window: billing permission, duty, distance, amount limit. job must be the sender's current job. true = ServerEditable.SendInvoice handled it. Used by jcks_compat_billing |
GetInvoices(identifier) |
table[] |
Invoices of a character |
PayInvoice(src, id) |
boolean, err? |
Pays with the normal checks |
DeclineInvoice(src, id) |
boolean, err? |
|
TerminalPay(src, id, token, tip) |
Finishes a terminal charge from a device | |
TerminalCancel(src, id, token) |
Cancels a terminal charge | |
SendServiceCall(src, job, message) |
table or nil, err |
Same as the player using /call |
Dispatch
| Export | Returns | Description |
|---|---|---|
SendDispatch(data), SendAlert(data) |
call id or nil | kind (police, ems, fire), code, title, message, priority 1 to 3, coords, street, blip, info, caller, jobs, radius, panic, see below |
GetDispatchCalls() |
table[] |
Open calls |
ClearDispatch(id) |
boolean | Closes a call |
GetDispatchRoster() |
table | Units on duty |
SetUnitStatus(src, status) |
boolean, err? |
available, busy, enroute, onscene, offline |
GetUnit(src) |
{ status, callsign, call } or nil |
|
SendCrimeAlert(kind, coords, data) |
Sends an alert of a Config.Alerts.kinds kind |
SendDispatch field |
Type | Default | What it does |
|---|---|---|---|
kind |
string | 'police' |
police, ems or fire. job is read when kind is missing |
code |
string | '10-31' |
Radio code, up to 12 characters. Sets the colour, blip and receivers from Config.Dispatch |
title |
string | 'Incident' |
Up to 80 characters |
message |
string | none | Up to 300 characters, description is read when it is missing |
priority |
number | 2 |
1 low, 2 medium, 3 critical |
coords |
vector3 | none | Position of the call |
street |
string | none | Up to 80 characters |
caller |
string | the calling resource | Up to 60 characters |
blip |
number | from blips.codes |
Blip sprite |
info |
table | none | Lines on the card, { icon, text } |
jobs |
table | from receivers.codes |
Only these jobs see, respond to and clear the call. A list ({ 'police', 'sheriff' }) or a set ({ police = true }) |
radius |
number | none | Metres, 10 to 500. The blip becomes a search circle |
panic |
boolean | false |
Pinned red card like the panic button. Calls with the panic or officer down code are always panic calls |
Field tools
| Export | Returns | Description |
|---|---|---|
IsRestrained(src) |
string or false | Restraint type |
SetRestrained(src, kind) |
boolean | Restrains without animation, kind = false releases |
StopEscort(src) |
nil | |
GetPlacedProps() |
table[] |
{ netId, key, job, owner, coords } |
ClearProps(coords, radius) |
number | Removes props around a position, radius 30 by default |
Medical
| Export | Returns | Description |
|---|---|---|
IsDown(src) |
boolean | |
Revive(src) |
Forced revive | |
Heal(src) |
||
GetInjuries(src) |
table | Per body part kind, severity 0 to 100 and level 1 to 3 |
Jail
| Export | Returns | Description |
|---|---|---|
IsJailed(src) |
||
JailPlayer(target, months, reason) |
boolean | Adds the months to a running sentence |
UnjailPlayer(target) |
Job groups
| Export | Returns | Description |
|---|---|---|
GetJobGroup(job) |
{ [job] = true } |
Jobs that share dispatch units with this job |
GetJobGroups() |
table[] |
{ id, label, color, icon, category, jobs } |
GetGroupOf(job) |
group or nil | With its settings.share switches |
AreJobsGrouped(a, b, feature?) |
boolean | feature: dispatch, calls, doors, stashes, mdt |
Fire, gigs, minigames
| Export | Description |
|---|---|
StartFire(coords, size?, opts?), StopFire(id), GetFires(), IsFireNear(coords, radius) |
See Fire department |
GetGigLevel(identifier, gigId), IsOnGig(src), GetGigContracts() |
See Gigs |
RegisterGigStep(kind, def), GigStepTypes() |
See Gigs |
StartMinigame(src, idOrDef, opts?), GetMinigames() |
See Minigames |
Evidence, cameras, forensics, devices
| Export | Description |
|---|---|
AddEvidence(data) |
Logs an evidence item: label, category, caseRef, identifier, plate, coords, ref. Returns the id |
RegisterCamera(def), RemoveCamera(id) |
Adds a camera to /cameras: { id?, label, group?, coords, rot = { x, z }, fov?, pan?, jobs?, expires? }. Removed when the owner stops |
AddDashcamEvent(event), GetDashcamEvents(filter) |
Rows in the shared camera archive |
GetBiometricProfile(identifier), AddTrace(trace) |
Forensic profile, add a trace (type = blood, casing, fingerprint or impact, with coords or plate, optional dna, fingerprint, serial, weapon, calibre, place, indoor). Returns the trace id |
SetRaining(state), IsRaining() |
Weather scripts tell forensics whether it rains. true or false overrides the players' reports, nil hands it back to them. Both return the current state |
BodycamEvent(src, kind, data), BodycamRelease(serial), BodycamActive(src) |
Bodycam device events, accepted only from the trusted provider |
WiretapRecord(data), GetWiretaps() |
Wiretap records and active taps |
MdtOpen(src, page?, ctx?), MdtCan(src, feature), MdtNotify(target, data), MdtDeviceProvider() |
MDT on a device |
MdtCall(src, name, payload) |
Runs one MDT request for a player through the same job, duty, permission, device and rate checks as the MDT window. name: boot, overview, search, person, vehicle, warrants, warrant, bolos, bolo, reports, report, bulletins, roster. Works only while jcks_electronics provides the MDT, otherwise nil, 'feature_disabled'. Returns the data or nil, err |
MdtHasWarrant(identifier), MdtWarrants(identifier) |
Active warrants of a character: true or false, or up to 20 { id, reason, issuedBy, created }. nil while the MDT is off |
MdtAddWarrant(identifier, data) |
Issues a warrant: data.reason (required, up to 160 characters), data.details, data.by. Returns the id or nil, err |
MdtRegisterPage(def), MdtRegisterPersonTab(def), MdtRegisterVehicleTab(def), MdtRegisterSearch(kind, label, handler, verifiedResource) |
Own MDT pages, tabs and search sources. Other resources register them through jcks_bridge |
ClearConfigOverrides(paths) |
Removes in game overrides of the given config paths |
Pulse card
lua
exports.jcks_jobs:SendPulse(src, {
title = 'Dispatch',
subtitle = 'Code 3',
text = 'Robbery in progress at Fleeca Bank',
icon = 'siren',
color = '#FF453A',
duration = 7000,
})Client exports
| Export | Returns | Description |
|---|---|---|
IsOnDuty() |
boolean | |
GetShiftSeconds() |
number | |
HasPermission(permission) |
boolean | |
IsBoss(), isBoss() |
boolean | |
GetJobData(name) |
table or nil | Public job data: label, colour, icon, type |
OpenBossMenu() |
nil | The server still checks permissions |
OpenJobCenter(), OpenMyJobs(), OpenInvoices() |
nil | |
OpenInvoice(serverId) |
nil | Invoice window for a player |
IsRestrained() |
string or false | |
IsEscorted(), IsCarryingProp() |
boolean | |
IsDown() |
boolean | |
Panic() |
nil | Presses the panic button |
CallService(job, message) |
nil | |
RespondToCall() |
nil |
lua
exports.jcks_lib:AddRadialItem({
{ id = 'boss_menu', label = 'Boss menu', icon = 'briefcase', onSelect = function() exports.jcks_jobs:OpenBossMenu() end },
})Events
All events are local (AddEventHandler).
Server
| Event | Arguments |
|---|---|
jcks_jobs:dutyChanged |
src, onDuty, job, shiftSeconds? |
jcks_jobs:hired |
identifier, job, grade |
jcks_jobs:fired |
identifier, job |
jcks_jobs:restrained |
target, kind, by (kind = false when released) |
jcks_jobs:escortChanged |
target, by (by = false when the escort ends) |
jcks_jobs:downChanged |
src, isDown (built in medical system) |
jcks_jobs:fireStarted |
id, coords, cause |
jcks_jobs:fireStopped |
id, reason (extinguished, cleared, stopped, burned_out) |
jcks_jobs:dispatchCall |
op, call, targets (op = new, update, removed) |
jcks_jobs:bodycamClip |
clip table |
jcks_jobs:groupsChanged |
|
jcks_jobs:settingsChanged |
changes |
jcks_jobs:configChanged |
paths, every changed config path |
jcks_jobs:settingsReady |
Settings are loaded |
jcks_jobs:mdtReady, jcks_jobs:gigStepsReady |
Register MDT pages or gig steps again |
Client
| Event | Arguments |
|---|---|
jcks_jobs:dutyChanged |
onDuty |
jcks_jobs:jobUpdated |
job (normalized bridge job) |
jcks_jobs:restrainedChanged |
kind (false when released) |
jcks_jobs:dispatchCall |
op, call, device (watch, vehicle or false) |
jcks_jobs:shift |
{ active, device, job, label, color, icon, elapsed, startedAt } |
jcks_jobs:mdtClosed |
via |
jcks_jobs:settingsApplied |
New settings from the server are applied |
jcks_jobs:gigDeviceDone |
token, fire it yourself when a device task is done |
lua
AddEventHandler('jcks_jobs:dutyChanged', function(src, onDuty, job, shiftSeconds)
if job == 'police' and not onDuty and shiftSeconds then
exports.jcks_bridge:AddMoney(src, 'bank', math.floor(shiftSeconds / 60) * 5, 'shift bonus')
end
end)State bags
| State bag | Value |
|---|---|
Player(src).state['jcks:duty'] |
true or false |
Player(src).state['jcks:unit'] |
{ status, callsign, call } |
jcks:restrained |
'handcuffs', 'zipties' or false |
isCuffed |
true or false |
jcks:escortedBy |
Server id of the escorting player or false |
jcks:escorting |
Server id of the escorted player or false |
jcks:jailed |
true while the player is in jail |
jcks:bodycam |
true while the bodycam is on |
isDead, dead |
true while the player is down in the built in medical system |
Entity(prop).state['jcks:prop'] |
{ key, job, owner } on placed trunk props |
Entity(vehicle).state['jcks:job'] |
{ job, owner, point } on job garage vehicles |
GlobalState['jcks:duty'] |
{ [job] = count } of players on duty |
GlobalState['jcks:fires'] |
Burning fires |
Client:
lua
local onDuty = LocalPlayer.state['jcks:duty']Server:
lua
local onDuty = Player(src).state['jcks:duty']Editable hooks
editable/server.lua:
| Function | When |
|---|---|
ServerEditable.CanHire(src, jobName, grade) |
Before a hire. Return false, 'locale_key' to refuse. src is nil for offline applications. Admin hires skip it |
ServerEditable.OnHired(identifier, jobName, grade, src) |
After a hire |
ServerEditable.OnGradeChanged(identifier, jobName, grade, src) |
After a promotion or demotion |
ServerEditable.OnFired(identifier, jobName, src) |
After firing |
ServerEditable.OnDutyChanged(src, jobName, onDuty, shiftSeconds) |
Duty change |
ServerEditable.OnExploitScore(src, identifier, score, reasons) |
Once when a character reaches the exploit score threshold |
ServerEditable.IsDown(src) |
Down detection |
ServerEditable.OnRestrained(target, kind, src) |
Restraint change |
ServerEditable.SendInvoice(src, target, jobName, amount, reason) |
Return true when your billing handled it |
ServerEditable.OnPanic(src, jobName, coords) |
Panic button |
ServerEditable.OnServiceCall(src, jobName, message, coords) |
Return true when your dispatch handled it |
ServerEditable.OnRespawn(src) |
Hospital respawn |
ServerEditable.Revive(target, src), ServerEditable.Heal(target, src) |
Revive and heal job actions |
ServerEditable.OnImpound(src, vehicle, plate) |
Impound job action |
ServerEditable.SendAlert(alert, provider) |
While the JCKS dispatch is off: alerts with the alert target custom or that a built in adapter could not send. Return true when you sent it |
editable/client.lua: ClientEditable.CanOpenMenu(app), OnDutyChanged(onDuty, jobName), IsDown(serverId, ped), OnRestrained(kind), DispatchAlert(call), SendAlert(alert, provider) and Overrides.
lua
function ServerEditable.CanHire(src, jobName, grade)
if jobName == 'police' then
local officers = #exports.jcks_jobs:GetEmployees('police')
if officers >= math.max(2, math.floor(#GetPlayers() / 10)) then
return false, 'job_full'
end
end
return true
end