HUD
Hide and show every HUD while your full-screen UI is open, read whether HUDs show, and open the running HUD's own settings.
When your script opens a full-screen UI (a shop, a phone, a photo mode), the HUD should get out of the way. These exports hide and show whichever HUD the server runs: ai-hud, or a third-party HUD ai-core knows (tgiann-lumihud, tgiann-hudv2, tgiann-modern-hud, tgiann-statushud, jg-hud, 0r-hud-v3, codem-supreme-hud, Codem-BlackHUDV2, wais-hudv6, qb-hud, ps-hud). With no known HUD, ai-core hides and shows the minimap instead. qb-hud and ps-hud cannot be hidden by another script: with them only the minimap follows.
Hiding works with reasons. Each resource hides the HUD under a name of its choice ("shop", "photo-mode"). HUDs stay hidden while at least one reason is set by any resource, so two screens open at once never fight: the HUD comes back only after both close. Reasons belong to the resource that set them and are removed when it stops.
HideHud
Hides every HUD (and the minimap when no known HUD runs) under a reason of your resource. Call it when your full-screen UI opens.
Side: Client · Waits: no
HideHud(reason: string): voidexports['ai-core']:HideHud(reason) -- or aiLib.hud.hide(reason)Parameters
Prop
Type
Returns
Nothing. A reason that is not a string is ignored.
Example
import { hud } from "@aicore-fivem/lib/client";
export function openShop(): void {
hud.hide("shop"); // same as resourceExport("ai-core").HideHud("shop")
SetNuiFocus(true, true);
SendNUIMessage({ action: "open" });
}
RegisterNuiCallback("close", (_data: unknown, cb: (r: unknown) => void) => {
SetNuiFocus(false, false);
hud.show("shop");
cb(true);
});Every HideHud needs its ShowHud with the same reason. ai-core cleans up after a resource that stops, but not after one that keeps running and forgets to call ShowHud: the HUD then stays hidden for that player.
ShowHud
Clears one hide reason of your resource. HUDs come back when no resource has a reason left.
Side: Client · Waits: no
ShowHud(reason: string): voidexports['ai-core']:ShowHud(reason) -- or aiLib.hud.show(reason)Parameters
Prop
Type
Returns
Nothing.
Example
See the example of HideHud.
IsHudVisible
Tells whether HUDs show right now, meaning no resource has a hide reason set. A HUD resource uses it at start; afterwards it follows the client event ai-core:client:hudVisible.
Side: Client · Waits: no
IsHudVisible(): booleanlocal visible = exports['ai-core']:IsHudVisible() -- or aiLib.hud.visible()Parameters
None.
Returns
boolean: true when no hide reason is set, false while at least one is.
Example
import { hud } from "@aicore-fivem/lib/client";
// A custom HUD: start in the right state, then follow every change.
function setVisible(visible: boolean): void {
SendNUIMessage({ action: "visible", data: visible });
}
setVisible(hud.visible);
hud.onChange(setVisible);OpenHudSettings
Opens the running HUD's own settings screen (ai-hud's or tgiann-lumihud's /hud, for example). The radial menu's HUD entry uses it; any script can.
Side: Client · Waits: no
OpenHudSettings(): booleanlocal opened = exports['ai-core']:OpenHudSettings() -- booleanParameters
None.
Returns
boolean: true when the running HUD has a settings screen and it was asked to open. false when no known HUD runs or the running one has no settings screen.
Example
import { notify, resourceExport } from "@aicore-fivem/lib/client";
import { Locale } from "common";
const core = resourceExport("ai-core");
RegisterCommand(
"hudsettings",
() => {
if (!core.OpenHudSettings()) notify(Locale("NO_HUD_SETTINGS"), "error");
},
false,
);HasHudSettings
Tells whether the running HUD has a settings screen, so you can show or hide a "HUD settings" button.
Side: Client · Waits: no
HasHudSettings(): booleanlocal has = exports['ai-core']:HasHudSettings() -- booleanParameters
None.
Returns
boolean: true when a known HUD runs and it has a settings screen, false otherwise.
Example
import { radial, resourceExport } from "@aicore-fivem/lib/client";
const core = resourceExport("ai-core");
// A radial item that shows only when the HUD has settings to open.
radial.add({
id: "myscript_hud",
label: "HUD",
icon: "sliders",
canShow: () => core.HasHudSettings(),
onPressed: () => void core.OpenHudSettings(),
});