JCKSDocs
JCKS BridgeV2Référence

Exports and events

Every server and client export of JCKS Bridge 2.0.0, the normalized events and the data shapes they return.

Call them as exports.jcks_bridge:Name(...). A short handle keeps code tidy:

lua
local Bridge = exports.jcks_bridge

Every API export is wrapped in pcall. If an underlying resource throws, the export returns nil and the console prints [jcks_bridge] <Export> failed: <error>. Exports that read the database yield, so call them from a thread or an event handler, not from the main chunk.

Add the bridge as a dependency of your resource:

lua
dependencies { 'jcks_bridge' }

Server

Info

Export Returns What it does
GetSystems() table Everything detected, see Systems
GetFramework() string qbx, esx, qb, ox, standalone or custom
GetVersion() string Bridge version
GetSetup(), IsConfigured() The saved setup, and whether it was saved
GetIdentityMode() table Config.Identity
HasResource(name) boolean Whether jcks_jobs, jcks_vehicles or jcks_logs runs and is switched on in /jcks
GetTrinity() table State of the JCKS resources the bridge knows
OpenSetup(src) Opens /jcks for the player when they are an admin
GetVersionInfo() table Result of the version check

Players

Export Returns What it does
GetIdentifier(src) string? Character identifier: ESX identifier, QBCore and Qbox citizenid
GetName(src) string First and last name of the character
GetJob(src) Job? Current job, normalized
SetJob(src, job, grade, onDuty?) boolean Sets the job of an online player
SetJobOffline(identifier, job, grade) boolean Sets the job of an offline character in the database
GetOfflineJob(identifier) { name, grade }? Job read from the database
GetSourceFromIdentifier(identifier) number? Server id of an online character
GetPlayers() number[] Server ids of all loaded players
GetOnlinePlayers() OnlinePlayer[] All loaded players with identifier, name and job in one call. Cheaper than GetJob in a loop.
SetDuty(src, state) Framework duty
SetMetadata(src, key, value) Character metadata
SetStatus(src, name, value) boolean Status such as hunger or thirst, 0 to 100. Through the framework, otherwise the player state bag.
IsAdmin(src) boolean See Permissions
HasPermission(src, id) / GetPermissions(src) / RegisterPermission(id, def) Access rules
HasIdentifierPermission(identifier, id) boolean Same check for an identifier such as license:..., works offline
InGroup(src, group) boolean Framework group or ACE group group.<name>
ListPermissions() table Every registered permission with its rule
ExplainDenied(src, permission, ace?) boolean Prints to the server console why the player is not admin and the server.cfg lines to add. At most once a minute per player, false when skipped.

Money

account is 'cash' or 'bank' on every framework. On ESX 'cash' maps to money and 'black' to black_money. Other names go to the framework unchanged. Account names take letters, digits and _, at most 32 characters.

Export Returns What it does
GetMoney(src, account) number Balance
AddMoney(src, account, amount, reason?) boolean, err? Amount 1 to 1,000,000,000, floored. false, 'invalid_args' otherwise.
RemoveMoney(src, account, amount, reason?) boolean, err? Only if the player has enough

Items and stashes

Item names take letters, digits, _, - and ., at most 64 characters. Counts are 1 to 1,000,000.

Export Returns What it does
GetItemCount(src, item) number
CanCarryItem(src, item, count?) boolean Weight and slot check
AddItem(src, item, count?, metadata?) boolean, err?
RemoveItem(src, item, count?, metadata?) boolean, err?
GetItemsMetadata(src, item) table Metadata of every stack of the item
FindItemByMetadata(src, item, match?) First stack whose metadata matches the table
RemoveItemBySlot(src, item, slot) boolean
InventoryHasMetadata() boolean false on framework inventories
GetItems() { [name] = { label } } All registered items
ItemExists(name) / GetItemLabel(name) / GetItemImage(name) Image URL from ItemImagePath
RegisterStash(id, label, slots, weight, personal?, groups?, coords?) boolean personal = true gives every character their own copy. Slots up to 1000.
OpenStash(src, id, label, slots, weight, personal?) boolean, err? false, 'stash_unsupported' on framework inventories
OpenPlayerInventory(src, target) boolean, err? Searching. false, 'search_unsupported' on framework inventories.
RegisterUsableItem(item, cb) boolean cb(src, item) runs in your resource
GetStashItems(id) table? Items in a stash

