Your server runs its own core, for example Open Life, or an inventory the bridge has no adapter for. JCKS scripts never talk to the framework directly, only to the bridge. Connect the bridge once and JCKS Jobs and every other JCKS script work with your core.
| File | Side | What it connects |
|---|---|---|
editable/server_framework.lua |
server | identifier, name, job and grade, duty, money, job list, admin groups, offline characters, company accounts |
editable/client_framework.lua |
client | gender for job outfits |
editable/server_inventory.lua |
server | item counts, give and take items, item list, metadata, stashes, player search, usable items |
editable/client_inventory.lua |
client | item count for prompts, stash and search UI opened from the client |
The files stay readable after escrow. Keep your copies when you update the bridge. When an update adds a function, the console names it and the default from defaults/editable/ runs until you copy it in.
What stays the bridge's job
You write plain functions that talk to your core. The bridge keeps every check on its side, whatever your functions do:
| Check | Where |
|---|---|
| Money amounts are whole numbers from 1 to 1 000 000 000, the account name is a plain word | before AddMoney and RemoveMoney |
The balance is read with GetMoney first, RemoveMoney only runs when the player can pay |
before RemoveMoney |
| Job name and grade are checked against your job list and the jobs created in JCKS | before SetJob and SetJobOffline |
Item name, count, slot and stash id are validated, RemoveItem only runs when GetItemCount shows enough, AddItem only when CanCarry allows it |
before every inventory call |
| Every return value is checked for type and shape, broken data is dropped | after every call |
| Errors are caught, the bridge logs each failing function at most once a minute and keeps running | every call |
Step 1. Pick custom
Open /jcks, Environment. Choose Custom core under Framework. If you also use your own inventory, choose Custom inventory under Inventory. With ox_inventory or another supported inventory, keep that one. Company accounts in your core: Integrations, Custom accounts. Save and restart jcks_bridge.
The same in settings/config.lua for a fresh server:
Config.Framework = 'custom' -- your core through editable/server_framework.lua
Config.Inventory = 'custom' -- or 'ox_inventory' if you use it
Config.Society = 'custom' -- job money kept by your core, or 'internal' for JCKS accountsDetection never picks custom on its own. A server without that setting keeps working as before.
Start order in server.cfg:
ensure oxmysql
ensure openlife_core
ensure jcks_lib
ensure jcks_bridge
ensure jcks_jobsStep 2. Name your core
At the top of editable/server_framework.lua:
Editable.Framework.Resource = 'openlife_core' -- your core resource name, the bridge waits up to 30 s for it to start
Editable.Framework.Style = 'exports' -- 'exports' (getPlayer, setJob, ...) or 'object' (ESX like shared object)
Editable.Framework.Vehicles = true -- true stores owned vehicles in the JCKS table jcks_owned_vehicles, false turns owned vehicles offStyle = 'object' covers cores that hand out an ESX like shared object: getSharedObject(), GetPlayerFromId, xPlayer.job, getAccount, addAccountMoney, removeAccountMoney, setJob, getGroup. If your core looks like that, you are almost done after this step.
Set the same name in editable/client_framework.lua.
Step 3. Fill in the required functions
The worked example assumes an exports based core like this. Rename the exports to the ones your core documents:
local p = exports.openlife_core:getPlayer(source)
exports.openlife_core:setJob(source, 'police', 2)
exports.openlife_core:setDuty(source, true)
exports.openlife_core:getMoney(source, 'bank')
exports.openlife_core:addMoney(source, 'cash', 500, 'salary')
exports.openlife_core:removeMoney(source, 'cash', 200, 'fine')
exports.openlife_core:getPlayers()where getPlayer returns:
{
identifier = 'OL12345',
firstname = 'John',
lastname = 'Smith',
group = 'user',
job = { name = 'police', label = 'Police', grade = 2, gradeLabel = 'Sergeant', onDuty = true },
}| Function | Receives | Returns |
|---|---|---|
GetIdentifier(src) |
server id | string, unique per character and never changing. nil while no character is loaded |
GetName(src) |
server id | character name, 'John Smith' |
GetJob(src) |
server id | { name, label, grade, gradeName, gradeLabel, salary, onDuty, isBoss }, name and grade required, onDuty = nil counts as on duty. nil while no character is loaded |
SetJob(src, job, grade, onDuty) |
server id, job name, grade, boolean or nil |
true on success |
SetDuty(src, onDuty) |
server id, boolean | true. If your core has no duty, return true and JCKS keeps duty itself |
GetMoney(src, account) |
server id, 'cash', 'bank' or 'black' |
balance |
AddMoney(src, account, amount, reason) |
server id, account, whole amount, text | true on success |
RemoveMoney(src, account, amount, reason) |
same | true on success, false when refused |
GetPlayers() |
list of server ids with a loaded character, { 1, 5, 12 } or a table keyed by server id |
The JCKS account names map to yours in one table:
local ACCOUNTS = { cash = 'cash', bank = 'bank', black = 'black_money', dirty = 'black_money' }The example GetJob from the file, so you see what the bridge expects:
function Editable.Framework.GetJob(src)
local p = getPlayer(src)
if not p or not p.job then return nil end
local job = p.job
return {
name = job.name,
label = job.label,
grade = tonumber(type(job.grade) == 'table' and job.grade.level or job.grade) or 0,
gradeName = job.grade_name or job.gradeName,
gradeLabel = job.grade_label or job.gradeLabel,
salary = tonumber(job.grade_salary or job.salary) or 0,
onDuty = job.onDuty ~= false and job.onduty ~= false,
isBoss = job.isBoss == true or job.isboss == true,
}
endStep 4. Tell the bridge about changes
JCKS notices every change it makes itself. Changes your core makes, for example /setjob from an admin menu or a character switch, need a signal. Without it the client job of that player stays old until the next change through JCKS.
The easiest way is Editable.Framework.Listen. The bridge calls it once after your core started:
function Editable.Framework.Listen(signal)
AddEventHandler('openlife:playerLoaded', function(src) signal.loaded(src) end)
AddEventHandler('openlife:playerLogout', function(src) signal.unloaded(src) end)
AddEventHandler('openlife:jobUpdated', function(src) signal.job(src) end)
AddEventHandler('openlife:dutyUpdated', function(src) signal.duty(src) end)
endOr call the bridge from your core's own code:
exports.jcks_bridge:CustomPlayerLoaded(source)
exports.jcks_bridge:CustomPlayerUnloaded(source)
exports.jcks_bridge:CustomJobChanged(source)
exports.jcks_bridge:CustomDutyChanged(source)The same as server events, for cores that cannot call exports at that moment:
TriggerEvent('jcks_bridge:custom:playerLoaded', source)
TriggerEvent('jcks_bridge:custom:playerUnloaded', source)
TriggerEvent('jcks_bridge:custom:jobChanged', source)
TriggerEvent('jcks_bridge:custom:dutyChanged', source)These events are server only. They are not net events, a client cannot trigger them.
| Signal | When | What the bridge does |
|---|---|---|
| loaded | character loaded or switched | reads the job with GetJob, publishes it to the client, fires jcks_bridge:server:playerLoaded, runs a one time self test |
| unloaded | logout without leaving the server | clears the client job, fires jcks_bridge:server:playerUnloaded |
| job | job or grade changed outside JCKS | reads the job again, fires jcks_bridge:server:jobChanged only if something changed |
| duty | duty changed outside JCKS | same as job, plus jcks_bridge:server:dutyChanged when the duty state changed |
You never pass the new job, the bridge always reads it through GetJob. Duplicate signals are ignored. A player who leaves the server is unloaded automatically. No signal polls anything.
On the client the job arrives in the player state bag jcks:job. JCKS scripts get jcks_bridge:client:playerLoaded, jcks_bridge:client:jobChanged and jcks_bridge:client:playerUnloaded from it, so editable/client_framework.lua only needs GetGender.
Step 5. Optional functions
| Function | Without it |
|---|---|
GetJobs() |
JCKS cannot import your jobs and lets your core decide in SetJob |
SaveJob(def, grades), DeleteJob(name) |
Jobs created in JCKS Jobs stay in jcks_bridge_jobdefs and are not written into your core |
InGroup(src, group) |
Admin groups come only from ACE (group.admin) |
SetMetadata(src, key, value) |
The default stores the value in the player state bag jcks:meta:<key> |
SetStatus(src, name, value) |
Needs such as hunger or thirst (0 to 100, for example after a medic revive) go only to the player state bag <name>, not to your core |
RegisterUsableItem(item, cb) |
The default uses ox_inventory when it runs, otherwise your core's registerUsableItem |
Listen(signal) |
See step 4 |
GetJobs returns:
{
{
name = 'police', label = 'Police', whitelisted = true,
grades = {
{ grade = 0, name = 'recruit', label = 'Recruit', salary = 50, isBoss = false },
{ grade = 4, name = 'chief', label = 'Chief', salary = 150, isBoss = true },
},
},
}Step 6. Offline characters
The boss menu fires offline employees, admins search characters, JCKS Jobs shows character names. These functions read your characters table. Fill in the names, the bridge quotes them and builds the SQL:
Editable.Framework.Database = {
table = 'players', -- characters table
identifier = 'identifier', -- column with the same value GetIdentifier returns
license = 'license', -- column with the Rockstar license (license:xxxx or the bare hash), used to list a player's characters
firstname = 'firstname',
lastname = 'lastname',
job = 'job', -- column with the job name
grade = 'job_grade', -- column with the job grade number
}The offline functions in the file use CustomCore.Sql(kind, sql, params) with {table}, {identifier} and the other names as placeholders and ? for values:
function Editable.Framework.GetOfflineJob(identifier)
local row = CustomCore.Sql('single', 'SELECT {job} AS job, {grade} AS grade FROM {table} WHERE {identifier} = ?', { identifier })
return row and { name = row.job, grade = tonumber(row.grade) or 0 } or nil
endIf your core keeps the job as JSON or the name in one column, rewrite these functions with your own SQL, always with ? placeholders. With Editable.Framework.Database = false offline features only work for players who are online.
| Function | Returns |
|---|---|
GetOfflineJob(identifier) |
{ name, grade } or nil |
SetJobOffline(identifier, job, grade) |
true on success |
GetEmployees(job) |
{ { identifier, name, grade }, ... } |
SearchCharacters(query, limit, offset) |
list of { identifier, name, job, grade } and the total count |
CharactersByLicense(license) |
up to 10 { identifier, name, job, grade } |
GetCharacterName(identifier) |
name or nil |
MoveGrade(job, from, to) |
nothing |
ResetOfflineJob(job) |
nothing |
Step 7. Company accounts
With Company accounts set to Custom accounts, the bridge uses Editable.Society at the end of editable/server_framework.lua:
function Editable.Society.GetMoney(job)
return exports[Editable.Framework.Resource]:getSocietyMoney(job) or 0
end
function Editable.Society.AddMoney(job, amount, reason)
return exports[Editable.Framework.Resource]:addSocietyMoney(job, amount, reason) ~= false
end
function Editable.Society.RemoveMoney(job, amount, reason)
return exports[Editable.Framework.Resource]:removeSocietyMoney(job, amount, reason) ~= false
endjob is the job name. The bridge checks the amount and the balance before RemoveMoney. Ensure(job, label) is optional and creates the account. If your core has no job money, keep JCKS internal accounts.
Step 8. Custom inventory
Skip this step with ox_inventory, qb-inventory, qs-inventory, tgiann, codem, ak47, core, jaksam, jpr, ps, lj or origen, the bridge has adapters for them.
Editable.Inventory.Resource = 'my_inventory' -- your inventory resource name
Editable.Inventory.Metadata = true -- true if items carry metadata, false if not
Editable.Inventory.Images = '' -- item image path with %s for the item name, e.g. 'nui://my_inventory/html/images/%s.png', empty for none| Function | Required | Receives | Returns |
|---|---|---|---|
GetItemCount(src, item) |
yes | server id, item name | count |
AddItem(src, item, count, metadata) |
yes | server id, item, whole count, table or nil |
true on success |
RemoveItem(src, item, count, metadata) |
yes | same | true on success |
GetItemList() |
yes | { water = { label = 'Water' }, ... }, cached 5 minutes |
|
CanCarry(src, item, count) |
no | true when there is room. Without it the bridge assumes room |
|
GetItemsMetadata(src, item) |
no | { { slot = 3, metadata = { plate = 'ABC123' } }, ... } |
|
RemoveSlot(src, item, slot) |
no | true. Without it one item is removed by name |
|
RegisterStash(id, label, slots, weight, personal, groups, coords) |
no | true, or false when your inventory has no stashes |
|
OpenStash(src, id, label, slots, weight, personal) |
no | true. Without it job stashes and lockers stay closed |
|
OpenPlayerInventory(src, target) |
no | true. Without it player search is off |
|
RegisterUsableItem(item, cb) |
no | call cb(source, item) when the item is used |
With Metadata = false or without GetItemsMetadata, features that need metadata stay off, for example physical vehicle keys.
If your inventory opens stashes only from the client, send the request from the server function:
function Editable.Inventory.OpenStash(src, id, label, slots, weight, personal)
local stashId = personal and (id .. '_' .. (CustomInventory.Identifier(src) or src)) or id
TriggerClientEvent('jcks_bridge:client:inventory', src, 'stash', { id = stashId, label = label, slots = slots, weight = weight })
return true
endand open it in editable/client_inventory.lua:
function Editable.Inventory.OpenStash(data)
exports[Editable.Inventory.Resource]:openStash(data.id, data.label, data.slots, data.weight)
endThe client GetItemCount only shows or hides prompts. The server checks the real count before anything happens.
With the framework Custom core and the inventory Framework default, the bridge uses the custom inventory files as the framework inventory.
Step 9. Check it
Restart jcks_bridge. The console shows:
[jcks_bridge] custom framework adapter from editable/server_framework.lua
all 9 required functions are defined
[jcks_bridge] custom framework: self test passed on player 1Missing required functions, a core resource that is not started and the first error of every failing function are printed in red. When the first character loads, a self test calls GetIdentifier, GetName, GetJob and GetMoney and prints what came back wrong, or self test passed.
The same result is in /jcks. Overview lists missing functions and errors as tasks. Environment shows the state under the selected option, with the error message of every failing function.
Troubleshooting
| Console shows | Fix |
|---|---|
framework adapter custom failed to load |
jcks_bridge is older than this feature or server/framework/custom.lua is missing. Update the bridge |
missing required functions: GetJob |
The function is not in editable/server_framework.lua. Copy it from defaults/editable/server_framework.lua |
core resource openlife_core is not started |
Wrong Editable.Framework.Resource or wrong start order in server.cfg |
Editable.Framework.GetJob failed: No such export getPlayer |
Your core has a different export name. Rename it in the file |
GetJob returned no table with name and grade |
Return the job as a table, see step 3 |
Editable.Framework.Database.grade is not set |
Fill in the column name or rewrite the offline function |
Jobs on the client stay old after /setjob |
Step 4, the core does not signal job changes |