Server and client exports, local events and state bags of JCKS Jobs 1.0.0 for other resources.
All exports are called as exports.jcks_jobs:Name(...). Framework, inventory, money and target functions are in Bridge V1 exports .
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 player's current grade
IsBoss(src), isBoss(src)
boolean
Current grade is a boss grade
GetSetting(key)
any
Current value of a setting, for example 'MultiJob.maxJobs'
GetJobGroup(job)
{ [job] = true }
Jobs in the same Config.JobGroups group
Company and employees #
Export
Returns
Description
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
HireEmployee(identifier, job, grade)
boolean, err?
Hires a character 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
SendPulse(src, data)
boolean
Pulse card, see below
Log(category, action, src?, job?, details?)
nil
Activity log and Discord. category: admin, boss, finance, duty, work, security
Invoices and calls #
Export
Returns
Description
CreateInvoice(target, job, amount, reason?, sender?)
id, or nil, err
target is a server id or an identifier, offline works
GetInvoices(identifier)
table[]
Invoices of a character
SendServiceCall(src, job, message)
table, or nil, err
Same as the player using /call
SendDispatch(data), SendAlert(data)
call id or nil
Dispatch call, see MDT and dispatch
GetDispatchCalls()
table[]
Open calls, highest priority first
ClearDispatch(id)
boolean
Closes a call
GetDispatchRoster()
table[]
Units on duty: { id, name, callsign, status, call, job, grade, ... }
SendCrimeAlert(kind, coords, data)
Automatic alert of a kind: shooting, speeding, fight, civilian_down, officer_down, theft, drugs
Export
Returns
Description
IsRestrained(src)
string or false
Restraint type, for example 'handcuffs'
SetRestrained(src, kind)
boolean
Restrains (kind = 'handcuffs') or releases (kind = false) without animation
StopEscort(src)
nil
Stops escorting of a player
GetPlacedProps()
table[]
{ netId, key, job, owner, coords } of every trunk prop
ClearProps(coords, radius)
number
Removes props around a position, returns the count
Jail #
Export
Returns
Description
IsJailed(src)
boolean
Whether the player is in prison
JailPlayer(target, months, reason)
boolean
Adds months to the sentence and puts the online player in prison
UnjailPlayer(target)
Releases a prisoner
Medical #
Export
Returns
Description
IsDown(src)
boolean
Player is down
Revive(src)
Revives the player
Heal(src)
Heals the player
GetInjuries(src)
table
Current injuries, empty table when none
Forensics #
Export
Returns
Description
GetBiometricProfile(identifier)
{ dna, fingerprint } or nil
DNA and fingerprint codes of a character, built from Forensics.salt
Client exports #
Export
Returns
Description
IsOnDuty()
boolean
GetShiftSeconds()
number
HasPermission(permission)
boolean
IsBoss(), isBoss()
boolean
GetJobData(name)
table or nil
Label, colour, icon, type and other public job data
OpenBossMenu()
nil
Opens the boss menu, the server still checks permissions
OpenJobCenter()
nil
OpenMyJobs()
nil
IsRestrained()
string or false
Restraint type of the local player
IsEscorted()
boolean
Local player is escorted
IsCarryingProp()
boolean
Local player is placing a trunk prop
OpenInvoice(serverId)
nil
Invoice window for a player, the server checks permission and distance
Panic()
nil
Presses the panic button
CallService(job, message)
nil
Sends a service call
RespondToCall()
nil
Responds to the latest service call
IsDown()
boolean
Local player is down
Pulse card #
lua Copy exports. jcks_jobs : SendPulse (src, {
title = 'Dispatch' ,
subtitle = 'Code 3' ,
text = 'Robbery in progress at Fleeca Bank' ,
icon = 'siren' ,
color = '#FF453A' ,
duration = 7000 ,
})
subtitle and duration (ms) are optional. Icons include briefcase, shield, siren, gavel, heart-pulse, ambulance, wrench, truck, car-taxi, car, utensils, store, sprout, phone, megaphone, hand-coins, bell, clock and more from the list in the V1 README.
Examples #
lua Copy lib. addRadialItem ({
id = 'boss_menu' ,
icon = 'briefcase' ,
label = 'Boss menu' ,
onSelect = function () exports. jcks_jobs : OpenBossMenu () end ,
})
lua Copy local id, err = exports. jcks_jobs : CreateInvoice (targetId, 'police' , 250 , 'Speeding' )
Events #
All events are local, listen with AddEventHandler.
Event
Side
Arguments
jcks_jobs:dutyChanged
server
src, onDuty, job, shiftSeconds?
jcks_jobs:hired
server
identifier, job, grade
jcks_jobs:fired
server
identifier, job
jcks_jobs:restrained
server
target, kind, by (kind = false when released, by can be nil)
jcks_jobs:settingsChanged
server
changes after Server settings were saved
jcks_jobs:dutyChanged
client
onDuty
jcks_jobs:jobUpdated
client
job (normalized bridge job)
jcks_jobs:restrainedChanged
client
kind (false when released)
jcks_jobs:settingsApplied
client
new settings arrived
lua Copy 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
jcks:restrained
'handcuffs', 'zipties' or false
isCuffed
true or false, read by many phone, radial and inventory resources
jcks:escortedBy
Server id of the escorting player or false
jcks:escorting
Server id of the escorted player or false
Entity(entity).state['jcks:prop']
{ key, job, owner } on placed trunk props
lua Copy local onDuty = LocalPlayer. state [ 'jcks:duty' ]
Editable hooks #
client/editable.lua and server/editable.lua stay readable in the escrow build.
Hook
Default
ClientEditable.CanOpenMenu(app)
false while dead or cuffed
ClientEditable.OnDutyChanged(onDuty, jobName)
empty
ClientEditable.IsDown(serverId, ped)
state bags, death checks and writhe or dead animations
ClientEditable.OnRestrained(kind)
empty
ClientEditable.DispatchAlert(call)
empty, runs on every new dispatch call
ClientEditable.Overrides
empty, see Job creator
ServerEditable.CanHire(src, jobName, grade)
true. Return false, 'locale_key' to block
ServerEditable.OnHired(identifier, jobName, grade, src)
empty
ServerEditable.OnFired(identifier, jobName, src)
empty
ServerEditable.OnDutyChanged(src, jobName, onDuty, shiftSeconds)
empty
ServerEditable.IsDown(src)
state bags, QBCore metadata, health
ServerEditable.OnRestrained(target, kind, src)
empty
ServerEditable.SendInvoice(src, target, jobName, amount, reason)
false. Return true to bill through another resource
ServerEditable.OnPanic(src, jobName, coords)
empty
ServerEditable.OnServiceCall(src, jobName, message, coords)
false. Return true when another resource handled the call
ServerEditable.OnRespawn(src)
empty, runs with Medical.removeItemsOnRespawn
ServerEditable.Revive(target, src)
built-in medical, esx_ambulancejob or qb-ambulancejob
ServerEditable.Heal(target, src)
built-in medical or esx_ambulancejob
ServerEditable.OnImpound(src, vehicle, plate)
jcks_vehicles ImpoundVehicle when started
lua Copy 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
The second return value is a locale key without the err. prefix. src is nil when a boss accepts the application of an offline player. Admins hiring in /jobadmin skip this hook.