Skip to content

lx-lib — Framework Bridge

lx-lib is the shared framework and inventory bridge used by every LX product. It detects your framework at runtime and exposes one LX.* API — which is how a single LX product build runs on Qbox, QB-Core, and ESX.

For copy-ready signatures and return values, see Client Exports and Server Exports.

Layer Supported
Framework qbx_core (Qbox), qb-core (QB), es_extended (ESX)
Inventory ox_inventory (recommended, including on ESX), qb-inventory

Inventory is optional to lx-lib itself. When no supported inventory is running, lx-lib still starts and installs safe stubs — item APIs return false / 0. Advanced Bus Job currently uses money, identity, notify, and lifecycle through lx-lib; it does not require an inventory for the shipped loop.

ox_lib is optional for lx-lib notifications. lx-lib falls back to native/framework notify when ox_lib is missing. Advanced Bus Job still hard-depends on ox_lib.

Follow the standalone lx-lib installation guide for requirements, dependency order, consumer manifest setup, and verification.

Detection runs once when lx-lib starts. Priority is Qbox → QB-Core → ESX for framework, and ox_inventory → qb-inventory for inventory. Only resources already in the started state are considered. If you start or swap an adapter later, restart lx-lib and any consumers.

One option, in the open file shared/config.lua:

Config = {
Debug = false, -- true = extra adapter-load traces
}

Debug = true enables additional adapter-load traces. Framework/inventory summaries and missing-adapter warnings print regardless.

init.lua, shared/config.lua, and modules/framework/*.lua / modules/inventory/*.lua stay readable under asset escrow. The server selects the detected adapter at runtime with LoadResourceFile; encrypted module files cannot be loaded that way.

These modules are part of the shipped bridge, not routine buyer configuration. Only edit them when adding a documented framework/inventory adapter or when LX support asks.

For developers integrating with LX products or writing addons. All functions live on the global LX table after @lx-lib/init.lua is loaded.

LX.GetFramework() -- 'qbx' | 'qb' | 'esx' | nil
LX.GetInventory() -- 'ox_inventory' | 'qb-inventory' | nil
LX.GetPlayer(src) -- normalized LX player table, or nil
LX.GetIdentifier(src) -- citizenid / identifier
LX.GetName(src) -- character name

GetPlayer does not return the raw Qbox/QB/ESX player object. Every adapter returns the same normalized shape:

{
source = number,
identifier = string?,
name = string,
job = {
name = string,
label = string,
grade = number,
gradeLabel = string,
onDuty = boolean,
},
money = {
cash = number,
bank = number,
},
}
LX.GetMoney(src, account) -- account: 'cash' | 'bank' | 'money'
LX.AddMoney(src, account, amount, reason?)
LX.RemoveMoney(src, account, amount, reason?)
LX.HasMoney(src, account, amount)

Accounts are cash, bank, and money. money is a portable cash alias: it maps to cash on Qbox/QB and remains money on ESX.

LX.HasItem(src, item, count?)
LX.GetItemCount(src, item)
LX.AddItem(src, item, count, metadata?)
LX.RemoveItem(src, item, count, metadata?)

RemoveItem accepts optional metadata. ox_inventory forwards it; qb-inventory ignores metadata and removes by item/slot resolution only. Without a supported inventory, item APIs return safe failure values.

LX.GetJob(src) -- { name, label, grade, gradeLabel, onDuty } | nil
LX.HasJob(src, name, minGrade?)
LX.IsOnDuty(src)

On standard ESX there is no universal duty state; absence of an explicit off-duty value is normalized as on-duty.

-- server
LX.Notify(src, message, type?, duration?)
-- client
LX.Notify(message, type?, duration?)
LX.OnPlayerLoaded(cb) -- persistent character-ready callback

OnPlayerLoaded registers a persistent client callback. It fires once for each character-ready cycle, resets on character unload (ESX/QB/Qbox), and fires again after the next login. Late registration after the ready event still runs (async next tick). After a resource restart, lx-lib polls for an already-loaded character for up to 15 seconds. Callback errors are isolated with pcall.

-- fxmanifest.lua
shared_script '@lx-lib/init.lua'
dependency 'lx-lib'

init.lua validates that lx-lib is started and errors with a clear message if not.