AI Core

Script exports

The exports of each ai-* script, and the APIs of other scripts they stand in for.

ai-* scripts never call each other for a shared job: items, keys, alerts, prison, medical, looks, radial items and weather go through ai-core (the lib), which calls the exports below. Call them yourself only for what is specific to that script. Exports typed in @aicore-fivem/shared work with resourceExport("ai-..."); the others with callExport(resource, name, ...args) or a plain exports[...] call.

Where a script stands in for another one (provide), the other script's export names answer too, so exports.ox_inventory:AddItem(...) reaches ai-inventory.

ai-lib

The shared player UI. Client exports, typed AiLibClientExports; the lib's notify, progress, showPrompt, menu, input, skillCheck and lockpick call them for you.

ExportWhat
Notify(notification: Notification): voidA notification card (text, title?, kind, duration?).
ShowProgress(label: string, duration: number): voidShows the progress bar for duration ms (the caller runs the action).
HideProgress(): voidHides it.
ShowPrompt(id: string, text: string, at?: { x, y, z }): voidShows or updates the caller's prompt; at draws it over a world point.
HidePrompt(id: string): voidHides a prompt.
OpenMenu(requestId: number, request: MenuRequest): voidA menu; the pick arrives as MENU_EVENTS.menuResult.
OpenInput(requestId: number, request: InputRequest): voidAn input dialog; the values arrive as MENU_EVENTS.inputResult.
OpenMinigame(requestId: number, request: MinigameRequest): voidA skill check or lockpick; the result arrives as MENU_EVENTS.menuResult.
CloseDialog(): voidCloses the caller's open menu or input (answered with null).

Server event ai-lib:client:notify (LIB_UI.notifyEvent) with a Notification shows a card on that player's screen.

ai-inventory

Server exports (own): other ai-* scripts reach them through ai-core's inventory layer.

ExportWhat
AddItem(inv: number | string, item: string, count: number, metadata?, slot?): booleanAdds items.
RemoveItem(inv: number | string, item: string, count: number, metadata?, slot?): booleanRemoves items.
GetItemCount(inv: number | string, item: string, metadata?): numberHow many.
GetItems(inv: number | string): { name, label, count, slot, metadata }[]Every stack with its label.
CanCarryItem(inv: number | string, item: string, count: number, metadata?): booleanWhether it fits.
RegisterUsableItem(name: string, handler: (source, item) => unknown): voidhandler returning false keeps the item; otherwise its consume amount is taken.
RegisterStash(name: string, label: string, slots: number, maxWeight: number, jobs?: string[], personal?: boolean): voidA stash.
OpenInventory(source: number, inv: number | string): booleanOpens an inventory on a player's screen.
ClearInventory(inv: number | string): voidEmpties it.
Items(name?: string): unknownOne item definition (ox shape), or all of them.
GetWeight(inv: number | string): { weight, maxWeight } | nullCarried weight and limit in grams.

Client exports: OpenInventory(type, data), CloseInventory(), OpenSelf() (own inventory with the ground, trunk or glovebox around), GetItemCount(item), HasItem(items: string \| string[] \| Record<string, number>, amount?), GetPlayerItems().

Server local event ai-inventory:usedItem (source, name, slot, metadata, status).

ox_inventory API

ai-inventory provides ox_inventory and answers its exports (ox_inventory 2.44). Inventories are named as in ox: a player source, a stash name, { id, owner } for personal stashes, a plate for trunks.

  • Server: AddItem (returns success, response, calls cb), RemoveItem, GetItem, GetItemCount, Search (count / slots), CanCarryItem, CanCarryWeight, CanCarryAmount, GetInventory, GetInventoryItems, GetSlot, GetSlotWithItem, GetSlotsWithItem, GetSlotIdWithItem, GetSlotIdsWithItem, GetEmptySlot, SetMetadata, SetDurability, SetMaxWeight, RegisterStash, ClearInventory, Items, ItemList, forceOpenInventory (stash, player, shop), CreateTemporaryStash, CustomDrop, RemoveInventory, SwapSlots.
  • Client: openInventory, closeInventory, Search, GetItemCount, GetPlayerItems, GetPlayerWeight, GetPlayerMaxWeight, Items, useSlot, getCurrentWeapon / GetCurrentWeapon; displayMetadata, weaponWheel, setStashTarget are accepted and do nothing.
  • Not answered: hooks (registerHook, removeHooks), UpdateVehicle, ConfiscateInventory / ReturnInventory, GetContainerFromSlot, RegisterShop (shops come from the panel).

