Skip to content

Cuxial Bridge

The compatibility layer every Cuxial script uses to talk to your framework, inventory and target.

Cuxial Bridge lets one script run on QBox, QBCore or ESX without editing it. Scripts ask the bridge for players, money, jobs, items and target options; the bridge translates each request to whatever your server runs.

It is free and open source. Every Cuxial script requires it, and you install it once.

What it supports ​

LayerSupportedDetected by
FrameworkQBox, QBCore, ESXqbx_core, qb-core, es_extended
Inventoryox_inventory, qb-inventoryResource with that name
Targetsleepless_interact, ox_target, qb-targetResource with that name

Detection follows the order of each row. If two options are running, the first one wins: qbx_core over qb-core, ox_inventory over qb-inventory, sleepless_interact over ox_target.

If nothing is detected, the bridge falls back to QBox, ox_inventory and ox_target.

Some scripts require a specific framework: Cuxial Multichar requires QBox or QBCore. Each script's page lists its requirements.

Installation ​

Install the dependency ​

Cuxial Bridge needs ox_lib. Make sure it is installed and starts before the bridge.

Copy the resource ​

Download the latest release from GitHub and place the cuxial_bridge folder in your resources directory. Every version and its changes are listed on the releases page.

Keep the folder name cuxial_bridge. Every script loads it by that exact name and will fail to start if you rename it.

Start it after your framework ​

Add it below your framework, inventory and target, and above every Cuxial script.

server.cfg
cfg
ensure ox_lib
ensure qbx_core
ensure ox_inventory
ensure ox_target

ensure cuxial_bridge

Replace the framework, inventory and target lines with the ones your server uses.

Check the server console ​

On start, the bridge prints what it detected:

[cuxial_bridge] listo framework=qbox inventario=ox_inventory target=ox_target contexto=server

If the three values match your server, you are done.

Configuration ​

Cuxial Bridge has no configuration file. You only need the convars below when detection picks the wrong option.

Forcing a choice ​

ConvarDefaultValues
cuxial_bridge:frameworkautoauto, qbox, qbcore, esx
cuxial_bridge:inventoryautoauto, ox_inventory, qb-inventory
cuxial_bridge:targetautoauto, sleepless_interact, ox_target, qb-target
server.cfg
cfg
setr cuxial_bridge:framework "esx"
setr cuxial_bridge:inventory "ox_inventory"
setr cuxial_bridge:target "ox_target"

Use setr, not set. These values are read on the server and on each player's game; with set the two sides can disagree. Place the lines above ensure cuxial_bridge.

Custom database tables ​

Change these only if your framework stores characters or vehicles in tables with different names. They are read on the server only, so set is enough.

ConvarQBox / QBCore defaultESX defaultWhat it is
cuxial_bridge:charTableplayersusersCharacters table
cuxial_bridge:charIdColumncitizenididentifierCharacter identifier column
cuxial_bridge:vehTableplayer_vehiclesowned_vehiclesOwned vehicles table
cuxial_bridge:vehOwnerColumncitizenidownerVehicle owner column
server.cfg
cfg
set cuxial_bridge:charTable "players"

For developers ​

Your own resources can use the bridge too. Add '@cuxial_bridge/init.lua' to their shared_scripts and call Bridge.*. These modules are the most useful outside the Cuxial scripts.

Bridge.Jobs (server) ​

Manage the members of any job, with the player online or offline, on QBox, QBCore and ESX. Built for boss menus that hire, fire and promote.

FunctionReturnsWhat it does
Bridge.Jobs.Members(job)table[]{ cid, name, grade, online, src? } of every member, online and offline.
Bridge.Jobs.Grades(job)table[]{ grade, name, isboss } from lowest to highest.
Bridge.Jobs.Grade(cid, job)number | nilGrade of the character in that job, or nil if not a member.
Bridge.Jobs.Hire(cid, job, grade)ok, errGives the character that job as their main job.
Bridge.Jobs.SetGrade(cid, job, grade)ok, errChanges the grade of a member.
Bridge.Jobs.Remove(cid, job)booleanRemoves the job, only if it is the character's job.

Possible errors: params, no_job, no_grade, already, not_member, not_found, max_jobs, framework. On QBox, Hire respects qbx:setjob_replaces and qbx:max_jobs_per_player.

lua
local ok, err = Bridge.Jobs.Hire(cid, 'mechanic', 0)
if not ok then print('hire failed', err) end

Bridge.Anim (client) ​

Locks the player's animations while a scene of your resource is running: sitting at a desk, a lift, a cutscene. While locked, Cuxial Emotes does not let the player start or cancel emotes, open the menu, raise hands, cross arms, point, ragdoll, lie down or crouch, and whatever the player was doing is released when the lock starts.

