Skip to main content

Developers

How respawning works​

  1. The player dies. The server records the time of death (the client can't change it).
  2. The respawn timer is respawn.time if at least respawn.minEms EMS are on duty, otherwise respawn.timeNoEms.
  3. When the timer ends, the player holds E (or clicks). Or they pay for Face Death once faceDeath.time has passed.
  4. The server checks the timer again, takes the Face Death fee and the hospital bill (cash first, then bank) and wipes the inventory if configured.
  5. The player is moved to the nearest respawn.locations spot and revived. On Qbox with respawn.mode = 'bed', qbx_ambulancejob puts them in a hospital bed instead.

On Qbox, gs-deathscreen also registers a qbx_medical respawn hook, so respawns from anywhere else are blocked until the timer has passed.

Custom dispatch​

To send EMS calls through your own dispatch script, set ems.dispatch = 'custom' and write the function in config.lua. It runs on the client when the player presses Call EMS.

config.lua
ems = {
dispatch = 'custom',
---@param phase 'downed'|'dead'
custom = function(phase)
local coords = GetEntityCoords(cache.ped)
exports['my-dispatch']:SendAlert({
title = phase == 'dead' and 'Civilian unresponsive' or 'Civilian down',
coords = coords,
job = 'ambulance',
})
end,
},
note

exports['my-dispatch']:SendAlert is an example. Use the export your dispatch script provides.

Callbacks and events​

These are used internally by gs-deathscreen. You normally don't need to call them yourself.

NameSideTypeDescription
gs-deathscreen:server:getInfoServerox_lib callbackReturns ems, remaining, total, cost, hospital, wipe and faceDeath for the calling player.
gs-deathscreen:server:respawnServerox_lib callbackRespawns the calling player. Pass true to pay for Face Death. Returns true on success.
gs-deathscreen:client:respawnAtClientNet eventSent by the server to move the player to the respawn point.
gs-deathscreen:server:finishRespawnServerNet eventSent by the client once it has arrived, to finish the revive.
gs-deathscreen:server:bledOutServerNet eventak47_ambulancejob only: marks a downed player as dead when the bleed-out timer ends.

Checking if the screen is running​

Other scripts can check whether gs-deathscreen is active with:

if GetResourceState('gs-deathscreen') == 'started' then
-- gs-deathscreen handles the death screen
end

This is the same check the ambulance script changes use.

Adding another ambulance script​

Everything gs-deathscreen needs from an ambulance script is in bridge/client.lua and bridge/server.lua: reading the death state, reviving, the bleed-out timer and the distress call. The framework side (money, jobs, metadata, notifications) is in bridge/framework_client.lua and bridge/framework_server.lua.