qb-inventory API

ai-inventory provides qb-inventory (2.0 API). Returned items carry both shapes: count / metadata and amount / info.

  • Server: AddItem(identifier, item, amount, slot, info), RemoveItem, HasItem (name, list or { name = amount }), GetItemCount, GetItemByName, GetItemsByName, GetItemBySlot, CanAddItem, GetFreeWeight, GetSlots, ClearInventory, SetItemData, CreateInventory, OpenInventory, OpenInventoryById, RemoveInventory, CloseInventory.
  • Client: HasItem, CloseInventory.
  • Not answered: hooks and listeners, CreateShop / OpenShop, SetInventory, GetInventory, SaveInventory, LoadInventory, UseItem, GetFirstSlotByItem, GetSlotsByItem, GetTotalWeight.

ai-vehicles

Owned vehicles. Server exports, typed AiVehiclesServerExports. VehicleOwner is { type: "character" \| "job" \| "gang" \| "resource", id }.

ExportWhat
CreateVehicle(owner: VehicleOwner, model: string, garage: string | null, props?): { id, plate } | nullRegisters a new owned vehicle.
GetVehicle(ref: number | string): OwnedVehicle | nullA vehicle by id or plate.
GetVehicles(owner: VehicleOwner): OwnedVehicle[]Vehicles of an online character, or a job or gang fleet.
IsOwnedPlate(plate: string): booleanWhether a plate belongs to an owned vehicle.
GetVehicleIdByEntity(entity: number): number | nullThe id of a spawned owned vehicle.
GetPlateOwners(): [plate, type, id][]Every owned vehicle in memory (then follow ai-vehicles:owners).
GetEntity(id: number): number | nullThe spawned entity of a vehicle.
SaveVehicle(id: number, change: { props?, fuel?, engine?, body?, state?, garage? }): voidSaves condition and look; the stored tuning stays.
SaveTuning(id: number, props: unknown): voidSaves full props with tuning (tuning shops only).
StoreVehicle(id: number, garage: string | null, state?: VehicleState): voidPuts a vehicle into a garage (garage, out, impound).
SetOwner(id: number, owner: VehicleOwner): voidChanges the owner.
DeleteVehicle(id: number): voidDeletes a vehicle.
SpawnVehicle(id: number, at: { x, y, z, heading }, asker: number, cb: (netId: number | null) => void, purpose?: KeyPurpose, setup?): voidCreates the entity; cb gets its net id.

ai-vehicles provides qbx_vehicles: GetPlayerVehicles(filters), GetPlayerVehicle(id), CreatePlayerVehicle(request), SetPlayerVehicleOwner(id, citizenid), DeletePlayerVehicles(idType, idValue), GetVehicleIdByPlate(plate), DoesPlayerVehiclePlateExist(plate), SaveVehicle(entity, options) (citizenid filters need the owner online).

ai-vehicleshop

ExportWhat
GetCatalogPrice(model: string): number | nullA model's catalog price (server).

ai-vehiclekeys

Server exports, also under qbx_vehiclekeys. A vehicle is an entity or a plate. Scripts give keys through ai-core (GiveVehicleKeys, lib vehicleKeys), which calls these while ai-vehiclekeys is the active key system.

ExportWhat
HasKeys(source: number, vehicle: number | string): booleanWhether the player has the keys.
GiveKeys(source: number, vehicle: number | string): voidGives keys.
RemoveKeys(source: number, vehicle: number | string): voidTakes keys.
SetLockState(vehicle, state)Locks ("lock", true, 2) or unlocks a vehicle entity.
IsPlayerNearVehicle(source, vehicle)Whether the player stands near the vehicle.

