Koja Scripts

Events

Server and client events koja-mdt fires for other resources, and the events other resources may trigger.

Events

Events are the lightweight way to react to the MDT. They never block an action; use hooks when you need to cancel or change something.

Server events you can listen to

Hook bridge

Every hook's after stage is fired as koja-mdt:<hook> with (payload, src), for example koja-mdt:dispatch:create, koja-mdt:incident:process, koja-mdt:citation:pay or koja-mdt:jail:create. The payloads are listed on the hooks page.

server.lua
AddEventHandler('koja-mdt:dispatch:create', function(call)
    if call.priority == 1 then exports['my-discord']:Post('Priority call: ' .. call.title) end
end)

Dedicated events

EventArgumentsFires when
koja-mdt:server:dutyChangedsrc, onDuty, departmentId, officerAn officer goes on or off duty, from any source. officer is { source, identifier, name, callsign, department }.
koja-mdt:server:citationIssuedcitationA citation is issued.
koja-mdt:server:processedtarget, { incidentId, identifier, fine, months }An incident suspect is processed. target is the server id or nil.
koja-mdt:server:warrantActivewarrantA warrant becomes active (issued directly or approved).
koja-mdt:server:sentencedtarget, sentence, resultA court sentence was applied. sentence = { caseId, number, identifier, fine, months, applyFine, applyJail }, result = { fined, jailed }.
koja-mdt:server:jailPlayertarget, months, reason, officerSrcThe MDT wants to jail a player and no built-in jail adapter handled it. Your prison script should jail the player.
koja-mdt:server:releasePlayertarget, identifier, reason, systemAn early release from the MDT was not handled by a jail adapter. target can be nil when the inmate is offline.
koja-mdt:server:impoundVehicleplate, data, systemAn impound made in the MDT (tablet or ImpoundVehicle), after the impound adapters ran. system is the adapter that handled it, or mdt. data = { reason, fee, hours, lot, officer }.
koja-mdt:server:releaseImpoundplate, data, systemAn impound released from the MDT (tablet or ReleaseImpound). data = { feeStatus, note, officer }.
koja-mdt:server:custodykind, recordEvery custody change. kind: jail, released, escaped, transferred, impound, impoundRelease.
koja-mdt:server:medicalBillPaidtarget, billA medical bill was charged to a patient.
koja-mdt:server:admissionadmissionA patient was admitted.
koja-mdt:server:dischargeadmissionA patient was discharged.
server.lua
AddEventHandler('koja-mdt:server:dutyChanged', function(src, onDuty, department)
    if src then TriggerClientEvent('my-radio:setChannelAccess', src, department, onDuty) end
end)

AddEventHandler('koja-mdt:server:jailPlayer', function(target, months, reason, officerSrc)
    exports['my-prison']:Jail(target, months, reason)
end)

Server events you can trigger

Custody reports, the event form of ReportJail, ReportRelease, ReportImpound and ReportImpoundRelease. Trigger them with TriggerEvent from server code only; a client triggering them is flagged by the MDT security guard and ignored.

EventArguments
koja-mdt:custody:jailwho, months, data
koja-mdt:custody:releasewho, reason, data
koja-mdt:custody:impoundplate, data
koja-mdt:custody:impoundReleaseplate, data
server.lua
TriggerEvent('koja-mdt:custody:jail', source, 30, { reason = 'Bank robbery', facility = 'Bolingbroke' })

Client events you can listen to

EventArgumentsFires when
koja-mdt:client:openedThe tablet opened.
koja-mdt:client:closedThe tablet closed.
koja-mdt:client:dutyChangedonDuty, departmentIdThe local player went on or off duty.
koja-mdt:client:statusChangedstatus, previous, callIdThe local unit's status or call changed.
koja-mdt:client:newCallcallA new call reached this unit (same shape as GetCall).
koja-mdt:client:callUpdatedcallA call this unit can see changed (units, notes, status, edits).
koja-mdt:client:notification{ id, kind, title, body, actor, link, department, unread, createdAt }A notification center entry arrived.
koja-mdt:client:bodycamChangedstate, previous, dataThe local bodycam state changed (off, standby, recording).
client.lua
AddEventHandler('koja-mdt:client:newCall', function(call)
    if call.priority == 1 then PlaySoundFrontend(-1, 'TIMER_STOP', 'HUD_MINI_GAME_SOUNDSET', true) end
end)

AddEventHandler('koja-mdt:client:statusChanged', function(status, previous, callId)
    exports['my-hud']:SetUnitStatus(status)
end)

Client events a server resource can trigger

EventArgumentsEffect
koja-mdt:client:closeCloses the tablet.
koja-mdt:client:waypointcoordsSets the GPS waypoint ({ x, y }).
server.lua
TriggerClientEvent('koja-mdt:client:close', target)

To open the tablet for a player, call the client export OpenMdt() (it goes through the access checks) instead of triggering the internal open event.