Company accounts

Export Returns What it does
EnsureSociety(job, label?) boolean Creates the account where the banking resource needs it. Safe to call often.
GetSocietyMoney(job) number
AddSocietyMoney(job, amount, reason?) boolean
RemoveSocietyMoney(job, amount, reason?) boolean Only if the balance is high enough
GetSocietyTransactions(job, limit?) table Newest first, default 50, at most 200. From jcks_bridge_transactions with internal accounts.
BankStatement(src, amount, reason) boolean Line in the player's personal bank history, see SocietyCompat.statements

Job definitions

Export Returns What it does
ImportJobs() JobDefinition[] Every job the framework knows
SyncJob(def, grades) boolean Creates or updates one job and its grades
SyncJobs(list) boolean { { job = def, grades = grades } }. On ESX RefreshJobs runs once.
RemoveJob(name) / JobExists(name, grade?) boolean
MoveGrade(job, from, to) Moves offline characters to another grade
ResetOfflineJob(job) Makes every offline holder of the job unemployed
GetEmployees(job) { identifier, name, grade }[] Online and offline
SearchCharacters(query, limit?, offset?) list, total Default limit 25. Entries { identifier, name, job, grade }.
GetCharacterName(identifier) string?
GetCharactersByLicense(license) table { { identifier, name, job, grade } }

Native multijob (Qbox)

On other frameworks these return nil or false. Check HasNativeMultiJob() first.

Export Returns
HasNativeMultiJob() true on Qbox
GetPlayerJobs(identifier) { [job] = grade }?
AddToJob(identifier, job, grade) boolean
RemoveFromJob(identifier, job) boolean
SetPrimaryJob(identifier, job) boolean

Owned vehicles

Works with ESX owned_vehicles, QBCore and Qbox player_vehicles, ox_core vehicles, standalone and custom core jcks_owned_vehicles. Every function returns the same record:

lua
{ plate, owner, model, props, garage, impound, state, type, job, fuel, engine, body, distance, depotPrice }

state is 'garage', 'out' or 'impound'.

Export Returns What it does
GetOwnedVehicles(identifier) record[]
GetOwnedVehicle(plate) record? Spaces are ignored
CountOwnedVehicles(identifier) number
SearchOwnedVehicles(query, limit?, offset?) record[], total By plate or owner. Default limit 50, at most 200.
AddOwnedVehicle(identifier, data, src?) true, plate or false, err data = { plate, model, props?, garage?, state?, type?, job? }
UpdateOwnedVehicle(plate, fields) boolean fields = { props?, owner?, state?, garage?, impound?, fuel?, engine?, body?, plate? }
RemoveOwnedVehicle(plate) / PlateExists(plate) boolean
GeneratePlate(format?) string? L letter, N digit, other characters copied, for example 'LLNNNLLL'
NormalizePlate(text) string Upper case, trimmed, only A to Z, 0 to 9 and spaces, at most 8 characters
ReturnOutVehicles(garage?) / ImpoundOutVehicles(lot?) number Marks every vehicle that is out as parked or impounded

Keys, notifications, clipboard

Export What it does
GiveKeys(src, vehicle, plate, opts?) / RemoveKeys(src, vehicle, plate, opts?) Through Editable.GiveKeys and Editable.RemoveKeys. vehicle is the server entity.
Notify(src, data) data = { title?, description, type?, duration? }, type is success, error, inform or warning
CopyToClipboard(src, text, label?) Copies text on the player's PC, up to 8192 characters

