EndCore Framework

en-respawn

The death screen, the enforced wait, and choosing a safe spawn point to wake up at with reset survival stats.

en-respawn handles dying and waking up again. When a player dies, the HUD hides and, after 1.5 seconds, a death screen opens over a slow camera pulling away from the body. It tells you how you died ("Another survivor put you down.", for example), how long you survived, and counts down the wait (20 seconds by default).

When the wait is over, the player picks a spawn point (if choosing is enabled) and holds E for 1.5 seconds to wake up at a safe location with 60% health and reset hunger, thirst, radiation, infection and temperature. Whatever they dropped stays where they fell. Logging out while dead and back in does not skip the wait, and an admin or medic revive closes the screen.

At a glance

Depends onen-core, en-ui
Optionalen-hud (hidden while dead), en-multicharacter (reopens the screen for players who logged in dead), en-admin (Build tab for spawn points)
Database tablesNone. Placed spawn points are stored by en-core's content registry
Config filesconfig/shared.lua
Key bindsNone (E is handled inside the death screen)

en-core itself has no respawn logic; it only marks the player dead. See World and death.

How it works

  1. en-core marks the player dead (metadata isdead). The server records the time of death. The client works out the cause and opens the death screen after 1.5 seconds, with the HUD hidden, controls disabled and a death camera.
  2. The screen counts down the remaining wait. The server rejects a wake request before Config.delay has passed, and guards against double presses.
  3. On wake, the server uses the chosen spawn (or a random one), applies Config.wakeStats, clears isdead and inlaststand, and fires en-respawn:server:respawned.
  4. The client fades out, streams the area, resurrects the player at the spawn, sets health to Config.health, and fades in with a "You wake up" message.

If isdead is set back to false by something else, such as an admin revive, the death screen closes.

Spawn points

Spawn points come from Config.spawns plus any placed in game with the en-admin Build tab (content kind 'spawn'). A placed spawn with the same id as a config entry replaces it; deleting the placement restores the config version. Keep spawn points inside safe zones so players don't wake up next to a horde.

Configuration

config/shared.lua:

KeyDefaultWhat it does
Config.delay20 sWait before waking (enforced server-side)
Config.key'E'Key to hold on the death screen
Config.holdTime1.5 sHow long to hold it
Config.choosetruePlayer picks a spawn; false = random
Config.health0.6Share of health on waking (minimum 0.05)
Config.wakeStats{ hunger = 60, thirst = 60, radiation = 0, infection = 0, temperature = 98.6 }Metadata set on wake; stats not listed are kept
Config.spawnsburton, sandy, paletoSpawn list, each { id, label, description, coords = vec4 }

Default spawns:

idLabelCoords
burtonBurton Checkpointvec4(-252.0, -303.0, 21.6, 160.0)
sandySandy Shores Campvec4(1853.8, 3689.4, 34.3, 210.0)
paletoPaleto Bay Outpostvec4(-448.0, 6008.0, 31.7, 315.0)

A harsher death with a longer wait, no choice and hungry survivors:

lua
-- config/shared.lua
Config.delay = 60
Config.choose = false
Config.health = 0.4
Config.wakeStats = { hunger = 30, thirst = 30, radiation = 0, infection = 0, temperature = 98.6 }

Config.spawns = {
    { id = 'burton', label = 'Burton Checkpoint', description = 'Guarded and fenced.', coords = vec4(-252.0, -303.0, 21.6, 160.0) },
    { id = 'zancudo', label = 'Zancudo Bunker', description = 'Concrete and quiet.', coords = vec4(-2350.0, 3250.0, 32.8, 90.0) },
}

Exports

Server exports on exports['en-respawn']:

ExportArgumentsReturns
GetRespawnWaitsourceSeconds remaining, or nil if alive
BuilderList, BuilderGet, BuilderValidate, BuilderSchema, BuilderTemplatekind, ...en-admin Build tab integration for kind 'spawn' (fields: label, description, coords with heading)

Events

EventSidePayload
en-respawn:server:respawnedServer localsrc, spawnId. Fired after the metadata reset, before the client teleports

en-respawn listens to encore:server:playerDied on the server, and on the client to encore:client:playerDied (killer, cause), encore:client:playerRevived, encore:client:onSetMetaData, encore:client:playerLoaded, encore:client:playerUnloaded and en-multicharacter:client:spawned.

Its UI uses two callbacks: en-respawn:state returns { dead, remaining, spawns? }, and en-respawn:wake (spawnId) returns { ok, label, coords } or { ok = false, error }.

Examples

Give a small kit to anyone who wakes up at the Paleto outpost:

lua
-- server
AddEventHandler('en-respawn:server:respawned', function(src, spawnId)
    if spawnId == 'paleto' then
        encore.inventory.addItem(src, 'water', 1)
        encore.inventory.addItem(src, 'bandage', 1)
    end
end)

Show a dead player how long they still have to wait:

lua
-- server
local wait = exports['en-respawn']:GetRespawnWait(source)
if wait then
    encore.notify(source, { title = 'Respawn', description = ('%d seconds left'):format(wait), type = 'inform' })
end