AI Core

Framework bridge events

The ESX, QB / Qbox and vRP events ai-core fires so scripts written for those frameworks keep working, with their exact arguments, and the framework events ai-core answers.

ai-core presents itself as es_extended, qb-core, qbx_core and vrp, so scripts written for those frameworks run without changes. Part of that is firing the framework's own events when something changes in ai-core: a character loads, money moves, a job changes. This page lists every framework event the bridge fires, with the arguments as the bridge sends them, and the framework events it answers.

New code should not use these. Write against ai-core's own events (server, client) and the lib: they carry more (several jobs, gangs, duty) and do not depend on a framework shape. This page is for running and fixing existing ESX / QB / vRP scripts.

The framework views keep one job per player: the job the player is on duty in, else their first job. ai-core itself allows several jobs. ESX has no gang; ESX's money account is ai-core's cash.

QBCore and Qbox: server

The bridge fires these on the server with TriggerEvent. Qbox scripts listen to the same QBCore names; the bridge fires no Qbox-only event.

QBCore:Server:PlayerLoaded

A character was loaded (from ai-core:playerLoaded).

Side: Server

Prop

Type

resource/server/index.ts
on("QBCore:Server:PlayerLoaded", (player: { PlayerData: { source: number; citizenid: string } }) => {
  console.log(`${player.PlayerData.citizenid} loaded (src ${player.PlayerData.source})`);
});

QBCore:Server:OnPlayerUnload

A character was let go: the player left or went back to the character screen (from ai-core:playerUnloaded).

Side: Server

Prop

Type

resource/server/index.ts
on("QBCore:Server:OnPlayerUnload", (source: number) => console.log(`${source} unloaded`));

QBCore:Server:OnMoneyChange

An account balance changed (from ai-core:moneyChanged).

Side: Server

Prop

Type

resource/server/index.ts
on("QBCore:Server:OnMoneyChange", (source: number, account: string, amount: number, action: "add" | "remove", reason: string) => {
  console.log(`${source} ${action} ${amount} ${account} (${reason})`);
});

QBCore:Server:OnJobUpdate

The player's framework job changed: a job added or removed, a grade change, going on or off duty, or a panel edit of that job (from ai-core:jobsChanged, ai-core:dutyChanged, ai-core:definitionsChanged).

Side: Server

Prop

Type

resource/server/index.ts
on("QBCore:Server:OnJobUpdate", (source: number, job: { name: string; onduty: boolean; grade: { level: number } }) => {
  console.log(`${source}: ${job.name} grade ${job.grade.level}, on duty ${job.onduty}`);
});

QBCore:Server:OnGangUpdate

The player's framework gang changed: the active gang, the gang list, or a panel edit of that gang (from ai-core:gangsChanged, ai-core:activeGangChanged, ai-core:definitionsChanged).

Side: Server

Prop

Type

resource/server/index.ts
on("QBCore:Server:OnGangUpdate", (source: number, gang: { name: string }) => console.log(`${source}: gang ${gang.name}`));

QBCore and Qbox: client

Fired on the player's own client with TriggerEvent.

EventWhenArguments
QBCore:Client:OnPlayerLoadedThe character stands in the world.none
QBCore:Client:OnPlayerUnloadThe player went back to the character screen.none
QBCore:Player:SetPlayerDataAfter load and after every money, job, gang or metadata change.(PlayerData: table) the whole QB PlayerData.
QBCore:Client:OnJobUpdateThe framework job changed.(job: table) the QB job table (as on the server).
QBCore:Client:SetDutyDuty changed for the same job.(onDuty: boolean)
QBCore:Client:OnGangUpdateThe framework gang changed.(gang: table) the QB gang table.
QBCore:Client:OnMoneyChangeAn account balance changed.(account: string, balance: number) ai-core's account name and the new balance.
resource/client/index.ts
on("QBCore:Client:OnPlayerLoaded", () => console.log("loaded"));
on("QBCore:Client:OnJobUpdate", (job: { name: string }) => console.log(`job: ${job.name}`));
on("QBCore:Client:SetDuty", (onDuty: boolean) => console.log(`on duty: ${onDuty}`));

QBCore:Client:OnMoneyChange carries (account, balance), the new balance, not qb-core's own arguments. A QB script that reads it as an amount sees the balance. Prefer QBCore:Player:SetPlayerData or ai-core's onPlayerData("money", ...).

ESX: server

esx:playerLoaded

A character was loaded (from ai-core:playerLoaded).

Side: Server

Prop

Type

resource/server/index.ts
on("esx:playerLoaded", (source: number, xPlayer: { identifier: string }) => {
  console.log(`${xPlayer.identifier} loaded (src ${source})`);
});

esx:playerDropped

The player left the server (from ai-core:playerUnloaded with reason dropped).

Side: Server

Prop

Type

resource/server/index.ts
on("esx:playerDropped", (source: number) => console.log(`${source} left`));