Licences

target is a server id or an identifier, so offline characters work too.

Export Returns What it does
AddLicense(target, kind, opts?) boolean, err? opts = { days?, label?, by? }. Days default to the type. Resets points and suspension.
RemoveLicense(target, kind) boolean
HasLicense(target, kind) boolean false while suspended or expired
GetLicenses(target) table { type, label, valid, points, issued, expires, suspended, issuedBy }
SuspendLicense(target, kind, days) boolean, err? days = 0 lifts the suspension
AddLicensePoints(target, kind, amount) true, points or false, err Suspends at pointsLimit
GetLicenseTypes() table { type, label, days }

Phone

Export What it does
PhoneMail(target, data) / PhoneNotify(target, data) Mail or notification on the detected phone
PhoneMessage(target, data) Text message on the detected phone, data = { sender?, from?, message }. Falls back to a phone notification.
GetPhoneNumber(target) Phone number of a player
GetPhoneSystem() / GetSupportedPhones() Detected phone and the supported list
PhoneIntercept(data) Reports a text or call to wiretaps, see Frameworks and systems

MDT

The bridge passes MDT calls to the detected MDT (jcks_jobs first). Other resources use these to work with any supported MDT.

Export What it does
MdtProvider() The detected MDT
MdtOpen(src, page?, ctx?) Opens the MDT for a player
MdtCan(src, feature) Whether the player may use an MDT feature
MdtNotify(target, data) Notice inside the MDT
MdtRegisterPage(def), MdtRegisterPersonTab(def), MdtRegisterVehicleTab(def), MdtRegisterSearch(kind, label, handler) Own pages, tabs and search sources, owned by the calling resource
MdtDevice(src) MDT device of the player from jcks_electronics, 'none' without it
MdtHasWarrant(target) / MdtWarrants(target) Warrant check and list, jcks_jobs and tk_mdt
MdtAddWarrant(target, data) data = { reason, details?, by? }, jcks_jobs
MdtRegisterWeapon(target, data) data = { weapon, serial, info?, by? }, weapon registry of ps-mdt, tk_mdt and piotreq_gpt

The server event jcks_bridge:mdtReady fires when an MDT provider is ready for registrations.

Logging hub

Export What it does
Log(category, action, src?, data?, meta?) Forwards a log line to JCKS Logs under the calling resource. Returns forwarded, sendOwnWebhooks.
LogsForwarding(resource) true when that resource's logs reach jcks_logs
HubStatus() { logs, failed, last, members, ownWebhooks }
ReportExploit(src, resource, reason, details, weight) Adds a security report
lua
local sent, own = exports.jcks_bridge:Log('finance', 'deposit', source, { amount = 500 }, { job = 'police' })

The calling resource comes from GetInvokingResource(), so a script cannot log in another script's name. Only jcks_jobs, jcks_vehicles and jcks_bridge are forwarded, other resources get false, true. Forwarding is switched per script in the JCKS Logs settings. Without jcks_logs every script keeps using its own webhooks.

Script settings

RegisterSettings(definition), GetScriptSettings(resource?), IsScriptEnabled(resource?), GetModuleSettings(name), IsModuleReady(name). See Script settings.

RegisterSecrets(list) adds up to 20 secrets of your resource to /jcks, System ({ key, type, label, description?, convar? }, type is token, webhook, webhooks or text). GetSecret(key, name?) reads one back, only for the resource that registered it. A convar set in server.cfg wins.

UUID and state bags

Export What it does
NewUuid() RFC 4122 version 4 UUID, lower case
IsUuid(value) boolean
GetPlayerStateBag(src, key) / SetPlayerStateBag(src, key, value)
SetEntityStateBag(entity, key, value)
GetGlobalStateBag(key) / SetGlobalStateBag(key, value) / WatchGlobalStateBag(key, cb)

