AI Core

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

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

KeyWhereValue
ai:duty:<job>GlobalStateNumber of on-duty members of that job.
ai:pvpGlobalStateWhether players can hurt each other.
ai:inventory, ai:vehicleKeys, ai:appearance, ai:medical, ai:fuel, ai:garages, ai:mdt, ai:notifyGlobalStateThe 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.

On this page