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).
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
GetSeatbelt(): boolean | nulllocal worn = exports['ai-smallresources']:GetSeatbelt() -- true, false or nilReturns
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
IsHandsUp(): booleanlocal 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
IsPointing(): booleanlocal 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
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
| Name | On | Type | Meaning |
|---|---|---|---|
aiHold | player | string | false | The news item the player holds (newscam, newsmic, newsboom). |
aiCarrying | player | number | The player is carrying someone (their server id). |
aiCarriedBy | player | number | The player is carried by someone (their server id). |
aiDiving | player | boolean | The player wears the diving gear. |
aiRealPlate | vehicle | string | The real plate while a fake plate is fitted. |
aiMoored | vehicle | boolean | The boat is tied to a mooring. |
diveOxygen | character metadata (ai-core) | number | Seconds of air left in the dive tank. |
aiPlayerCount / aiMaxPlayers | GlobalState | number | Players 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.