Skip to content

SetPlayerInjuries

Sets the player’s injured body parts, in place of the ones they have.

The parts in the list are injured and every other part is whole; {} heals them all and leaves the health and the bleeding alone. The player’s game and everyone who sees them show it (the limp, the injury in the HUD). OnPlayerInjury is not called - this is the mode’s own word. With GetPlayerInjuries it keeps a character’s injuries across sessions: save the list when they leave, set it back once they have spawned.

SetPlayerInjuries(pid, parts)
Parameter Type
pid number the player
parts table a list of body part ids, 1 .. 6

boolean - false when the player is dead or not in the world

-- a character's injuries kept across sessions (saveWounds / loadWounds are the mode's own storage)
local restored = {}
function OnPlayerDisconnect(pid, reason)
saveWounds(pid, GetPlayerInjuries(pid), GetPlayerBleeding(pid), GetPlayerBleedingTime(pid))
restored[pid] = nil
end
function OnPlayerSpawn(pid)
if restored[pid] then return end -- the first spawn of the session only: a respawn starts whole
restored[pid] = true
local w = loadWounds(pid)
if w then
SetPlayerInjuries(pid, w.parts)
if w.bleeding > 0 then SetPlayerBleeding(pid, w.bleeding, w.seconds) end
end
end

SetPlayerInjured · GetPlayerInjuries · GetPlayerBleedingTime · SetPlayerBleeding · HealPlayer · the Vitals group of the index