ai-core for developers
Where ai-core's exports, events, state bags and bridge are documented.
ai-core's API is large, so it has its own reference pages. This page points to them.
References
Server exports
Characters and players, money, jobs and gangs, items, keys, alerts, logs and every other server export, with types and examples.
Client exports
Player data, the HUD, key hints, the radial menu, appearance, world sync and the other client exports.
Events
playerLoaded, moneyChanged, jobsChanged, dutyChanged and the other events, with their arguments and listener examples.
The lib
@aicore-fivem/lib and aiLib: the helpers that call ai-core for you.
How to call it
import { resourceExport } from "@aicore-fivem/lib/server";
// Typed as AiCoreServerExports in @aicore-fivem/shared.
const core = resourceExport("ai-core");
const character = core.GetCharacter(source);Most of the time you do not call ai-core's exports yourself: the lib's helpers (money, inventory, online, onCharacter, vehicleKeys, dispatch...) wrap them.
Framework bridges
Scripts written for ESX, QBCore, Qbox or vRP do not need ai-core's own API: ai-core answers theirs (ESX.GetPlayerFromId, QBCore.Functions.GetPlayer, exports.qbx_core:GetPlayer, vRP's Proxy and Tunnel). What each bridge answers and its limits are on Compatibility.
State bags and GlobalState
| Key | Where | Value |
|---|---|---|
ai:duty:<job> | GlobalState | Number of on-duty members of that job. |
ai:pvp | GlobalState | Whether players can hurt each other. |
ai:inventory, ai:vehicleKeys, ai:appearance, ai:medical, ai:fuel, ai:garages, ai:mdt, ai:notify | GlobalState | The resource name of the script ai-core uses for that job. |
The full list with their shapes is in the server exports and events references.