vehicle_uuid is the permanent identity of a vehicle. Plates and VINs can change, and vehicles without a plate or with a scratched VIN still save and load through the UUID. Shared bag names include jcks:duty, jcks:restrained (with the isCuffed mirror), jcks:veh ({ uuid, plate, owner, stolen, fake, scratched }), jcks:fuel ({ level, type, charge }), jcks:admin and jcks:perms.

Client

Export Returns What it does
GetSystems() / GetFramework() / GetVersion() Same as on the server
IsLoaded() boolean The character is fully loaded
GetJob() Job? Job of the local player
GetGender() string 'male' or 'female', from character data or the ped model
Notify(data or text) Through the notify provider
Progress(opts) boolean Blocking. true completed, false cancelled.
CancelProgress()
SkillCheck(difficulty, inputs?) boolean Through the skill check provider
ShowTextUI(text, icon?) / HideTextUI() Through the text UI provider
RegisterProvider(kind, name, impl) / GetProvider(kind, resource?) See Providers
GetItemCount(item) / HasItem(item, count?) count defaults to 1
GetItemImage(name) string?
OpenWardrobe() boolean false without a clothing resource
RestoreCivilian() boolean
GetPlayerSkin() table? Current look from the detected clothing resource
SetFuel(vehicle, fuel?) / GetFuel(vehicle) fuel defaults to 100.0
GetVehicleProperties(vehicle) / SetVehicleProperties(vehicle, props) You need control of the entity to set them
GetVehiclePlate(vehicle) string? Trimmed, upper case
GetMileage(vehicle) number? Kilometres from the jcks:km entity state bag
GetStatus(name) / GetStatuses() / SetStatus(name, value) Local statuses such as hunger, thirst, stress, 0 to 100
GetMoney() table { cash?, bank?, black_money?, crypto? } of the local player, read from the framework (QBCore, Qbox, ESX)
GetVoice() table Voice range, mode and radio state
IsSeatbeltOn() boolean
HasPermission(id) / GetPermissions() / IsAdmin() Permissions of the local player as published by the server
CopyClipboard(text, label?) / CopyClipboardLines(...) / CopyClipboardReport(title, rows)
NewUuid() / IsUuid(value) / GetTrinity() / HasResource(name)
GetStateBag(scope, key, id) / SetLocalStateBag(...) / WatchStateBag(...)
GetIdentityMode() table Config.Identity
GetAppearance(resource?) table Look from jcks_lib for the calling resource

Progress options

lua
local done = exports.jcks_bridge:Progress({
    duration = 5000,
    label = 'Repairing',
    canCancel = true,
    scenario = 'PROP_HUMAN_BUM_BIN',
    prop = { model = 'prop_tool_wrench', pos = vec3(0.1, 0.0, 0.0), rot = vec3(0.0, 0.0, 0.0) },
})

canCancel defaults to true. Use scenario, or anim = { dict, clip } instead.

Target

Export What it does
UsesTarget() false when target is none or nothing was found
AddTargetZone(name, coords, size, heading, options) Box zone, returns a handle
AddTargetPolyZone(name, points, thickness, options) Polygon zone, returns a handle
RemoveTargetZone(handle)
AddTargetEntity(entity, options) / RemoveTargetEntity(entity, options) Local entity
AddTargetGlobalPlayer(options) / RemoveTargetGlobalPlayer(options) Every player
AddTargetGlobalVehicle(options) / RemoveTargetGlobalVehicle(options) Every vehicle. bones = { 'boot' } in an option limits it to that bone.
AddTargetModel(models, options) / RemoveTargetModel(models, options) Every entity of the models
AddTargetGlobalObject(options) / RemoveTargetGlobalObject(options) Every object

Remove calls take the same options (and models) you added. The option format is the same for every target system. Functions run in your resource, and onSelect always receives a table with entity.

