Dispatch
Send police (or any job) alerts through whichever alert system the server runs.
Police alerts go through ai-core, never through an alert script's own exports or events (ai-policealert included). ai-core forwards each alert to the active alert system: the one the panel's Alert script setting picks, or the first one running (ai-policealert's built-in cards come last). The alert system shows it to the on-duty members of the alert's jobs.
ai-core also answers QB's police:server:policeAlert event for alert systems that do not, so QB scripts' alerts arrive too.
SendDispatchAlert
Sends one alert. Use it for anything officers (or another job) should respond to: shots fired, a store robbery, a stolen car.
Side: Server · Waits: no · Lib: dispatch.alert
SendDispatchAlert(alert: DispatchAlert): booleanlocal sent = exports['ai-core']:SendDispatchAlert({ title = 'Store robbery', code = '10-90', source = source })Parameters
Prop
Type
DispatchAlert
Prop
Type
Unknown fields are dropped. See DispatchAlert.
Returns
boolean: true when the alert system took the alert. false when title is missing or empty, no alert system runs, or it failed.
Example
import { onClientCallback, resourceExport, near } from "@aicore-fivem/lib/server";
import { fail } from "@aicore-fivem/lib/shared";
import { Locale } from "common";
const core = resourceExport("ai-core");
const REGISTER = { x: 24.5, y: -1345.6, z: 29.5 };
onClientCallback("myscript:robRegister", { guards: [near(REGISTER, 2)], lock: true }, (source) => {
if (core.GetOnDutyCount("police") < 2) return fail("NOT_ENOUGH_POLICE");
core.SendDispatchAlert({
code: "10-90",
title: Locale("ALERT_STORE_ROBBERY"),
message: Locale("ALERT_STORE_NAME"),
coords: REGISTER,
source,
jobs: ["police"],
icon: "cash-register",
priority: "high",
});
return { ok: true };
});Texts are shown as given: translate them with Locale before sending. Do not send an alert on every frame or every hit: an alert for shots fired should have a cooldown per player.