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 once, with the last damaged bone.
2
The server confirms
The server reads the ped’s health itself. Only health below 100 confirms the report. 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.
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 player is revived in place with low health and plays the downed animation.
- 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. 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.