ai-radialmenu for developers
Adding items to the radial menu, the RadialItem shape, ai-radialmenu's own client exports and the radial APIs it answers.
Add your items through AI Core, not through ai-radialmenu: lib radial.add(item) in TypeScript or aiLib.radial.add(item) in Lua. AI Core keeps the items, hands them to whichever radial menu the server runs, gives them again to a radial that restarts, and drops them when your resource stops. Calling ai-radialmenu directly ties your script to one wheel.
Adding an item (recommended way)
radial.add
Adds an item to the wheel, or replaces the item with the same id.
Side: Client · Waits: no
radial.add(item: RadialItem): voidaiLib.radial.add(item)Parameters
Prop
Type
RadialItem
Prop
Type
Returns
Nothing.
Example
import { radial, notify, onPlayerData, getPlayerData } from "@aicore-fivem/lib/client";
import { RADIAL_VEHICLE } from "@aicore-fivem/shared";
import Locale from "common/locale";
// A police category on the main wheel, shown only on duty.
radial.add({
id: "police",
label: Locale("RADIAL_POLICE"),
icon: "shield-halved",
canShow: () => getPlayerData("duty") === "police",
items: [
{ id: "police_cuff", label: Locale("RADIAL_CUFF"), icon: "handcuffs", onPressed: () => emit("myscript:cuffNearest") },
],
});
// An item inside the built-in vehicle category.
radial.add({
id: "myscript_windows",
label: Locale("RADIAL_WINDOWS"),
icon: "car-side",
parent: RADIAL_VEHICLE,
keepOpen: true,
onPressed: () => notify(Locale("WINDOWS_TOGGLED"), "info"),
});
// Duty changed: read every canShow of an open wheel again.
onPlayerData("duty", () => radial.refresh());Add your items once, when your resource starts. Do not add them again when the radial menu restarts: AI Core does that for you. canShow runs on every open, so keep it cheap (read cached data, no server calls).
radial.remove
Removes one of your items by id. Side: Client · Waits: no.
radial.remove(id: string): voidaiLib.radial.remove('myscript_windows')radial.refresh
Reads every canShow of an open wheel again. Call it after the data your canShow reads has changed while the wheel may be open. Side: Client · Waits: no.
radial.refresh(): voidaiLib.radial.refresh()ai-radialmenu's own client exports
AI Core's radial layer calls these. They are typed AiRadialClientExports in @aicore-fivem/shared.
| Export | What it does |
|---|---|
AddItem(item: RadialItem & { onSelect?: () => void }): void | Adds or replaces an item owned by the calling resource. onSelect is accepted as an older name of onPressed. parent puts it into a sub menu. |
RemoveItem(id: string, parent?: string): void | Removes an item (from under parent when given). |
Refresh(): void | Reads every canShow of an open wheel again. |
Items, sub menus and item states of a resource are removed when that resource stops.
APIs it answers
ai-radialmenu provides two other wheels, so their export names reach it:
- qb-radialmenu:
AddOption(data, id?)returns the id the item is kept under;RemoveOption(id). Item fieldstitle,icon(fas fa-xaccepted),items,action(a function) ortype+event(client,server,command,qbcommand),shouldClose = falsekeeps the wheel open. - 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). Item fieldslabel(a text, or{ en, tr }picked by theai:localeconvar),canInteract(args),onSelect(args),event+type+args,command,export { resource, name, args },menu,shouldClose,whileDead.
Not answered: tgiann-radialmenu-target's GetCurrentMenuId, its settings and server exports, and its local events (menuOpened, itemSelected). Its target API is answered by ai-target.
Events
None for other scripts. The wheel's NUI messages (open, update, close) and callbacks (select, close) are internal.