players module owns death state, injuries and the downed flow. The server decides every transition. Resources such as ug-ambulance build scenes on top, through the API and hooks.
States
Instant death skips
Downed: fatal gunshots to the head (instantDeath.headshot) and listed categories such as Explosion.
How death is detected
1
The client reports
The client checks its own ped every 250 ms. When it becomes fatally injured, it reports with the last damaged bone. A report the server does not confirm is sent again every 3 seconds.
2
The server confirms
The server reads the ped’s health itself. Only health below 100 confirms the report. Health reaches the server a moment after the client sees the death, so the server keeps checking for one second. The weapon comes from
GetPedCauseOfDeath and the killer from GetPedSourceOfDeath, both read on the server.3
The killer is verified
A killer only counts when a
weaponDamageEvent from that player hit the victim in the last 3 seconds. Otherwise the killer is unknown.4
The state changes
The server records the injury, picks
Downed or Dead from your config, and updates the ug-core:DeathState statebag.InvalidDeathState. The resting place is taken 12 seconds after the fall, so a body rolling down a hill is not flagged.
Injuries
Every hit is recorded. Hits on the same body region with the same category merge into one injury:{ region, category, weapon, killer?, at }.
The downed flow
- The body ragdolls until it rests on the ground, for at most 10 seconds. Then the player is revived in place with low health and plays the downed animation. Killed again while down, the body ragdolls and takes the pose again.
- Shooting, aiming, melee, sprinting, jumping, entering vehicles and switching weapons are disabled. Dead players cannot move either.
- Bleedout runs on the server. When it expires, the player dies, unless
Players:BeforeBleedoutpostpones it. - Dead players stay in place, in the dead animation, until
ReviveorRespawn. - spawnmanager’s auto-respawn is turned off, and kept off when another resource turns it on. UgCore owns respawning.
Building an ambulance resource
server.lua
UgCore.Players.GetInjuries and GetCauseOfDeath for diagnosis scenes, and ClearInjuries(source, region) to treat one region at a time.
Persistence
With thecharacters module and persistDeathState, death state, injuries and cause of death are saved with the character. Disconnecting never revives a player: they come back downed or dead.
Configuration
Seeconfig/players.lua in Config files. PVP and racing servers usually set downed.enabled = false and respawn.auto = true.