NC Bridge — NothingCode shared library
nc_bridge is the shared library of the NothingCode resources (nc_party, nc_rift, nc_dungeon). It is open (no escrow), stateless and has no player texts: texts stay in each resource's locales/. NC resources load the lib/ files inside themselves from their fxmanifest (like @ox_lib/init.lua); their NUIs read themes, fonts and toasts from https://cfx-nui-nc_bridge/web/.... The full list of functions is in API.md.
What is inside
| File | Side | What it is for |
|---|---|---|
lib/core.lua | shared | version, logs, texts from the resource's locales |
lib/framework.lua | shared | Qbox / QBCore / ESX / standalone, player name and identifier |
lib/inventory.lua | server | items and money: ox_inventory, qb-inventory, framework inventory |
lib/notify.lua | shared | notices: NUI toast, GTA feed, ox_lib, okokNotify, framework |
lib/theme.lua | client | NUI theme (fantasy, scifi, horror, steampunk, dieselpunk) |
lib/xp.lua | server | where XP goes: nc_rift, KVP, framework metadata, your own resource |
lib/death.lua | shared | dead / down and revive (ml_healthsystem, framework, native) |
lib/debug.lua | server | on-disk log data/debug.log of the resource |
lib/util.lua | server | request limits, positions, refusals |
lib/party.lua | server | party members and loot split with nc_party (optional) |
web/ | NUI | 5 themes, fonts with licences, toast style |
Dependencies
- No required resource: framework, inventory, notices and medical system are detected on their own with
GetResourceStateand can be forced from the NC resource's config (see the configuration guide). - Framework: Qbox (
qbx_core), QBCore (qb-core), ESX (es_extended) or standalone. - Inventory: ox_inventory, qb-inventory or the framework's one.
- Optional: ox_lib or okokNotify (notices), ml_healthsystem (death), nc_party (party and loot), nc_rift (XP).
- OneSync recommended (player positions read by the server).
Start order
In server.cfg nc_bridge comes first, after your framework and inventory:
ensure nc_bridge
ensure nc_assets
ensure nc_party
ensure nc_rift
ensure nc_dungeonKeep only the resources you have. Every NC resource has dependency 'nc_bridge', so FiveM starts nc_bridge even without its line, but keeping it first avoids @nc_bridge/... load errors. nc_bridge can be restarted at any time (it is stateless); after updating it, restart the NC resources too. If you own several NC packs bought at different times, keep only one nc_bridge folder, the newest: the API only grows, old functions stay.
Loading the Lua files
In the fxmanifest of the resource that uses nc_bridge, after config.lua and the locales, in the order below (load only the files you need; lib/core.lua always first):
dependency 'nc_bridge'
shared_scripts {
'config.lua',
'locales/*.lua',
'@nc_bridge/lib/core.lua',
'@nc_bridge/lib/framework.lua',
'@nc_bridge/lib/inventory.lua',
'@nc_bridge/lib/notify.lua',
'@nc_bridge/lib/xp.lua',
'@nc_bridge/lib/death.lua',
'@nc_bridge/lib/party.lua',
}
client_scripts {
'@nc_bridge/lib/theme.lua',
}
server_scripts {
'@nc_bridge/lib/debug.lua',
'@nc_bridge/lib/util.lua',
}Every file works on the table NCB, owned by the resource that loads it (no variable shared between resources). At start the resource can call NCB.Require('1.0.0'): if nc_bridge is older it prints a warning in the console.
Web files for NUIs
<link rel="stylesheet" href="https://cfx-nui-nc_bridge/web/fonts.css">
<link rel="stylesheet" href="https://cfx-nui-nc_bridge/web/themes/fantasy.css">
<link rel="stylesheet" href="https://cfx-nui-nc_bridge/web/toasts.css">The theme is the class theme-<name> on <html>; the name comes from NCB.Theme() on the client. Fonts are in web/fonts/ with their licences in fonts/LICENSES.txt (OFL 1.1 / Apache 2.0).
Configuration
nc_bridge has no config.lua of its own: it reads Config.Bridge, Config.UI, Config.Locale and Config.Debug of the resource that loads it. Every key and hook to adapt inventory, notices, death and XP is in the configuration guide.
The full guide in 9 languages is also in the resource's docs/ folder.