FunctionReturnsWhat it does
Bridge.Anim.lock(reason)—Locks with a reason of your own ('seat', 'office'…). Repeating it does not count twice.
Bridge.Anim.unlock(reason)—Releases that reason.
Bridge.Anim.set(reason, locked)—lock or unlock depending on the boolean.
Bridge.Anim.unlockAll()—Releases every reason of your resource.
Bridge.Anim.isHeld(reason?)booleanWhether your resource holds that reason, or any reason without an argument.
Bridge.Anim.isLocked()booleanWhether the player is locked by any resource.
lua
Bridge.Anim.lock('seat')
-- ... the scene ...
Bridge.Anim.unlock('seat')
  • Several resources and reasons add up: the player is free when none is left.
  • If your resource stops, its locks are released. If Cuxial Emotes restarts, the active locks are applied again.
  • The player state animLock holds 'resource:reason' of the first lock, or nil. Read it to avoid starting your own animation on top. It is written by the client: use it to block actions, never to grant them.
  • While a lock is active, the sd-phone phone is disabled and enabled again when it ends, unless another script had already disabled it. sleepless_interact hides options with an animation while the lock lasts.
  • It requires Cuxial Emotes. Without it, the calls do nothing.

Bridge.Screens (server and client) ​

Adds screens and Cuxial OS apps from your resource to Cuxial Screens: registerScreen, removeScreen, registerApp, onCall, push, notify on the server, and open, close, isUsing on the client. They are registered again on their own if Cuxial Screens starts later or restarts. See Exports & events of Cuxial Screens.

Online players (server) ​

A list of connected players with a loaded character, kept in memory and updated by framework events (load, unload, job, gang, duty). Reading it does not call the framework for each player, so use it instead of looping over GetPlayers() with Bridge.GetPlayer.

FunctionReturnsWhat it does
Bridge.OnlinePlayers()table<src, entry>Every entry: { src, cid, job, grade, duty, boss, gang, gangGrade }. Read it, do not modify it.
Bridge.OnlineCount()numberPlayers with a loaded character.
Bridge.OnlineEntry(src)entry | nilThe entry of one player.
Bridge.OnlineSource(cid)number | nilServer id of the character, if online.
Bridge.OnlineByJob(jobs, onDutyOnly?)number[]Server ids in that job. jobs is a name, a list of names or a set { police = true }. With onDutyOnly, only those on duty.
Bridge.OnlineByGang(gang)number[]Server ids in that gang.
Bridge.OnDutyChange(cb)—Calls cb(src, onDuty) when a player goes on or off duty. QBox and QBCore.
lua
for _, src in ipairs(Bridge.OnlineByJob({ 'police', 'sheriff' }, true)) do
    Bridge.Notify(src, 'Robbery in progress', 'error')
end

Bridge.DB.GetVehicleOwners (server) ​

Bridge.DB.GetVehicleOwners(plates) returns the owner of several plates in a single query, as { [plate] = cid }. Plates without an owner are left out. It works on QBox, QBCore and ESX and follows the vehicle table convars.

lua
local owners = Bridge.DB.GetVehicleOwners({ 'ABC123', 'XYZ789' })
print(owners['ABC123'])

Bridge.Vehicles keys (server) ​

Vehicle keys from Cuxial Garages, the key item that carries the plate. Each function takes a plate or a vehicle entity. Without Cuxial Garages started, they return false.

FunctionReturnsWhat it does
Bridge.Vehicles.GiveKeys(src, plateOrVehicle)booleanGives the key. Does not duplicate it if the player already has it.
Bridge.Vehicles.RemoveKeys(src, plateOrVehicle)booleanRemoves every key of that plate from the player.
Bridge.Vehicles.HasKeys(src, plateOrVehicle)booleanWhether the player has the key.
lua
if not Bridge.Vehicles.HasKeys(src, vehicle) then
    Bridge.Vehicles.GiveKeys(src, vehicle)
end

Bridge.Fuel (server) ​

Reads and sets the fuel of a vehicle entity, from 0 to 100. It uses Cuxial Fuel when it is started and the vehicle's fuel state bag otherwise.

FunctionReturnsWhat it does
Bridge.Fuel.Get(vehicle)numberCurrent level. 0 if the entity does not exist.
Bridge.Fuel.Set(vehicle, level)booleanSets the level, clamped to 0-100.
lua
Bridge.Fuel.Set(vehicle, 100)

Bridge.Target global options (client) ​

