AI Core

ai-smallresources for developers

Client exports, the seat belt event, state bags and metadata of ai-smallresources.

To read the seat belt or gestures from your own script, use the lib's seatbelt.isOn() / seatbelt.onChange(fn) and gestures.isHandsUp() / gestures.isPointing() (client; Lua aiLib.seatbelt, aiLib.gestures). They go through ai-core and work with whichever seat belt or emote script runs. The exports below are what ai-core reads while ai-smallresources answers.

All three exports are on the client, synchronous, and read the local player. GetSeatbelt is typed as AiSmallResourcesClientExports in @aicore-fivem/shared; IsHandsUp and IsPointing are not typed (use callExport).

TypeScript
import { resourceExport, callExport } from "@aicore-fivem/lib/client";
const small = resourceExport("ai-smallresources");

Client exports

GetSeatbelt

Whether the local player wears a seat belt.

Side: Client · Waits: no

Signature
GetSeatbelt(): boolean | null
Lua
local worn = exports['ai-smallresources']:GetSeatbelt() -- true, false or nil

Returns

true when buckled, false when not. null when the Seatbelt feature is switched off in the panel, or the player is not in a vehicle with a seat belt.

Example

import { seatbelt } from "@aicore-fivem/lib/client";

// A HUD's belt icon: read once, then follow changes.
let worn = seatbelt.isOn();
seatbelt.onChange((value) => {
  worn = value;
});

Read it on an action or a vehicle change, never every frame.

IsHandsUp

Whether the local player has their hands up (the X gesture).

Side: Client · Waits: no

Signature
IsHandsUp(): boolean
Lua
local up = exports['ai-smallresources']:IsHandsUp()

Returns

true while the hands are up, false otherwise.

IsPointing

Whether the local player is pointing (the B gesture).

Side: Client · Waits: no

Signature
IsPointing(): boolean
Lua
local pointing = exports['ai-smallresources']:IsPointing()

Returns

true while pointing, false otherwise.

Events

ai-smallresources:seatbelt

Fires on the local client when the seat belt changes. The name is SEATBELT_EVENT in @aicore-fivem/shared. ai-core passes it on as its own seat belt event, which the lib's seatbelt.onChange listens to; prefer that.

Side: Client (local event)

Prop

Type

Lua
AddEventHandler('ai-smallresources:seatbelt', function(worn)
  print('seat belt', worn)
end)

Every other event of ai-smallresources is internal (its client and its server).

State bags and metadata

NameOnTypeMeaning
aiHoldplayerstring | falseThe news item the player holds (newscam, newsmic, newsboom).
aiCarryingplayernumberThe player is carrying someone (their server id).
aiCarriedByplayernumberThe player is carried by someone (their server id).
aiDivingplayerbooleanThe player wears the diving gear.
aiRealPlatevehiclestringThe real plate while a fake plate is fitted.
aiMooredvehiclebooleanThe boat is tied to a mooring.
diveOxygencharacter metadata (ai-core)numberSeconds of air left in the dive tank.
aiPlayerCount / aiMaxPlayersGlobalStatenumberPlayers online and slots, set while Discord Rich Presence is on.
// Server: the real plate of a vehicle, fake or not.
export function realPlate(vehicle: number): string {
  const real = Entity(vehicle).state.aiRealPlate as string | undefined;
  return real ?? GetVehicleNumberPlateText(vehicle);
}

Usable items

Registered through ai-core's inventory layer, so they work with whichever inventory runs: binoculars, firework1-firework4, newscam, newsmic, newsboom, fakeplate, notepad, note (metadata text and description), diving_gear, diving_fill.

On this page