ai-death

Server exports, typed AiDeathServerExports; Revive and IsDead also under qbx_medical. Scripts use ai-core's medical layer (lib medical) instead.

ExportWhat
Revive(source: number): booleanGets a downed player up; false when not down.
IsDead(source: number): booleanWhether the player is down.
Heal(source: number): voidFull health for a player who is not down.

Client event hospital:client:Revive from the server revives the player.

ai-prison

Server exports; ai-core's prison layer (lib prison) calls them.

ExportWhat
JailPlayer(source, minutes, by?)Jails a player; true when it worked.
ReleasePlayer(source)Releases a jailed player.
GetJailTime(source)Minutes left (0 when free).

ai-policealert

ExportWhat
DispatchAlert(alert: DispatchAlert): voidShows an alert card; only ai-core's dispatch layer calls it (scripts use SendDispatchAlert / lib dispatch).

ai-doorlock

Server exports, typed AiDoorlockServerExports; doors by their panel id. Also answers ox_doorlock setDoorState and getDoor.

ExportWhat
SetDoorState(id: string, locked: boolean): voidLocks or unlocks a door.
IsLocked(id: string): booleanWhether a door is locked.

ai-banking

Society money for QB scripts (an account is a job name). Server exports, also under qb-banking; Renewed-Banking getAccountMoney, addAccountMoney, removeAccountMoney answer the same.

ExportWhat
GetAccountBalance(job)A job account's bank balance.
AddMoney(job, amount, reason)Adds to it.
RemoveMoney(job, amount, reason)Takes from it.

ai-hud

ExportSideWhat
OpenSettings()ClientOpens the HUD settings.
SetMinimapAlways(on: boolean)ClientAn admin's own toggle: the minimap on foot whatever the panel says.
GetMinimapAlways(): booleanClientWhether it is kept.
GetNeeds(source)ServerThe player's hunger, thirst, stress, or null.
SetNeed(source, need, value)ServerSets one need.
AddNeed(source, need, delta)ServerChanges one need by delta.

ai-smallresources

Client exports.

ExportWhat
GetSeatbelt(): boolean | nullWhether the player wears a seat belt; null on foot or with seat belts off. Changes arrive as ai-smallresources:seatbelt.
IsHandsUp(): booleanHands up (scripts use lib gestures).
IsPointing(): booleanPointing.

ai-sirens

Client exports for emergency vehicles; vehicle defaults to the one the player sits in. State changes work on the driver's client.

ExportWhat
SetLights(vehicle, on)Lights on or off.
ToggleLights(vehicle)Flips the lights.
SetSirenTone(vehicle, tone)Tone 0-3 (0 = off).
ToggleSiren(vehicle)Siren on or off.
CycleTone(vehicle)The next tone.
GetSirenTone(vehicle)The current tone.
AreLightsOn(vehicle)Whether the lights are on.
GetAirManuState(vehicle)The manual tone state.
GetLightbarModel(vehicle)The light bar model, or null.

ai-exitsleeping

ExportSideWhat
AddCreateCheck(id, fn(source, charId, coords) => boolean)ServerReturn false to leave no sleeping body (an apartment, an event zone); dropped when the adding resource stops.
PlayerLoaded()ClientWakes the character when the wake mode is "export".
SetHidden(reason, hidden)ClientHides every sleeping body on this client while any reason holds (interiors, shells).
SetCarryBlocked(reason, blocked)ClientHides the carry option while any reason holds.

ai-appearance

Client exports, typed AiAppearanceClientExports; scripts use lib appearance.

ExportWhat
ApplyAppearance(ped: number, appearance: unknown): booleanPuts an ai-appearance look on a ped of its model.
GetPedAppearance(ped: number): unknownThe local player's look, null for other peds.

ai-radialmenu

Own client exports (typed AiRadialClientExports): AddItem(item) (onSelect is accepted as onPressed), RemoveItem(id, parent?), Refresh(). Scripts use lib radial.