Adds options to every vehicle, ped or object in the world, on sleepless_interact, ox_target and qb-target.

FunctionWhat it does
Bridge.Target.addGlobalVehicle(options) / removeGlobalVehicle(names)Options on every vehicle.
Bridge.Target.addGlobalPed(options) / removeGlobalPed(names)Options on every ped.
Bridge.Target.addGlobalObject(options) / removeGlobalObject(names)Options on every object.

Each option takes name, label, icon, distance, canInteract(entity) and onSelect(entity), plus bones (a bone name or a list) on targets that support it. names is a name or a list of names.

lua
Bridge.Target.addGlobalVehicle({
    {
        name = 'myres:inspect',
        label = 'Inspect',
        icon = 'fa-solid fa-magnifying-glass',
        bones = { 'boot' },
        onSelect = function(vehicle) print('inspect', vehicle) end,
    },
})

Bridge.Media (server) ​

Live view of a player's screen, and optionally their microphone, for other players: the method Cuxial Admin uses to watch and listen. Sessions belong to the resource that opens them, one per player and resource. The bridge does not check permissions: your resource decides who watches whom.

FunctionReturnsWhat it does
Bridge.Media.Open(src, opts?)string | nilStarts a session on that player and returns its id, or the id already open. opts: audio, maxViewers (0 = no limit), tag, onEnd(session, reason).
Bridge.Media.AddViewer(id, viewerSrc)booleanAdds a viewer.
Bridge.Media.RemoveViewer(id, viewerSrc)—Removes a viewer.
Bridge.Media.SetAudio(id, on)booleanTurns the player's microphone on or off in the session.
Bridge.Media.Close(id, reason?)—Ends the session.
Bridge.Media.List(tag?)table[]Active sessions of your resource, oldest first: { id, src, tag, viewers, startedAt, audio }.
Bridge.Media.Get(id)table | nilThe session, read only.
Bridge.Media.ByTarget(src)string | nilId of the session on that player.
Bridge.Media.IsViewer(id, src)booleanWhether that player is watching the session.
Bridge.Media.ViewerCount(id)numberCurrent viewers.

When a session ends, onEnd is called and the local server event cuxial_bridge:mediaEnded fires with id, reason, tag, resource. Reasons: closed, host_left, failed, resource_stop. Filter by resource if you listen from another resource.

lua
local id = Bridge.Media.Open(targetSrc, { audio = false, maxViewers = 4, tag = 'spectate' })
if id then Bridge.Media.AddViewer(id, staffSrc) end

AddEventHandler('cuxial_bridge:mediaEnded', function(sessionId, reason, tag, resource)
    if resource ~= GetCurrentResourceName() then return end
    print('session ended', sessionId, reason)
end)

The picture is captured and shown by your resource's interface. Include the live kit from the bridge's webkit/ folder: the host in the interface every player loads, and the viewer where the session is watched.

Updates ​

A few seconds after the server starts, Cuxial Bridge checks the version of every Cuxial script you run, the bridge included, and prints a single block in the server console: one line per script with a newer version, with the new number and whether it is a major, minor or patch update. When everything is up to date it prints one short line. Nothing is downloaded or changed automatically. The check is a single request that sends no data about your server.

The current version of Cuxial Bridge is 2.26.0.

ConvarWhat it does
cuxial_versioncheck 0Turns the notice off.
cuxial_versioncheck_quiet 1Hides the line shown when everything is up to date.
cuxial_versioncheck_details 1Shows up to 3 changes per outdated script.
cuxial_versioncheck_url "https://…"Changes the address the check queries.
server.cfg
cfg
set cuxial_versioncheck_details 1

To update, download the latest release, replace the cuxial_bridge folder and restart the server.

Update the bridge before updating a script: new script versions can rely on the latest bridge. See Updating a script.

Common problems ​

The console shows a warning that no framework was detected

The warning reads [cuxial_bridge] aviso: no se detectó framework, usando fallback "qbox".

Cause. Your framework was not running when the bridge, or a script, loaded.

Fix. Move the framework ensure line above cuxial_bridge and above every Cuxial script. If the framework resource has a non-standard folder name, force it with setr cuxial_bridge:framework.

The wrong inventory or target is detected

Cause. Two options are running at the same time, or yours starts after the Cuxial scripts.

Fix. Check the start order first. If both resources must stay, force the right one with setr cuxial_bridge:inventory or setr cuxial_bridge:target.

A script fails to start with an error mentioning cuxial_bridge/init.lua

Cause. The bridge is missing, was renamed, or starts after the script.

Fix. Confirm the folder is named cuxial_bridge and that ensure cuxial_bridge appears before the script.

© Cuxial