Exports & Events
Server exports
exports['kartik-ers']:IsOnShift(source) -- boolean
exports['kartik-ers']:GetUnitService(source) -- 'police' | 'ambulance' | 'fire' | 'tow' | nil
exports['kartik-ers']:GetActiveCallout(source) -- callout table | nil
exports['kartik-ers']:GetOnShiftUnits() -- { { source, service, busy }, ... }
exports['kartik-ers']:StartShift(source, serviceId) -- boolean
exports['kartik-ers']:EndShift(source) -- boolean
exports['kartik-ers']:OfferCallout(source, calloutId?) -- boolean, reason
exports['kartik-ers']:GetPedRecord(netId) -- NPC identity of a networked ped (if generated)
exports['kartik-ers']:GeneratePerson(isMale?) -- a random identity (not saved)
exports['kartik-ers']:SpeakDispatch(source, text) -- speak a dispatch line to a unit (see Voice Dispatch)GetActiveCallout returns { uid, calloutId, label, code, street, coords, arrived, ... }. On a joint scene it also has jointId, and assist (the service) when the player is assisting.
OfferCallout without a calloutId picks a random callout for the player's service.
Examples
Only pay a bonus to players on an ERS shift:
if exports['kartik-ers']:IsOnShift(source) then
-- ...
endCount free EMS units:
local free = 0
for _, unit in ipairs(exports['kartik-ers']:GetOnShiftUnits()) do
if unit.service == 'ambulance' and not unit.busy then free = free + 1 end
endServer events
Register with AddEventHandler in a server script.
| Event | Arguments |
|---|---|
kartik-ers:shiftChanged | source, onShift, serviceId |
kartik-ers:calloutStarted | source, callout |
kartik-ers:calloutFinished | source, callout, result (completed / failed / abandoned) |
kartik-ers:arrest | source, { citizenId, name, warrant } |
kartik-ers:citation | source, { citizenId, name, charges, total, note } |
kartik-ers:calloutOffered | source, { offerId, calloutId, label, code, priority, description, fromDispatcher } |
kartik-ers:calloutArrived | source, callout |
kartik-ers:unitStatus | source, key, status (key: onAccept / onArrive / onCalloutEnd / ...) |
kartik-ers:dispatchVoice | source, { kind, text, unit, callout }: a ready-to-speak dispatch line (Voice Dispatch) |
AddEventHandler('kartik-ers:calloutFinished', function(src, callout, result)
if result == 'completed' then
print(('%s completed %s'):format(GetPlayerName(src), callout.label))
end
end)Kartik MDT
Open the ERS app
exports['kartik-mdt']:openMDTPage('/tablet-app?id=kartik-ers')Exports kartik-ers uses
- Server:
CreateFakeProfile,IsFakeProfile,CreateFakeVehicle,CreateWarrant,HasActiveWarrant,LookupPlate,SetUnitStatus,SetDuty,CreateCall,AttachUnitToCall,DetachUnitFromCall,UpdateCall,ClearCall,ReplyToIncident, and thekartik-mdt:dndChangedevent. - Client (ERS app, MDT V2 2.4.0+):
RegisterTabletApp,SendTabletAppMessage,CloseMDT,openMDTPage, and thekartik-mdt:tablet:readyevent.