Layers and the bridge
How AI Core sits between scripts - integration layers, stand-ins and the ESX / QB / Qbox bridge.
Integration layers
A script never calls another script's exports for a shared job. It calls the lib, the lib calls AI Core, and AI Core forwards to the script the server runs for that job. Each layer picks its adapter at start (the admin panel can override it) and again when a candidate starts or stops.
| Layer | Lib | Adapters |
|---|---|---|
| Inventory | inventory | ai-inventory, ox_inventory, qb-inventory, tgiann-inventory and more |
| Vehicle keys | vehicleKeys | ai-vehiclekeys, qbx_vehiclekeys and others |
| Dispatch | dispatch.alert | ai-policealert and alert scripts |
| Phone | phone | tgiann-phone, lb-phone |
| Weather and time | world | the qb-weathersync API (ai-weathersync, qb-weathersync, Renewed), cd_easytime; pauses counted per reason |
| Prison | prison | ai-prison, qb-prison |
| Appearance | appearance | ai-appearance, tgiann-clothing |
| Medical | medical | ai-death, qbx_medical, qb-ambulancejob, esx_ambulancejob, ars_ambulancejob |
| Radial menu | radial | ai-radialmenu, qb-radialmenu, ox_lib |
| Gestures | gestures | ai-smallresources, tgiann-emotes |
| HUD | hud, keyHints | ai-hud, tgiann-lumihud |
| Prime time | isPrimeTime | tgiann-policealert, else the panel's hours |
Adding a script to a layer is one adapter file and one registry line.
The bridge
ai-core provides es_extended, qb-core and qbx_core and answers their APIs from Lua files in bridge/:
- core objects (
exports['qb-core']:GetCoreObject(),ESX = exports.es_extended:getSharedObject(), the legacy events), Qbox exports; - player objects (
xPlayer, QBPlayer) mirrored from AI Core's change events, never by asking AI Core per read; - client
PlayerDatabuilt from AI Core's own player data channel; - framework events with the same arguments and timing (
QBCore:Client:OnPlayerLoaded,esx:setJob...); - callbacks, usable items, commands (listed in the panel), notifications, menus, text prompts and progress bars drawn with AI Core's UI;
- file includes (
@qb-core/shared/locale.lua,@es_extended/imports.lua,@qbx_core/modules/playerdata.lua).
The bridge runs on a copy of ai-lib's Lua side, so framework helpers (streaming, zones, keybinds, progress, rate limits) share the lib's code.