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.
| Export | What |
|---|---|
Notify(notification: Notification): void | A notification card (text, title?, kind, duration?). |
ShowProgress(label: string, duration: number): void | Shows the progress bar for duration ms (the caller runs the action). |
HideProgress(): void | Hides it. |
ShowPrompt(id: string, text: string, at?: { x, y, z }): void | Shows or updates the caller's prompt; at draws it over a world point. |
HidePrompt(id: string): void | Hides a prompt. |
OpenMenu(requestId: number, request: MenuRequest): void | A menu; the pick arrives as MENU_EVENTS.menuResult. |
OpenInput(requestId: number, request: InputRequest): void | An input dialog; the values arrive as MENU_EVENTS.inputResult. |
OpenMinigame(requestId: number, request: MinigameRequest): void | A skill check or lockpick; the result arrives as MENU_EVENTS.menuResult. |
CloseDialog(): void | Closes 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.
| Export | What |
|---|---|
AddItem(inv: number | string, item: string, count: number, metadata?, slot?): boolean | Adds items. |
RemoveItem(inv: number | string, item: string, count: number, metadata?, slot?): boolean | Removes items. |
GetItemCount(inv: number | string, item: string, metadata?): number | How many. |
GetItems(inv: number | string): { name, label, count, slot, metadata }[] | Every stack with its label. |
CanCarryItem(inv: number | string, item: string, count: number, metadata?): boolean | Whether it fits. |
RegisterUsableItem(name: string, handler: (source, item) => unknown): void | handler returning false keeps the item; otherwise its consume amount is taken. |
RegisterStash(name: string, label: string, slots: number, maxWeight: number, jobs?: string[], personal?: boolean): void | A stash. |
OpenInventory(source: number, inv: number | string): boolean | Opens an inventory on a player's screen. |
ClearInventory(inv: number | string): void | Empties it. |
Items(name?: string): unknown | One item definition (ox shape), or all of them. |
GetWeight(inv: number | string): { weight, maxWeight } | null | Carried 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(returnssuccess, response, callscb),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,setStashTargetare 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 }.
| Export | What |
|---|---|
CreateVehicle(owner: VehicleOwner, model: string, garage: string | null, props?): { id, plate } | null | Registers a new owned vehicle. |
GetVehicle(ref: number | string): OwnedVehicle | null | A vehicle by id or plate. |
GetVehicles(owner: VehicleOwner): OwnedVehicle[] | Vehicles of an online character, or a job or gang fleet. |
IsOwnedPlate(plate: string): boolean | Whether a plate belongs to an owned vehicle. |
GetVehicleIdByEntity(entity: number): number | null | The id of a spawned owned vehicle. |
GetPlateOwners(): [plate, type, id][] | Every owned vehicle in memory (then follow ai-vehicles:owners). |
GetEntity(id: number): number | null | The spawned entity of a vehicle. |
SaveVehicle(id: number, change: { props?, fuel?, engine?, body?, state?, garage? }): void | Saves condition and look; the stored tuning stays. |
SaveTuning(id: number, props: unknown): void | Saves full props with tuning (tuning shops only). |
StoreVehicle(id: number, garage: string | null, state?: VehicleState): void | Puts a vehicle into a garage (garage, out, impound). |
SetOwner(id: number, owner: VehicleOwner): void | Changes the owner. |
DeleteVehicle(id: number): void | Deletes a vehicle. |
SpawnVehicle(id: number, at: { x, y, z, heading }, asker: number, cb: (netId: number | null) => void, purpose?: KeyPurpose, setup?): void | Creates 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
| Export | What |
|---|---|
GetCatalogPrice(model: string): number | null | A 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.
| Export | What |
|---|---|
HasKeys(source: number, vehicle: number | string): boolean | Whether the player has the keys. |
GiveKeys(source: number, vehicle: number | string): void | Gives keys. |
RemoveKeys(source: number, vehicle: number | string): void | Takes 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.
| Export | What |
|---|---|
Revive(source: number): boolean | Gets a downed player up; false when not down. |
IsDead(source: number): boolean | Whether the player is down. |
Heal(source: number): void | Full 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.
| Export | What |
|---|---|
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
| Export | What |
|---|---|
DispatchAlert(alert: DispatchAlert): void | Shows 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.
| Export | What |
|---|---|
SetDoorState(id: string, locked: boolean): void | Locks or unlocks a door. |
IsLocked(id: string): boolean | Whether 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.
| Export | What |
|---|---|
GetAccountBalance(job) | A job account's bank balance. |
AddMoney(job, amount, reason) | Adds to it. |
RemoveMoney(job, amount, reason) | Takes from it. |
ai-hud
| Export | Side | What |
|---|---|---|
OpenSettings() | Client | Opens the HUD settings. |
SetMinimapAlways(on: boolean) | Client | An admin's own toggle: the minimap on foot whatever the panel says. |
GetMinimapAlways(): boolean | Client | Whether it is kept. |
GetNeeds(source) | Server | The player's hunger, thirst, stress, or null. |
SetNeed(source, need, value) | Server | Sets one need. |
AddNeed(source, need, delta) | Server | Changes one need by delta. |
ai-smallresources
Client exports.
| Export | What |
|---|---|
GetSeatbelt(): boolean | null | Whether the player wears a seat belt; null on foot or with seat belts off. Changes arrive as ai-smallresources:seatbelt. |
IsHandsUp(): boolean | Hands up (scripts use lib gestures). |
IsPointing(): boolean | Pointing. |
ai-sirens
Client exports for emergency vehicles; vehicle defaults to the one the player sits in. State changes work on the driver's client.
| Export | What |
|---|---|
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
| Export | Side | What |
|---|---|---|
AddCreateCheck(id, fn(source, charId, coords) => boolean) | Server | Return false to leave no sleeping body (an apartment, an event zone); dropped when the adding resource stops. |
PlayerLoaded() | Client | Wakes the character when the wake mode is "export". |
SetHidden(reason, hidden) | Client | Hides every sleeping body on this client while any reason holds (interiors, shells). |
SetCarryBlocked(reason, blocked) | Client | Hides the carry option while any reason holds. |
ai-appearance
Client exports, typed AiAppearanceClientExports; scripts use lib appearance.
| Export | What |
|---|---|
ApplyAppearance(ped: number, appearance: unknown): boolean | Puts an ai-appearance look on a ped of its model. |
GetPedAppearance(ped: number): unknown | The 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...) plusaddRadioDisableBit/removeRadioDisableBit,registerCustomSubmix,setEffectSubmix; ownaddRadioChannel/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; serverpma-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); eventschat: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); eventchatMessage (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.