Skip to main content
Hooks run on the server, before an action happens. A hook can let the action through, block it, or change its data. Events are different: they fire after an action and only tell you that it happened.

Registering a hook

RegisterHook returns a hook id. Pass it to RemoveHook to unregister:
Hooks are removed automatically when the resource that registered them stops.

Return values

Only the fields listed under Changeable are read back from a returned table. Any other field you change is ignored, and the MDT validates the new values again, the same way it validates player input.
  • payload.source is the player who triggered the action. It’s nil when the action is automated (exports, timers, scripts).
  • If a hook errors, the error is logged and the hook is skipped. The action still goes through.
  • The first hook to return false stops the chain. Hooks after it don’t run.

Examples

Block an action

Stop society withdrawals over a limit:

Change the payload

Return the payload with the changed fields. Every hook after this one receives the changed payload.

Adjust charges

onChargesIssue runs before any fine, jail time or record is written, for every flow that issues charges (penalties, incidents and warrants). Returned charges must still target the same citizens and stay within the Config.Charges caps, otherwise the action is rejected.

Enrich dispatch calls

payload.payload holds the call being created (type, code, priority, title, description, location, details).

Require something before clock in

Any check your server already has can gate an MDT action. my_garage below stands in for your own resource.

Hook list

Most payloads also include source. It isn’t repeated in the tables below.

Incidents

entityType is penalty, incident or warrant. entityId is nil while the record is still being created.

Warrants

BOLOs

Evidence

Citizens

Vehicles & weapons

modification is { id, name, category }.

Dispatch

Field

Blocking onRadarPlateHit hides the hit from the officer and skips the dispatch call it would create.

Chat

image is { url, width?, height? }, location is { label?, x, y } and record is { kind, id, label }.

Notifications

Collaboration

Employees

Shifts

Certifications & achievements

Department

For onRecordAccessChange, entityType is incident, warrant, bolo or evidence.

Penal code & settings