Events & State Bags
🖥️ Server events
AddEventHandler('kartik-ambulancejob:server:stateChanged', function(key, state, previous)
-- 'alive' | 'laststand' | 'dead'
end)| Event | Arguments |
|---|---|
kartik-ambulancejob:server:stateChanged | key, state, previous |
kartik-ambulancejob:medicalReportCreated | report |
kartik-ambulancejob:server:encounterFinished | key, report |
kartik-ambulancejob:server:revived | key, bySource |
kartik-ambulancejob:server:diseaseGiven | key, diseaseId |
kartik-ambulancejob:server:overdose | source, 'start' | 'ended' | 'collapsed' |
kartik-ambulancejob:server:addictionChanged | source, type, level |
kartik-ambulancejob:server:panic | source, { 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
| Event | Arguments |
|---|---|
kartik-ambulancejob:client:stateChanged | state, 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 = deadThe 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, permissionsSet 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 for | Use | Notes |
|---|---|---|
| A server export / server code | exports['kartik-ambulancejob']:RevivePlayer(targetId, true) | Always works, full revive |
| A server event the admin fires | hospital:server:RevivePlayer with the target id | Admins can revive anyone, at any distance |
| A client event sent to the target | hospital:client:Revive | Only 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:playerRevived | Revive |
hospital:client:Revive | Revive |
esx_ambulancejob:revive | Revive |
qbx_medical:client:heal | Heal, 'full' or partial |
hospital:client:HealInjuries | Heal, 'full' or partial |
esx_ambulancejob:heal | Heal, 'big' or small |
hospital:server:RevivePlayer | Revive a target, admins, or a medic within 5 m |
hospital:server:SetDeathStatus / SetLaststandStatus | Put the player down |
esx_ambulancejob:setDeathStatus | Put the player down |
hospital:server:resetHungerThirst | Restore 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:
| Event | Side | When |
|---|---|---|
qbx_medical:client:onPlayerDied | Client | The player dies |
qbx_medical:client:onPlayerLaststand | Client | The player goes into last stand |
qbx_medical:client:playerRevived | Client | The player is back up |
qbx_medical:server:playerRespawned | Server | The player respawned at a hospital (source as the argument) |
Legacy exports
Provided whenever the original resource is not started:
| Resource | Client | Server |
|---|---|---|
qbx_medical | IsDead, IsLaststand, GetDeathTime, GetLaststandTime, GetRespawnHoldTimeDeprecated, DisableRespawn, AllowRespawn, RemoveBleed, KillPlayer, StartLastStand | Revive, Heal, HealPartially, GetPlayerStatus |
qb-ambulancejob | IsDead, InLaststand, GetDeathStatus | IsDead, InLaststand, Revive |
esx_ambulancejob | isDead, getDeathStatus | isDead, revive |
wasabi_ambulance | isPlayerDead | RevivePlayer |
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.