AI Core

MDT

Write fines, warrants, arrests and jail records into whichever police MDT the server runs.

Records go through ai-core, never through an MDT's own exports or events. ai-core forwards each record to the active MDT: the one the panel's MDT script setting picks, or the first one running. There is no ai-* MDT, so while no MDT runs, records are not written anywhere. Opening the MDT screen happens on the client (client export OpenMdt, lib mdt.open).

GetMdtSystem

The resource name of the MDT ai-core forwards to.

Side: Server · Waits: no · Lib: mdt.provider()

Signature
GetMdtSystem(): string | null
Lua
local system = exports['ai-core']:GetMdtSystem() -- string or nil

Parameters

None.

Returns

string | null: the MDT's resource name. null when none runs.

Example

import { addCommand, resourceExport } from "@aicore-fivem/lib/server";

const core = resourceExport("ai-core");

addCommand("mdtsystem", { help: "Shows the MDT in use", restricted: true }, () => {
  console.log(core.GetMdtSystem() ?? "none: records are not written");
});

AddMdtRecord

Writes a record about a player into the MDT: a fine, a warrant, an arrest or a jail sentence. ai-core fills in the citizen ids and names of the target and the officer.

Side: Server · Waits: no · Lib: mdt.record

Signature
AddMdtRecord(record: MdtRecord): boolean
Lua
local written = exports['ai-core']:AddMdtRecord({ kind = 'fine', target = target, by = source, title = 'Speeding', amount = 250 })

Parameters

Prop

Type

MdtRecord

Prop

Type

See MdtRecord and MdtRecordKind.

Returns

boolean: true when the MDT wrote it. false when the record is invalid (wrong kind, no title, target not a positive whole number), the target has no loaded character, no MDT runs, the MDT takes no records from scripts or has no such kind.

Example

import { onClientCallback, resourceExport } from "@aicore-fivem/lib/server";
import { fail, readId } from "@aicore-fivem/lib/shared";
import { Locale } from "common";

const core = resourceExport("ai-core");

// An officer jails a player for 20 minutes; the MDT keeps the record.
onClientCallback(
  "myscript:jail",
  { args: ([target]) => { const id = readId(target); return id === null ? null : [id]; }, lock: true },
  (source, target) => {
    if (core.GetDutyJob(source) !== "police") return fail("NOT_POLICE");
    if (!core.JailPlayer(target, 20, source)) return fail("JAIL_FAILED");
    core.AddMdtRecord({ kind: "jail", target, by: source, title: Locale("RECORD_ROBBERY"), minutes: 20 });
    return { ok: true };
  },
);

On this page