Skip to content

MDT

Exports and events

Server-side hooks for adding to incidents and writing narratives. The MDT itself listens to c3r's events and voice dispatch's lwk_control:ran.

Server exports

AddDialogue

Adds a line of conversation to the officer's open incident. c3r's scripted conversations already go here through c3r:dialogue.

exports.lwk_mdt:AddDialogue(src, who, text)
ParameterTypeWhat it is
srcnumberThe officer's server id
whostringWho said it, up to 20 characters, e.g. 'Officer'
textstringThe line, up to 300 characters

Nothing happens if the officer has no open incident. An incident keeps its last 100 lines.

GetPersonHistory

A person's earlier contacts, newest first, at most 5. Lets an AI subject say "not you again".

local history = exports.lwk_mdt:GetPersonHistory(src, person)
ParameterTypeWhat it is
srcnumberThe officer's server id
persontableA c3r person record

Returns a list of earlier incidents (the current one isn't counted), each marked with whether it was this officer's report. Empty if they're not on file.

GetReportDraft

The automatic narrative for a freshly drafted report, so another resource can rewrite it in prose.

local narrative, hasDialogue, timelineLength = exports.lwk_mdt:GetReportDraft(id)

Returns nil unless the report is still an untouched draft.

SetNarrative

Replaces a draft's narrative. It's then frozen, like an officer's own edit.

local ok = exports.lwk_mdt:SetNarrative(id, text) -- text up to 6000 characters

Returns false if the report isn't an untouched draft: an officer's edit or signature always wins.

Server events

lwk_mdt:reportDrafted

Fires when an incident closes and its draft is ready.

AddEventHandler('lwk_mdt:reportDrafted', function(id, src)
    local draft = exports.lwk_mdt:GetReportDraft(id)
    if draft then
        exports.lwk_mdt:SetNarrative(id, 'On the above date and time I conducted a traffic stop...')
    end
end)

Events the MDT listens to

EventFromBecomes
c3r:stopStarted, c3r:pursuitStarted, c3r:calloutAcceptedc3rA new incident
c3r:contact, c3r:vehicleContactc3rPeople and vehicles on the incident
c3r:dialoguec3rThe conversation
c3r:notec3rA timeline line (test results, searches)
c3r:stopEnded, c3r:pursuitEnded, c3r:calloutEndedc3rThe incident closes and drafts
lwk_control:ranvoice dispatchRadio actions on the timeline

To put your own line on an officer's timeline, fire c3r:note on the server:

TriggerEvent('c3r:note', src, 'K9 unit alerted on the driver side door')