A lightweight compatibility bridge for anx-scripts resources.
anx_bridge detects which framework, inventory and target system your server is
running and exposes a single, unified API through the global Bridge object.
Write your resource once against the bridge and it will run on any supported
stack — no per-framework forks, no if QBCore then ... elseif ESX then ....
| Module | Supported resources |
|---|---|
framework |
qb-core, qbx_core, es_extended |
inventory |
qb-inventory, ox_inventory |
target |
qb-target, ox_target |
If no supported resource is detected for a module, a fallback adapter is loaded instead. Fallbacks are no-ops that log a warning, so a missing dependency never crashes the resource — it just degrades gracefully.
On start, init.lua iterates over each module (framework, inventory,
target) and picks the adapter to load:
- It reads the convar
anx_bridge:<module>(defaultauto). - In
automode it loads the adapter for the first supported resource whose state isstarted. - You can force a specific resource by setting the convar (see below).
- If nothing matches, the
fallbackadapter is used.
The chosen adapters are attached to the global Bridge table:
Bridge = {
framework = { ... }, -- FrameworkModule
inventory = { ... }, -- InventoryModule
target = { ... }, -- TargetModule
shared = { ... }, -- utils
}
server methods are stripped on the client and client methods are stripped on
the server, so you always access the correct side directly.
When run as a standalone resource, anx_bridge prints the resolved adapters for
each module on startup.
Force a specific adapter instead of auto-detection (server.cfg):
# valid values: auto (default) | qb-core | qbx_core | es_extended
setr anx_bridge:framework auto
# valid values: auto (default) | qb-inventory | ox_inventory
setr anx_bridge:inventory auto
# valid values: auto (default) | qb-target | ox_target
setr anx_bridge:target autoAdd the bridge to your resource's fxmanifest.lua and require it as a shared
script (it must load after ox_lib):
shared_scripts {
'@ox_lib/init.lua',
'@anx_bridge/init.lua',
}Important: in your
server.cfg, startanx_bridgeafterox_liband the resources it bridges (framework, inventory, target). Any resource that uses the bridge must start afteranx_bridge.
Then use the global Bridge object anywhere in your resource. Refer to
types.lua for the full API surface of each module.
Each module is a directory containing one Lua file per supported resource plus a
fallback.lua.
To support a new resource for a module that already exists (e.g. a new inventory):
- Create
<module>/<resource>.luareturning a table that implements the module's interface (seetypes.luafor the full contracts). - Add an entry to that module's
pathlist ininit.lua:{ name = "<resource>", file = "<resource>" },nameis the resource name checked againstGetResourceState,fileis the Lua file to load (they can differ — e.g.qbx_corereuses theqb-corefile). - The resource's
nameis now a valid value for the module's convar (anx_bridge:<module>), so it can be forced instead of auto-detected. Add it to that module's list of valid values in the Convars section.
To add a whole new module (e.g. dispatch, phone):
- Create a
<module>/directory with one Lua file per supported resource plus afallback.lua, each returning a table withclient/servertables. - Describe its interface in
types.lua— a<Module>Moduleclass — and add a matching field toBridgeRoot. - Register the module in the
moduleslist ininit.luawith itsnameandpathentries. - Add
'<module>/**.lua'to thefilesblock infxmanifest.lua. - The module automatically gets its own
anx_bridge:<module>convar (defaults toauto). Document it and its valid values in the Convars section.