Nivo Bridge
API
Functions for developers who extend nv_bridge or build on top of it.
For developers who extend nv_bridge (a custom adapter) or write their own resource on top of it. Nivo scripts load the bridge with one line in their manifest:
-- fxmanifest.lua
dependency 'nv_bridge'
shared_scripts { '@nv_bridge/init.lua', 'config.lua' }
nv_sql 'sql/001_tables.sql' -- run once per database, in this order
nv_sql_esx 'install/esx_items.sql' -- only on ESX (also nv_sql_qb, nv_sql_qbox)
nivo_requires 'ox_lib' -- optional: stop with a clear message when missing
nivo_optional 'bob74_ipl' -- optional: warning only
Detected systems
| Field | Values |
|---|---|
Bridge.Framework | 'esx', 'qb', 'qbox' |
Bridge.Inventory | 'ox', 'qb', 'ps', 'lj', 'qs', 'codem', 'ak47', 'native', 'custom' ... |
Bridge.TargetSystem | 'ox', 'qb', 'builtin', 'custom' |
Bridge.DispatchSystem | 'lb', 'cd', 'ps', 'qs', 'rcore', 'builtin', 'custom' |
Bridge.NotifySystem | 'esx', 'qb', 'qbox', 'ox', 'okok', 'brutal', 'mythic', 'pnotify', 'tnotify', 'custom' |
Bridge.ProgressSystem | 'ox', 'qb', 'esx', 'builtin', 'custom' |
Server
| Function | Returns |
|---|---|
Bridge.GetPlayer(src) | { source, identifier, job = { name, grade, onduty }, getName(), getAccount(name), addAccountMoney(name, n, reason), removeAccountMoney(name, n, reason), raw } or nil |
Bridge.GetPlayers() | list of player objects |
Bridge.Identifier(src) | identifier (ESX) or citizenid (QBCore, Qbox) |
Bridge.CountJobs({ 'police' }) | on-duty players with one of the jobs (cached 5 s) |
Bridge.RegisterUsable(item, cb) | cb(src, ...) when the item is used |
Bridge.Inv.GetItemCount(src, item) | number |
Bridge.Inv.Search(src, 'slots', item) | { { slot, count, metadata } } |
Bridge.Inv.AddItem(src, item, count, metadata, slot) | true / false |
Bridge.Inv.RemoveItem(src, item, count, metadata, slot) | true / false |
Bridge.Inv.CanCarryItem(src, item, count) | true / false |
Bridge.Inv.ItemLabel(item) | display name |
Bridge.Stash.Register(id, label, slots, weight), .Add, .Clear, .Open(src, id), .Guard(prefix, fn) | storage inventories |
Bridge.Pay.Has(src, 'money' or 'bank', price), Bridge.Pay.Charge(...) | true / false |
Bridge.AddDirty(src, amount) | ESX black_money, QBCore / Qbox dirty money item |
Bridge.SocietyAdd(account, amount) | esx_addonaccount, Renewed-Banking, qb-banking |
Bridge.Notify(src, message, type, title) | notification on the player's client |
Bridge.Alert(alert) | police alert through the detected dispatch |
Bridge.DB | the oxmysql MySQL object |
Bridge.DB.Ready(fn) | runs fn after the script's SQL files are applied |
Bridge.OnPlayerLoaded(cb), Bridge.OnJobUpdate(cb) | cb(src) |
Alert format:
Bridge.Alert({
jobs = { 'police' }, -- default: PoliceJobs from config.lua
code = '10-90',
title = 'Drug sale',
message = 'Suspicious hand-to-hand sale reported',
coords = GetEntityCoords(GetPlayerPed(src)),
priority = 'medium', -- 'low' | 'medium' | 'high'
blip = { sprite = 161, color = 1, scale = 1.0 },
src = src, -- suspect, optional
})
Client
| Function | Returns |
|---|---|
Bridge.PlayerJob() | { name, grade } |
Bridge.Notify(message, type, title, duration) | ā |
Bridge.Progress({ duration, label, canCancel, anim = { dict, clip, flag }, disable = { move, car, combat } }) | true when finished, false when cancelled |
Bridge.Inv.Count(item) | number |
Bridge.Pay.Choose(price) | 'money', 'bank' or nil |
Bridge.Blip.Add(key, { coords, sprite, color, scale, label }), Bridge.Blip.Remove(key) | ā |
Bridge.Target.addLocalEntity(entity, options), removeLocalEntity, addSphereZone(data), removeZone(id), addGlobalPed(options) | ox_target option format on every target |
NUI callback nvTheme | the script's Config.Theme, else the Theme from nv_bridge/config.lua (the window asks for it when it opens) |
Shared
| Function | Returns |
|---|---|
_L('key', ...) | text from locales/<Config.Locale>.json, then locales/en.json, then the key |
Bridge.IsStarted(resource) | true when the resource is started or starting |
Bridge.Register(kind, name, adapter) | adds an adapter (used by the files in custom/) |