Bridge — server API
Every server-side bridge function — players, money, jobs, gangs, inventory and lifecycle.
Every server-side bridge function — players, money, jobs, gangs, inventory and lifecycle.
These functions run server-side, on lib.bridge. Every return is normalized — the same
shape on ESX, QBCore, QBox, ox and vanilla.
| Function | Returns | Description |
|---|---|---|
getPlayer(source) | BridgePlayer? | The player, or nil if not found. |
getIdentifier(source) | string? | Stable identifier (license / citizenid). |
getCoords(source) | vector3? | Current position. |
getPlayers() | number[] | Connected player source ids. |
getPlayerCount() | number | Number of players online. |
getCharacterName(source) | string | RP name; always a string (falls back to account name, then Unknown). |
isPlayerOnline(source) | boolean | Whether the source maps to a loaded player. |
kick(source, reason?) | — | Kick with an optional reason. |
getPlayer(source)BridgePlayer?nil if not found.getIdentifier(source)string?getCoords(source)vector3?getPlayers()number[]source ids.getPlayerCount()numbergetCharacterName(source)stringUnknown).isPlayerOnline(source)booleansource maps to a loaded player.kick(source, reason?)---@class BridgePlayer
---@field source number
---@field identifier string
---@field name string| Function | Returns | Description |
|---|---|---|
getMoney(source, moneyType?) | number | Balance of an account. |
addMoney(source, moneyType?, amount) | — | Add to an account. |
removeMoney(source, moneyType?, amount) | — | Remove from an account. |
canAfford(source, amount, accounts?) | boolean | Whether the summed accounts cover amount. |
getAccounts(source) | table | Returns { cash, bank, black }. |
getMoney(source, moneyType?)numberaddMoney(source, moneyType?, amount)removeMoney(source, moneyType?, amount)canAfford(source, amount, accounts?)booleanamount.getAccounts(source)table{ cash, bank, black }.moneyType is cash (default), bank or black — normalized across frameworks (black
maps to black_money on ESX, crypto on QB/QBox). canAfford defaults to { cash, bank }.
| Function | Returns | Description |
|---|---|---|
getJob(source) | BridgeJob? | Current job. |
setJob(source, name, grade) | — | Set the player's job. |
getPlayersByJob(jobs, options?) | BridgePlayer[] | Players on one or more jobs. |
getJobs() | table | All jobs, keyed by name. |
getJob(source)BridgeJob?setJob(source, name, grade)getPlayersByJob(jobs, options?)BridgePlayer[]getJobs()tablegetPlayersByJob takes a job string or a list; options.minGrade (default 0) filters by grade.
---@class BridgeJob
---@field name string
---@field label string
---@field grade number
---@field gradeLabel string| Function | Returns | Description |
|---|---|---|
getGang(source) | BridgeGang? | Current gang. |
setGang(source, name, grade) | — | Set the player's gang. |
getGangs() | table | All gangs. |
getPlayersByGang(gangs, options?) | BridgePlayer[] | Players in one or more gangs. |
getGang(source)BridgeGang?setGang(source, name, grade)getGangs()tablegetPlayersByGang(gangs, options?)BridgePlayer[]ESX, ox and vanilla have no native gang — these return nil / {} with a one-time warning.
| Function | Returns | Description |
|---|---|---|
hasItem(source, itemName, count?) | boolean | Whether the player holds at least count (default 1). |
addItem(source, itemName, count, metadata?) | — | Give an item. |
removeItem(source, itemName, count, metadata?) | — | Take an item. |
getInventory(source) | BridgeInventoryItem[] | The player's items. |
registerUsableItem(itemName, cb) | — | Run cb(source) when the item is used. |
hasItem(source, itemName, count?)booleancount (default 1).addItem(source, itemName, count, metadata?)removeItem(source, itemName, count, metadata?)getInventory(source)BridgeInventoryItem[]registerUsableItem(itemName, cb)cb(source) when the item is used.Uses ox_inventory when present, otherwise the framework's native inventory. On ESX without
ox, item.metadata is always nil — handle that if you read it.
| Function | Returns | Description |
|---|---|---|
notify(source, data) | — | Show a notification to the player. |
notify(source, data)---@class NotifyData
---@field type 'info' | 'success' | 'error' | 'warning'
---@field content string
---@field title? string
---@field duration? number| Function | Returns | Description |
|---|---|---|
onPlayerLoaded(cb) | — | Runs cb(source) when a player finishes loading. |
onPlayerDropped(cb) | — | Runs cb(source, reason) when a player disconnects. |
onPlayerLoaded(cb)cb(source) when a player finishes loading.onPlayerDropped(cb)cb(source, reason) when a player disconnects.| Function | Returns | Description |
|---|---|---|
giveVehicleKeys(source, vehicle) | — | Give keys for vehicle (entity handle). |
removeVehicleKeys(source, vehicle) | — | Remove keys. |
giveVehicleKeys(source, vehicle)vehicle (entity handle).removeVehicleKeys(source, vehicle)Routed through your see:keys system. mrnewb and qs are client-only, so the server call
is a no-op there — see Detection & config for the support note.
Used by multicharacter flows. createCharacter returns an opaque token you store and pass
back to loadCharacter as-is — its content is framework-specific, don't parse it.
| Function | Returns | Description |
|---|---|---|
loadCharacter(source, charToken) | — | Load a character from a stored token. |
createCharacter(source, slot, data) | string? | Create a character; returns the token to store. |
loadCharacter(source, charToken)createCharacter(source, slot, data)string?local player = lib.bridge.getPlayer(source)
if not player then return end
if not lib.bridge.canAfford(source, 500) then
lib.bridge.notify(source, { type = 'error', content = 'Not enough money' })
return
end
lib.bridge.removeMoney(source, 'bank', 500)
lib.bridge.addItem(source, 'phone', 1)
lib.bridge.notify(source, { type = 'success', content = 'Phone bought' })No cache — every call refetches from the framework. Cache it yourself if you call the same getter in a tight loop.