Kartik Scripts

Events & State Bags

🖥️ Server events

AddEventHandler('kartik-ambulancejob:server:stateChanged', function(key, state, previous)
    -- 'alive' | 'laststand' | 'dead'
end)
EventArguments
kartik-ambulancejob:server:stateChangedkey, state, previous
kartik-ambulancejob:medicalReportCreatedreport
kartik-ambulancejob:server:encounterFinishedkey, report
kartik-ambulancejob:server:revivedkey, bySource
kartik-ambulancejob:server:diseaseGivenkey, diseaseId
kartik-ambulancejob:server:overdosesource, 'start' | 'ended' | 'collapsed'
kartik-ambulancejob:server:addictionChangedsource, type, level
kartik-ambulancejob:server:panicsource, { kind, code, job, coords } (see Emergency Buttons)

Listening for reports

AddEventHandler('kartik-ambulancejob:medicalReportCreated', function(report)
    -- push it into your own CAD, insurance system or Discord bot
    print(report.summary)
end)

💻 Client events

EventArguments
kartik-ambulancejob:client:stateChangedstate, previous
kartik-ambulancejob:client:overdose'start' | 'ended' | 'collapsed'
AddEventHandler('kartik-ambulancejob:client:stateChanged', function(state, previous)
    if state == 'dead' then
        -- hide your HUD, stop your job, whatever you need
    end
end)

🎒 State bags

Readable from anywhere, no export call needed.

Per player

Player(serverId).state['kaj:state']     -- 'alive' | 'laststand' | 'dead'
Player(serverId).state['kaj:overdose']
Player(serverId).state['kaj:stretcher'] -- net id of the stretcher they are on
Player(serverId).state['kaj:bodybag']

Per player, qbx_medical compatible

Set by this resource so scripts written for qbx_medical keep reading the right values:

Player(serverId).state.isDead                    -- true while down OR dead (pma-voice, phones, appearance menus read this)
Player(serverId).state.dead                      -- same as isDead, for older QBX scripts
Player(serverId).state['qbx_medical:deathState'] -- 1 = alive, 2 = last stand, 3 = dead

The framework metadata isdead and inlaststand are kept in sync too.

On ESX the metadata key is isDead: it is 1 while the player is down or dead and is removed when they are alive again, so a plain if PlayerData.metadata.isDead then check (used by inventories such as CodeM) only blocks players who are really down.

Global

GlobalState['kaj:medics']        -- available medics (not down themselves)
GlobalState['kaj:medicsOnDuty']  -- everyone clocked in
GlobalState['kaj:staff']         -- enabled jobs, manager ranks, easy mode, permissions

Set by you

LocalPlayer.state.kajIgnoreDamage = true  -- arena mode: damage creates no injuries

📥 Incoming events you can fire

TriggerEvent('kartik-ambulancejob:server:drink', source, 0.02)   -- add blood alcohol

🛡️ Admin menus

There is no separate kartik-ambulancejob revive event, admin menus (919Admin, vMenu, EasyAdmin and similar) use one of the hooks below. Pick the first one your menu's config supports:

Your menu asks forUseNotes
A server export / server codeexports['kartik-ambulancejob']:RevivePlayer(targetId, true)Always works, full revive
A server event the admin fireshospital:server:RevivePlayer with the target idAdmins can revive anyone, at any distance
A client event sent to the targethospital:client:ReviveOnly works with an admin or medic within 10 m, see below
-- server export (recommended)
exports['kartik-ambulancejob']:RevivePlayer(targetId, true)

-- server event, fired from the admin's client
TriggerServerEvent('hospital:server:RevivePlayer', targetId)

-- client event, sent to the target
TriggerClientEvent('hospital:client:Revive', targetId)

Most admin menus revive remotely, so with the default Config.Compat.trustClientReviveEvents = false the client event hospital:client:Revive is blocked and logged as Blocked legacy revive event. Use one of the first two options, or set trustClientReviveEvents = true if the menu only supports a client event, see the security note.

txAdmin's Heal / Heal all needs no setup, see Config.Compat.txAdminHeal.


🔄 Legacy events

Answered

Still answered by the compatibility layer, so old scripts keep working:

Event
qbx_medical:client:playerRevivedRevive
hospital:client:ReviveRevive
esx_ambulancejob:reviveRevive
qbx_medical:client:healHeal, 'full' or partial
hospital:client:HealInjuriesHeal, 'full' or partial
esx_ambulancejob:healHeal, 'big' or small
hospital:server:RevivePlayerRevive a target, admins, or a medic within 5 m
hospital:server:SetDeathStatus / SetLaststandStatusPut the player down
esx_ambulancejob:setDeathStatusPut the player down
hospital:server:resetHungerThirstRestore hunger & thirst

The client revive and heal events can be faked by cheaters, so they only work with an admin or on-duty medic within 10 m, see the security note. From your own server code, prefer the server exports (exports.qbx_medical:Revive(src), :Heal(src)), which always work.

Fired

So scripts that listen to qbx_medical react to this resource:

EventSideWhen
qbx_medical:client:onPlayerDiedClientThe player dies
qbx_medical:client:onPlayerLaststandClientThe player goes into last stand
qbx_medical:client:playerRevivedClientThe player is back up
qbx_medical:server:playerRespawnedServerThe player respawned at a hospital (source as the argument)

Legacy exports

Provided whenever the original resource is not started:

ResourceClientServer
qbx_medicalIsDead, IsLaststand, GetDeathTime, GetLaststandTime, GetRespawnHoldTimeDeprecated, DisableRespawn, AllowRespawn, RemoveBleed, KillPlayer, StartLastStandRevive, Heal, HealPartially, GetPlayerStatus
qb-ambulancejobIsDead, InLaststand, GetDeathStatusIsDead, InLaststand, Revive
esx_ambulancejobisDead, getDeathStatusisDead, revive
wasabi_ambulanceisPlayerDeadRevivePlayer

qbx_medical's purely visual client exports (EnableDamageEffects, DisableDamageEffects, IncrementDeathTime, IncrementLaststandTime, PlayDeadAnimation, MakePedLimp, SendBleedAlert, MakePlayerBlackout, MakePlayerFadeOut, EnableBleeding, DisableBleeding) are accepted and do nothing, this resource runs its own effects, so scripts calling them never error.

Controlled by Config.Compat.

On this page