Kartik Scripts

Exports & Events

exports['kartik-firefighterjob']:ExportName(...)

Server

Firefighters

exports['kartik-firefighterjob']:IsFirefighter(src)          -- has a fire job (Config.Jobs)
exports['kartik-firefighterjob']:IsOnDuty(src)
exports['kartik-firefighterjob']:GetStation(src)             -- station id they clocked in at
exports['kartik-firefighterjob']:GetOnDutyFirefighters()     -- list of server ids
exports['kartik-firefighterjob']:IsPlayerGeared(src)         -- in turnout gear
exports['kartik-firefighterjob']:GetTeam(src)                -- their team, or nil
exports['kartik-firefighterjob']:HasCertification(src, 'extrication')
exports['kartik-firefighterjob']:GetShiftSeconds(citizenid, days) -- seconds on duty in the last `days`
exports['kartik-firefighterjob']:GetStats(src)               -- xp, missions, fires, rescues, saves, deaths
exports['kartik-firefighterjob']:AddXp(src, amount)
exports['kartik-firefighterjob']:IsOnNpcMission(src)         -- working an NPC call right now

Alarms & dispatch

-- ring the closest crewed station (pages everyone on duty when no station is crewed)
exports['kartik-firefighterjob']:DispatchIncident({
    coords = vec3(0.0, 0.0, 0.0),
    callType = 'fire',          -- Config.CallTypes
    title = 'Structure Fire',
    street = 'Forum Drive',
})

exports['kartik-firefighterjob']:RingStation(stationId, data, force) -- ring one station (force = even if nobody is clocked in there)
exports['kartik-firefighterjob']:StopAlarm(stationId)
exports['kartik-firefighterjob']:GetClosestStation(coords)
exports['kartik-firefighterjob']:TriggerPullStation(coords, 'Building') -- start a pull station alarm call

Fires

-- fireType: structure, vehicle, wildfire, dumpster, fuel, electrical, industrial, rescue, backburn, smoke
local id = exports['kartik-firefighterjob']:CreateIncident('structure', coords, {
    label = 'Warehouse fire', street = 'Elysian Island', indoor = false, silent = false,
})
exports['kartik-firefighterjob']:RemoveIncident(id)
exports['kartik-firefighterjob']:GetIncidents()

NPC calls

-- typeId: a key of Config.MissionTypes
local id = exports['kartik-firefighterjob']:StartMission('house_fire', {
    label = 'Forum Drive', coords = vec3(-14.3, -1441.2, 31.1), heading = 0.0,
    target = nil, -- cat / jumper spot
    water = nil,  -- true for water calls
})
exports['kartik-firefighterjob']:EndMission(id, 'completed') -- 'completed' | 'failed' (half score) | 'aborted' (no pay)
exports['kartik-firefighterjob']:GetMissions()

Water & equipment

exports['kartik-firefighterjob']:GetWaterLevel(vehicle)          -- litres
exports['kartik-firefighterjob']:SetWaterLevel(vehicle, litres)
exports['kartik-firefighterjob']:GetFoamLevel(vehicle)
exports['kartik-firefighterjob']:GetPlacedEquipment()            -- cones, ladders, fans, pumps...
exports['kartik-firefighterjob']:GetReadiness()                  -- stations with their apparatus and equipment

Documents

exports['kartik-firefighterjob']:GetSharedDocuments('police')  -- documents shared with that job: { id, title, folder, author_name, updated_at }

Client

exports['kartik-firefighterjob']:IsPlayerGeared()
exports['kartik-firefighterjob']:OpenGearMenu()
exports['kartik-firefighterjob']:GearDown()
exports['kartik-firefighterjob']:GetAirLevel()            -- SCBA air left
exports['kartik-firefighterjob']:GetTruckWater(vehicle)
exports['kartik-firefighterjob']:openTablet()
exports['kartik-firefighterjob']:OpenTabletPage('calls')  -- see The Fire Tablet for the page names
exports['kartik-firefighterjob']:useItem(itemName)        -- used by the ox_inventory items
exports['kartik-firefighterjob']:useTablet()              -- used by the fire_tablet item
exports['kartik-firefighterjob']:OpenSharedDocuments()    -- the /firedocs viewer (firefighters get the Documents page)

TriggerEvent('kartik-firefighterjob:client:openTabletPage', page) does the same as OpenTabletPage.

Server events

Listen with AddEventHandler:

EventArguments
kartik-firefighterjob:dutyChangedsrc, onDuty, stationId
kartik-firefighterjob:fleetSpawnedvehicle, src, stationId
kartik-firefighterjob:alarmstationId, alarm
kartik-firefighterjob:incidentCreatedid, fireType, origin
kartik-firefighterjob:incidentCompletedid, fireType, contributors
kartik-firefighterjob:incidentRemovedid, completed
kartik-firefighterjob:incidentHotspotsid (hot spots left behind)
kartik-firefighterjob:incidentRekindledid
kartik-firefighterjob:incidentOverhauledid
kartik-firefighterjob:vehicleCaughtincidentId, newIncidentId, coords (fire spread to a parked car)
kartik-firefighterjob:patientFreedincidentId, src
kartik-firefighterjob:rescueStepincidentId, step, src (battery, roof, ...)
kartik-firefighterjob:rescueSparkincidentId (cutting a live car sparked a fire)
kartik-firefighterjob:missionStartedid, type, coords
kartik-firefighterjob:missionEndedid, result, score, participants
kartik-firefighterjob:missionEscalatedid, level, auto
kartik-firefighterjob:maydaysrc, coords, auto
kartik-firefighterjob:incidentRequestmissionId, kind, src, mdtCallId
kartik-firefighterjob:patientHandovermedicSrc, sheet
kartik-firefighterjob:arsonEvidencemissionId, investigation, origin
kartik-firefighterjob:worldArsonincidentId, src, method, coords (a player set a fire: lighter or molotov)
kartik-firefighterjob:inspectionFiledsrc, siteId, result, findings
kartik-firefighterjob:databaseReadynone

Client events

EventArguments
kartik-firefighterjob:client:gearChangedgeared
kartik-firefighterjob:client:alarmStartedalarm

For London Studios compatibility, firejob:cl:dutyChanged and firejob:client:GearStateChanged are fired too.

Example

-- pay a bonus for every fire put out
AddEventHandler('kartik-firefighterjob:incidentCompleted', function(id, fireType, contributors)
    for src in pairs(contributors) do
        print(('%s helped put out incident %s (%s)'):format(GetPlayerName(src), id, fireType))
    end
end)

On this page