Kartik Scripts

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
    -- ...
end

Count 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
end

Server events

Register with AddEventHandler in a server script.

EventArguments
kartik-ers:shiftChangedsource, onShift, serviceId
kartik-ers:calloutStartedsource, callout
kartik-ers:calloutFinishedsource, callout, result (completed / failed / abandoned)
kartik-ers:arrestsource, { citizenId, name, warrant }
kartik-ers:citationsource, { citizenId, name, charges, total, note }
kartik-ers:calloutOfferedsource, { offerId, calloutId, label, code, priority, description, fromDispatcher }
kartik-ers:calloutArrivedsource, callout
kartik-ers:unitStatussource, key, status (key: onAccept / onArrive / onCalloutEnd / ...)
kartik-ers:dispatchVoicesource, { 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 the kartik-mdt:dndChanged event.
  • Client (ERS app, MDT V2 2.4.0+): RegisterTabletApp, SendTabletAppMessage, CloseMDT, openMDTPage, and the kartik-mdt:tablet:ready event.

On this page