esx:playerLogout

The player went back to the character screen and stays connected (from ai-core:playerUnloaded with reason switch).

Side: Server

Prop

Type

resource/server/index.ts
on("esx:playerLogout", (source: number) => console.log(`${source} switched character`));

esx:setJob

The player's framework job changed (same moments as QBCore:Server:OnJobUpdate).

Side: Server

Prop

Type

resource/server/index.ts
on("esx:setJob", (source: number, job: { name: string; grade: number }) => {
  console.log(`${source}: ${job.name} grade ${job.grade}`);
});

ESX: client

Fired on the player's own client with TriggerEvent.

EventWhenArguments
esx:playerLoadedThe character stands in the world.(PlayerData: table, isNew: false) ESX's client PlayerData.
esx:onPlayerLogoutThe player went back to the character screen.none
esx:setAccountMoneyAn account balance changed.(account: { name, money, label }); name is "money" for ai-core's cash.
esx:setJobThe framework job changed.(job: table, lastJob: table | nil) ESX job tables (as on the server).
esx:setPlayerDataESX.SetPlayerData ran: the ped changed (model swap, respawn) or the metadata changed.(key: string, value: any)
resource/client/index.ts
on("esx:playerLoaded", () => console.log("loaded"));
on("esx:setAccountMoney", (account: { name: string; money: number }) => console.log(`${account.name}: ${account.money}`));

vRP

ai-core's vRP bridge fires vRP's server events. The vRP user_id is ai-core's character id.

vRP:playerJoin

A character was loaded. (vRP fires it on connect; ai-core only knows the id once a character is loaded.)

Side: Server

Prop

Type

resource/server/index.ts
on("vRP:playerJoin", (userId: number, source: number, name: string) => console.log(`${name} joined as user ${userId} (src ${source})`));

vRP:playerSpawn

The character was put into the world. Fires 2 seconds after ai-core spawned it, like vRP. Only for the spawn of a character load: respawns after death come from the death script and do not fire it.

Side: Server

Prop

Type

resource/server/index.ts
on("vRP:playerSpawn", (userId: number, source: number, firstSpawn: boolean) => {
  if (firstSpawn) console.log(`user ${userId} spawned (src ${source})`);
});

vRP:playerLeave

A character was let go: the player left or switched character.

Side: Server

Prop

Type

resource/server/index.ts
on("vRP:playerLeave", (userId: number, source: number) => console.log(`user ${userId} left (src ${source})`));

vRP:playerJoinGroup and vRP:playerLeaveGroup

The character got or lost a vRP group. Groups are ai-core's jobs, the active gang, the group names the server owner mapped in the panel (tab "vRP scripts"), and extra groups vRP scripts add. Fires for every change, also changes ai-core or another script makes without vRP.

Side: Server

Prop

Type

resource/server/index.ts
on("vRP:playerJoinGroup", (userId: number, group: string, gtype?: string) => console.log(`user ${userId} joined ${group} (${gtype ?? "group"})`));
on("vRP:playerLeaveGroup", (userId: number, group: string) => console.log(`user ${userId} left ${group}`));

vRP 2 and 3 extensions get their own extension events from the bridge (characterLoad, playerJoin, characterUnload, playerLeave, playerSpawn, playerDeath, playerMoneyUpdate, playerJoinGroup / playerLeaveGroup and others) through vRP's extension event system, not as FiveM events. Not fired: vRP:save, vRP:playerRejoin, vRPcli:playerSpawned.

Framework events ai-core answers

Scripts written for a framework send these events expecting the framework to answer. ai-core answers them instead.

EventSideWhat ai-core does
QBCore:GetObject, esx:getSharedObjectbothCalls the callback with the core object (QBCore / ESX).
QBCore:Server:TriggerCallback, esx:triggerServerCallbackserver (from clients)Runs the framework callback registered with CreateCallback / RegisterServerCallback and answers. At most 30 requests per player in any 10 seconds.
QBCore:Notify, esx:showNotification, esx:showAdvancedNotification, ESX:Notifyclient (from the server)Shows ai-lib's notification.
esx:showHelpNotification, ESX:TextUI, ESX:HideUI, qb-core:client:DrawText, qb-core:client:ChangeText, qb-core:client:HideText, qb-core:client:KeyPressedclientShows or hides ai-lib's prompt.
qb-menu:client:openMenu, qb-menu:client:closeMenuclientOpens or closes ai-lib's menu with the qb-menu items.
progressbar:client:cancelclientCancels the bridge's progress bar.
police:server:policeAlertserverSends a police alert to the active alert system at the player's position. Clients send (text) (one per player in 10 seconds); server scripts TriggerEvent it with (text, camId, playerSource).
qb-weathersync:client:DisableSync / EnableSync, cd_easytime:PauseSync, vSync:toggleclientCounted as pause reasons of the weather and time sync (see Weather and time sync).

On this page