AI Core

ai-policealert for developers

How to send a police alert that reaches ai-policealert (or any other alert script), the DispatchAlert fields, and ai-policealert's own export.

To send a police alert from your script, call the lib's dispatch.alert(alert) (TypeScript) or aiLib.dispatch.alert(alert) (Lua). It goes through AI Core's dispatch layer and reaches whichever alert system the server uses: ai-policealert, or a supported third-party alert script. Never call ai-policealert's export directly.

dispatch.alert

Sends one police (or other job) alert through AI Core. On-duty members of jobs get it; without jobs the alert system's own police jobs do (for ai-policealert: the panel's Alert jobs).

Side: Server · Waits: no

Signature
dispatch.alert(alert: DispatchAlert): boolean
Lua
local sent = aiLib.dispatch.alert(alert) -- boolean

Parameters

Prop

Type

DispatchAlert

Prop

Type

Returns

true when an alert system took the alert. false when no alert system runs or the alert is invalid (no title).

Example

import { dispatch, onClientCallback } from "@aicore-fivem/lib/server";
import { Locale } from "./locale"; // your resource's translated texts

// A client says it started breaking into an ATM; the server alerts the police at the player's position.
onClientCallback("myscript:breakAtm", (source) => {
  const sent = dispatch.alert({
    code: "10-90",
    title: Locale("ALERT_ATM_TITLE"),
    message: Locale("ALERT_ATM_MESSAGE"),
    source, // coords come from this player
    icon: "money-bill",
    priority: "high",
  });
  if (!sent) console.log("no alert system is running");
  return { ok: true };
});

Texts are shown as you send them: translate them before the call. Fields not listed above are dropped. Do not send an alert for every repeated action: ai-police, for example, keeps one shot alert per 150 m every 30 s.

Server export

DispatchAlert

ai-policealert's own entry point. Only AI Core's dispatch layer calls it while ai-policealert is the active alert system; scripts use dispatch.alert above. Typed as AiPoliceAlertServerExports in @aicore-fivem/shared.

Side: Server · Waits: no

Signature
DispatchAlert(alert: DispatchAlert): void
Lua
exports['ai-policealert']:DispatchAlert(alert)

Parameters

Prop

Type

Returns

Nothing. Calling it directly skips AI Core's choice of alert system, and coords is not filled from source (AI Core does that before it calls the export).

Private events

The script's own server-client contract (resource/common/alerts.ts). They may change between versions: do not trigger or listen to them from other resources.

NameDirectionWhat it carries
ai-policealert:client:alertsserver -> officerThe live alerts of the officer's duty job (a full list; an empty list clears the cards).
ai-policealert:client:alertserver -> officerOne new alert.

On this page