It provides other wheels' APIs:

  • qb-radialmenu: AddOption(data, id?) returns the id, RemoveOption(id).
  • tgiann-radialmenu-target: AddMenuItem(item | items, parentId?), RemoveMenuItem(id, parentId?), ClearMenuItems(), RegisterSubMenu({ id, items }), RefreshMenu(), DisableMenu(state), IsMenuDisabled(), OpenMenu(), CloseMenu(), IsMenuOpen(), HasMenuItem(id), SetMenuItemHidden(id, state), IsMenuItemHidden(id), UpdateMenuItem(id, { label?, icon? }), ResetMenuItem(id).

ai-target

Answers the ox_target client API under ai-target and ox_target: addSphereZone, addBoxZone, addPolyZone, removeZone, zoneExists, addModel, removeModel, addEntity, removeEntity, addLocalEntity, removeLocalEntity, addGlobalPed / Vehicle / Object / Player and their removeGlobal*, disableTargeting, isActive. addGlobalOption is not offered (it logs a warning). Scripts use lib Points, which picks prompt or target by the owner's setting.

ai-voice

Stands in for pma-voice 7.x (provides pma-voice, mumble-voip, tokovoip, toko-voip, tokovoip_script).

  • Server, pma-voice names: setPlayerRadio, setPlayerCall, getPlayersInRadioChannel / GetPlayersInRadioChannel, addChannelCheck, overrideRadioNameGetter, isValidPlayer.
  • Server, own: getBackend, setPlayerProximityMode(source, index), setPlayerRange(source, metres | null), getPlayerProximity(source), toggleMute(source, seconds?), addProximityCheck(fn(source, index, distance)) (false refuses), addPlayerRadioListen / removePlayerRadioListen / setPlayerRadioActive(source, channel), getPlayerRadioChannels(source) ({ active, channels }), addCallCheck(fn(source, callId)) (true allows), setPlayerCallSpeaker(source, on) / getPlayerCallSpeaker(source), setPlayerSubmix(source, name | null).
  • Client: pma-voice's client exports (setRadioChannel, setCallChannel, setRadioVolume, setCallVolume, setVoiceProperty, overrideProximityRange, toggleMutePlayer, toggleRadioAnim...) plus addRadioDisableBit / removeRadioDisableBit, registerCustomSubmix, setEffectSubmix; own addRadioChannel / removeRadioChannel / setActiveRadioChannel / getRadioChannels, setCallSpeaker / getCallSpeaker, setRadioAnimDisabled, createSubmix(name, spec) / getSubmix / editSubmix / listSubmixes, cycleProximity, getBackend, isRadioTalking.
  • Local events: client pma-voice:setTalkingMode, pma-voice:radioActive, pma-voice:toggleRadioAnim; server pma-voice:playerMuted.

ai-weathersync

Exports under ai-weathersync and qb-weathersync (its whole contract): setWeather, setTime, setBlackout, setTimeFreeze, setDynamicWeather, nextWeatherStage, getWeatherState, getTime, getBlackoutState, getTimeFreezeState, getDynamicWeather. Scripts use ai-core's GetWeather / SetWeather... (lib world), which work with any weather script.

ai-chat

Stands in for FiveM's chat resource.

  • Client: exports addMessage(message), addSuggestion(name, help, params); events chat:addMessage, chatMessage (author, color, text), chat:addSuggestion(s), chat:removeSuggestion, chat:addMode / chat:removeMode, chat:clear.
  • Server: exports addMessage(target, message), registerMessageHook(fn), registerMode(data); event chatMessage (source, author, text) before delivery (cancel it to drop the message).

ai-mysql

Stands in for oxmysql: exports under ai-mysql and oxmysql: query, single, scalar, insert, update, prepare, rawExecute, transaction, startTransaction, store, isReady, awaitConnection, execute, fetch, each also as <name>_async / <name>Sync. ghmattimysql (execute, scalar, transaction, store) and mysql-async (mysql_execute, mysql_insert, mysql_fetch_all, mysql_fetch_scalar, mysql_transaction, mysql_store) names too; events oxmysql:error, oxmysql:transaction-error. See Database.

On this page