lua
local zone = exports.jcks_bridge:AddTargetZone('my_zone', vec3(441.8, -982.0, 30.7), vec3(1.5, 1.5, 2.0), 90.0, {
    {
        name = 'my_zone:open',
        label = 'Open computer',
        icon = 'fas fa-laptop',
        distance = 2.0,
        groups = { police = 0 },
        items = 'laptop',
        canInteract = function() return not IsPedInAnyVehicle(PlayerPedId(), false) end,
        onSelect = function() print('opened') end,
    },
})

exports.jcks_bridge:RemoveTargetZone(zone)

groups limits the option to jobs and minimum grades, items to players carrying the item. Both are optional.

Events

Local events, listen with AddEventHandler.

Event Side Arguments When
jcks_bridge:server:playerLoaded server src A character finished loading
jcks_bridge:server:jobChanged server src, job, lastJob? Job or grade changed. lastJob is set on ESX and the custom core.
jcks_bridge:server:dutyChanged server src, onDuty Duty changed
jcks_bridge:server:playerUnloaded server src Logout or disconnect
jcks_bridge:licenseChanged server identifier, kind, granted A licence was added or removed
jcks_bridge:settingsChanged server resource, values An admin saved script settings
jcks_bridge:ready server The bridge finished starting
jcks_bridge:mdtReady server An MDT provider accepts registrations
jcks_bridge:phone:intercept server table A text or call was reported
jcks_bridge:client:playerLoaded client job? The local character finished loading
jcks_bridge:client:jobChanged client job Local job or grade changed
jcks_bridge:client:playerUnloaded client Logout or character switch
lua
AddEventHandler('jcks_bridge:server:jobChanged', function(src, job)
    print(('%s is now %s (%s)'):format(GetPlayerName(src), job.label, job.gradeLabel))
end)

Data shapes

Job

lua
{
    name = 'police',
    label = 'LSPD',
    grade = 2,
    gradeName = 'sergeant',
    gradeLabel = 'Sergeant',
    salary = 800,
    onDuty = true,
    isBoss = false,
}

grade is always a number. salary exists on the server only, onDuty is nil when the framework has no duty. isBoss comes from isboss on QBCore and Qbox, the grade name boss on ESX and the owner role on ox_core.

OnlinePlayer

lua
{ source = 12, identifier = 'ABC12345', name = 'John Doe', job = Job }

JobDefinition

lua
local def = {
    name = 'burgershot',
    label = 'Burger Shot',
    type = 'business',
    whitelisted = false,
    defaultDuty = true,
    offDutyPay = false,
}

local grades = {
    { grade = 0, name = 'trainee', label = 'Trainee', salary = 150 },
    { grade = 1, name = 'cook', label = 'Cook', salary = 250 },
    { grade = 2, name = 'boss', label = 'Owner', salary = 500, isBoss = true },
}

exports.jcks_bridge:SyncJob(def, grades)

name takes a to z, 0 to 9 and _. type, defaultDuty and offDutyPay are used by QBCore and Qbox, whitelisted by ESX.

Systems

lua
{
    framework = 'qbx', inventory = 'ox_inventory', target = 'jcks', society = 'Renewed-Banking',
    keys = 'qbx_vehiclekeys', fuel = 'ox_fuel', clothing = 'illenium-appearance',
    nativeMultiJob = true, unemployed = 'unemployed',
    itemImagePath = 'nui://ox_inventory/web/images/%s.png', version = '2.0.0',
}

Example: pay the company for a sale

lua
jcks.callback.register('my_shop:sell', function(src, item)
    if Bridge:GetItemCount(src, item) < 1 then return false end
    if not Bridge:RemoveItem(src, item, 1) then return false end
    Bridge:AddMoney(src, 'cash', 60)
    Bridge:AddSocietyMoney('burgershot', 40, 'sale')
    return true
end, { args = { 'string' } })