These are the editable files exactly as JCKS Jobs 2.0.0 ships them. Your own copies in editable/ are never replaced by an update. When the console says a function is missing, the default below runs instead of it. Copy the function into your file only if you want to change it.
The same files are in defaults/editable/ of the release. Files of other versions: changelog.
editable/client.lua
| Function | What it does |
|---|---|
ClientEditable.CanOpenMenu |
Called before any jcks_jobs window opens. |
ClientEditable.OnDutyChanged |
Called when the local player goes on or off duty. |
ClientEditable.IsDown |
Returns true when another player is down or dead. |
ClientEditable.OnRestrained |
Called when the local player was restrained or released. |
ClientEditable.DispatchAlert |
Called when a JCKS dispatch call lands on this unit (only while the JCKS dispatch module is on). |
ClientEditable.SendAlert |
Used while the JCKS dispatch module is off, for dispatch scripts that only offer client exports. |
ClientEditable.Overrides |
Replaces a JCKS location (stash, locker, boss, wardrobe, outfits, shop, garage ...) with another resource's menu. Empty by default. |
lua
--[[ JCKS JOBS · EDITABLE CLIENT HOOKS
Client side of editable/server.lua. These run on the player's game, so never decide anything that
matters here (money, items, jobs): the server checks all of that again.
Hooks run inside pcall, an error only prints in F8. ]]
ClientEditable = ClientEditable or {}
--[[ Called before any jcks_jobs window opens. Receives the window name (admin, boss, myjobs, mdt,
dispatch, evidence, shop ...). Return false to block it, for example while your phone or an
external MDT is open, or while the player is dead or cuffed by another resource. ]]
function ClientEditable.CanOpenMenu(app)
local ped = PlayerPedId()
if IsEntityDead(ped) or IsPedCuffed(ped) then return false end
if LocalPlayer.state.isDead or LocalPlayer.state.dead or LocalPlayer.state.isCuffed then return false end
return true
end
--[[ Called when the local player goes on or off duty. Receives the new state and the job name.
Use it for your own HUD or an external multijob menu. ]]
function ClientEditable.OnDutyChanged(onDuty, jobName)
end
--[[ Returns true when another player is down or dead. Receives the server id and the ped.
Decides whether "Revive" or "Heal" shows on that player. With an external ambulance job that uses
other state bags or animations, add its check here. ]]
function ClientEditable.IsDown(serverId, ped)
local state = Player(serverId).state
if state.isDead or state.dead or state.inLastStand or state.laststand then return true end
if IsPedDeadOrDying(ped, true) or IsPedFatallyInjured(ped) then return true end
return IsEntityPlayingAnim(ped, 'combat@damage@writhe', 'writhe_loop', 3) or IsEntityPlayingAnim(ped, 'dead', 'dead_a', 3)
end
--[[ Called when the local player was restrained or released. Receives the kind ('cuffs', 'ziptie' ...)
or false when released. ]]
function ClientEditable.OnRestrained(kind)
end
--[[ Called when a JCKS dispatch call lands on this unit (only while the JCKS dispatch module is on).
Receives the call table (id, kind, code, title, message, priority, coords, street, info).
Use it to play your own sound or forward the call to a phone app. ]]
function ClientEditable.DispatchAlert(call)
end
--[[ ALERT GATEWAY · client side
Used while the JCKS dispatch module is off, for dispatch scripts that only offer client exports.
The server hands an alert to the game of the player who caused it (alert.source) when
ServerEditable.SendAlert returned false. ps-dispatch is built in and does not need this function.
Receives the same alert table as ServerEditable.SendAlert (coords arrive as vector3) and the provider
name. Return true when you sent it.
Example for a script with a client export:
exports['my_dispatch']:SendAlert({ code = alert.code, title = alert.title, coords = alert.coords, jobs = alert.jobs })
return true ]]
function ClientEditable.SendAlert(alert, provider)
return false
end
--[[ Replace a JCKS location with another resource's menu. Key = location type (stash, locker, boss,
wardrobe, outfits, shop, garage ...), value = function(point) that opens your menu. The server checks
distance and access first. point has id, job and type (and the location data for every type but boss).
Example: ClientEditable.Overrides.wardrobe = function(point) exports['my_clothing']:OpenWardrobe() end ]]
ClientEditable.Overrides = {
}editable/server.lua
| Function | What it does |
|---|---|
ServerEditable.CanHire |
Called before a player gets a job (boss hire, application, Job Center, admin). |
ServerEditable.OnHired |
Called after a character got a job through jcks_jobs (boss hire, application, Job Center, admin, gig faction). |
ServerEditable.OnGradeChanged |
Called after a member got a new grade (boss menu promotion or demotion, admin, gig faction rank). |
ServerEditable.OnFired |
Called after a character lost a job (fired by the boss, quit in My jobs, removed by an admin, set to unemployed by an admin, or the whole job was deleted). |
ServerEditable.OnDutyChanged |
Called when a player goes on or off duty in jcks_jobs. |
ServerEditable.OnExploitScore |
Called once when a character reaches the exploit score threshold (ServerConfig.ExploitScore). |
ServerEditable.IsDown |
Returns true when the player is down or dead. Used by job actions, restraints and crime alerts. |
ServerEditable.OnRestrained |
Called after a player was restrained or released. |
ServerEditable.SendInvoice |
Sends an invoice to your own billing resource instead of a JCKS invoice. |
ServerEditable.OnPanic |
Called when an officer or medic presses the panic button. |
ServerEditable.OnServiceCall |
Called when a player calls a service (/call, Job Hub). |
ServerEditable.OnRespawn |
Called after a player respawned at the hospital (built-in medical only). |
ServerEditable.Revive |
Revives a player. Used by the "Revive" job action and admin tools. |
ServerEditable.Heal |
Heals a player. Used by the "Heal" job action. |
ServerEditable.OnImpound |
Impounds a vehicle for the "Impound" job action. |
ServerEditable.SendAlert |
Every alert of jcks_jobs goes through one gateway. |
lua
--[[ JCKS JOBS · EDITABLE SERVER HOOKS
These functions connect jcks_jobs to the rest of your server. They stay readable in every release
(also the escrow build), and an update keeps your version of this file.
Every built-in system can be switched off in game (/jobadmin -> Server settings -> Modules), so
another resource can do that job instead: your own MDT, dispatch, multijob, billing, doorlock,
ambulance, police job and so on. When a module is off, jcks_jobs still tells the outside world what
happens through the hooks below:
alerts (panic, service calls, crime alerts, downed players, door break-ins, fires, prison escapes,
vehicle alarms of jcks_vehicles) -> ServerEditable.SendAlert, or a dispatch picked in
Server settings -> Modules -> Alert target (Dispatch.provider)
invoices (taxi fares, MDT fines, hospital fees) while Invoices & fines is off -> ServerEditable.SendInvoice
hires, grade changes, firing and duty -> OnHired, OnGradeChanged, OnFired, OnDutyChanged (for an external multijob)
reviving and healing -> ServerEditable.Revive / ServerEditable.Heal (for an external ambulance job)
Rules for everything in this file
- Hooks run inside pcall. An error only prints in the console, the action of jcks_jobs goes on.
- Values that reach these functions are already checked by the server (player online, job, distance,
amounts). Do not trust anything a client sends you here either. ]]
ServerEditable = ServerEditable or {}
--[[ Called before a player gets a job (boss hire, application, Job Center, admin).
Receives the server id, the job name and the grade. Return false (and optionally a locale error key)
to block it, for example when your own whitelist says no. Return true to allow. ]]
function ServerEditable.CanHire(src, jobName, grade)
return true
end
--[[ Called after a character got a job through jcks_jobs (boss hire, application, Job Center, admin,
gig faction). Receives the identifier, job name, grade and the server id (nil when the player is offline).
With MultiJob switched off and an external multijob (ps-multijob, esx_multijob ...), add the job to
that resource here so its menu shows the new job. ]]
function ServerEditable.OnHired(identifier, jobName, grade, src)
end
--[[ Called after a member got a new grade (boss menu promotion or demotion, admin, gig faction rank).
Receives the identifier, job name, the new grade and the server id (nil when offline).
An external multijob usually keeps its own grade per job, update it here. ]]
function ServerEditable.OnGradeChanged(identifier, jobName, grade, src)
end
--[[ Called after a character lost a job (fired by the boss, quit in My jobs, removed by an admin, set to
unemployed by an admin, or the whole job was deleted). Receives the identifier, job name and the server
id (nil when offline). Remove the job from your external multijob here. ]]
function ServerEditable.OnFired(identifier, jobName, src)
end
--[[ Called when a player goes on or off duty in jcks_jobs. Receives the server id, job name, the new state
(true = on duty) and, when going off duty, the length of the shift in seconds.
Use it to tell an external multijob, timeclock or Discord bot. With Duty -> Mirror duty with the framework
on, the framework duty is already synced and nothing has to be done here. ]]
function ServerEditable.OnDutyChanged(src, jobName, onDuty, shiftSeconds)
end
--[[ Called once when a character reaches the exploit score threshold (see ServerConfig.ExploitScore).
Receives the server id, identifier, total points and a list of { reason, n }. Put a ban or a txAdmin
action here if you want one. ]]
function ServerEditable.OnExploitScore(src, identifier, score, reasons)
end
--[[ Returns true when the player is down or dead. Used by job actions (revive, heal), restraints and
crime alerts. The default reads the usual state bags and the QBCore metadata. With an external
ambulance job that uses other names, add its check here. ]]
local QBCore = nil
function ServerEditable.IsDown(src)
local state = Player(src).state
if state.isDead or state.dead or state.inLastStand or state.laststand then return true end
if Bridge.Name == 'qb' then
QBCore = QBCore or exports['qb-core']:GetCoreObject()
local p = QBCore.Functions.GetPlayer(src)
local meta = p and p.PlayerData.metadata
if meta and (meta.isdead or meta.inlaststand) then return true end
end
local ped = GetPlayerPed(src)
return ped ~= 0 and GetEntityHealth(ped) <= 0
end
--[[ Called after a player was restrained or released. Receives the target, the kind
('cuffs', 'ziptie' ... or false when released) and the officer. ]]
function ServerEditable.OnRestrained(target, kind, src)
end
--[[ Sends an invoice to your own billing resource instead of a JCKS invoice.
Receives:
src server id of the employee who bills, nil for system invoices (hospital fee)
target server id of the customer, or the character identifier when the customer is offline (MDT fines)
jobName the job (company) that gets the money
amount whole number, already limited by Invoices & fines -> Highest amount
reason text up to 160 characters
Return true when your billing took it, false to let jcks_jobs handle it.
While Invoices & fines is ON, the employee menu calls this first and falls back to a JCKS invoice.
While Invoices & fines is OFF, every invoice jcks_jobs would create (taxi fares, MDT fines, hospital
fees) is sent here only. Returning false then means no invoice at all.
Example for okokBilling (check the export name in its documentation):
if type(target) ~= 'number' then return false end
exports.okokBilling:CreateBill(src, target, amount, reason, jobName)
return true ]]
function ServerEditable.SendInvoice(src, target, jobName, amount, reason)
return false
end
--[[ Called when an officer or medic presses the panic button. Receives the server id, the job and the
position { x, y, z }. The alert itself already went through the alert gateway, use this for extras
(a Discord message, a sound on your own HUD). ]]
function ServerEditable.OnPanic(src, jobName, coords)
end
--[[ Called when a player calls a service (/call, Job Hub). Receives the server id, the called job, the
message and the position. Return true to take the call completely (jcks_jobs does nothing else, for
example when your phone handles service calls). Return false to let jcks_jobs handle it. ]]
function ServerEditable.OnServiceCall(src, jobName, message, coords)
return false
end
--[[ Called after a player respawned at the hospital (built-in medical only). Remove items or reset
things of other resources here. ]]
function ServerEditable.OnRespawn(src)
end
--[[ Revives a player. Used by the "Revive" job action and admin tools. Uses the built-in medical when it
is on, otherwise esx_ambulancejob or qb-ambulancejob. With another ambulance job (wasabi_ambulance,
qbx_medical ...) call its revive event or export here. ]]
function ServerEditable.Revive(target, src)
if Medical and Medical.Enabled() then
Medical.Revive(target, src, { force = true })
elseif GetResourceState('esx_ambulancejob') == 'started' then
TriggerClientEvent('esx_ambulancejob:revive', target)
elseif GetResourceState('qb-ambulancejob') == 'started' then
TriggerClientEvent('hospital:client:Revive', target)
else
TriggerClientEvent('jcks_jobs:client:revive', target)
end
end
--[[ Heals a player. Used by the "Heal" job action. Same rules as Revive above. ]]
function ServerEditable.Heal(target, src)
if Medical and Medical.Enabled() then
Medical.Heal(target, src)
elseif GetResourceState('esx_ambulancejob') == 'started' then
TriggerClientEvent('esx_ambulancejob:heal', target, 'big', true)
else
TriggerClientEvent('jcks_jobs:client:heal', target)
end
end
--[[ Impounds a vehicle for the "Impound" job action. Uses jcks_vehicles when it runs, otherwise marks
the owned vehicle as impounded through jcks_bridge. Return true when it was handled. ]]
function ServerEditable.OnImpound(src, vehicle, plate)
if GetResourceState('jcks_vehicles') == 'started' then
local ok = pcall(function() return exports.jcks_vehicles:ImpoundVehicle(plate, { entity = vehicle, by = src }) end)
if ok then return true end
end
if plate and plate ~= '' then pcall(Bridge.UpdateOwnedVehicle, plate, { state = 'impound' }) end
return true
end
--[[ ALERT GATEWAY · custom dispatch
Every alert of jcks_jobs goes through one gateway. While the JCKS dispatch module is ON the alert
becomes a JCKS dispatch call and this function is not used.
While it is OFF, Server settings -> Modules -> Alert target (Dispatch.provider) decides:
'auto' the first running of cd_dispatch, ps-dispatch, qs-dispatch, rcore_dispatch, lb-tablet,
tk_dispatch, core_dispatch, wasabi_mdt, piotreq_gpt, linden_outlawalert, otherwise this function
'cd_dispatch', 'ps-dispatch', 'qs-dispatch', 'rcore_dispatch', 'lb-tablet', 'tk_dispatch', 'core_dispatch',
'wasabi_mdt', 'piotreq_gpt', 'linden_outlawalert'
built-in adapters (checked against the official documentation of each script)
'custom' this function
'off' alerts are dropped
When a built-in adapter cannot send (resource stopped, alert without position), the alert comes here too.
Receives alert, provider:
alert.kind 'police' | 'ems' | 'fire'
alert.code radio code, e.g. '10-99'
alert.title short title
alert.message text, can be ''
alert.priority 1 (low) to 3 (urgent)
alert.panic true for panic and officer down
alert.coords vector3 or nil
alert.street street name or nil
alert.caller name of the caller or nil
alert.blip GTA blip sprite or nil
alert.radius search radius in metres or nil
alert.source server id of the player who caused or sent the alert, nil for system alerts
alert.info list of { icon, text } (weapon, vehicle, plate, direction ...)
alert.jobs list of job names that should receive it (from Dispatch -> police / EMS / fire jobs)
provider the chosen target, see above
Return true when you sent it. Return false and, when alert.source is set, the same alert is handed to
ClientEditable.SendAlert on that player's game (for dispatch scripts that only have client exports).
lb-tablet has a built-in adapter that sends "time" as os.time() (seconds), because the documentation of
AddDispatch does not name the unit. If the tablet shows a wrong time, set the alert target to 'custom'.
The example below then sends os.time() * 1000. ]]
function ServerEditable.SendAlert(alert, provider)
local LB_PRIORITY = { 'low', 'medium', 'high' }
if provider == 'custom' and GetResourceState('lb-tablet') == 'started' and alert.coords then
local fields = {}
for _, entry in ipairs(alert.info) do fields[#fields + 1] = { icon = 'circle-info', label = entry.text } end
exports['lb-tablet']:AddDispatch({
priority = alert.panic and 'high' or LB_PRIORITY[alert.priority] or 'medium',
code = alert.code,
title = alert.title,
description = alert.message ~= '' and alert.message or alert.title,
location = { label = alert.street or alert.title, coords = vector2(alert.coords.x, alert.coords.y) },
time = os.time() * 1000,
job = alert.jobs,
fields = fields,
blip = { sprite = alert.blip or 161, color = alert.priority >= 3 and 1 or 3, size = 1.0, label = alert.title },
})
return true
end
return false
end