Skip to content

SetPlayerKnockedOut

Knocks a player out, or wakes them - the game’s own knock-out, health as it is.

A knocked-out player drops, their screen goes dark, everyone who has their body sees them lie, and their health stays as it is (bleeding goes on - a bleed-out is a death). They cannot fight, ride, act, make an emote or start a dice match; a grab carries them (SetCarrying). seconds above 0 wakes them by itself after that long (24 hours at the most); 0 or nil keeps them down until the mode wakes them (on false), they die, leave or respawn. Knocking out one who is out already sets the timer anew. A player who carries someone puts them down. OnPlayerKnockedOut and OnPlayerWake tell it.

false and the reason (“They are riding.”, “They are in a cart.” …) when the player is not in the world, dead, on a horse (the mode can ThrowPlayerFromHorse first), in a cart, flying, in a dice match, or in a fall or a pull-down. A game from an older or unsupported build is knocked out all the same - the server holds the player down whatever his game shows - but takes no part in a carry. Waking a player who is not knocked out answers true.

SetPlayerKnockedOut(pid [, on, seconds])
Parameter Type
pid number the player
on boolean true (the default) knocks them out, false wakes them (optional)
seconds number how long they stay down, at most 86400 (24 hours); nil or 0 until woken (optional)

boolean, string - true when done; false and the reason when it could not be

-- a blow that would kill knocks out instead, for a minute
function OnPlayerDamage(pid, attacker, damage)
if damage >= GetPlayerHealth(pid) and not IsPlayerKnockedOut(pid) then
if SetPlayerKnockedOut(pid, true, 60) then return GetPlayerHealth(pid) - 1 end
end
end

IsPlayerKnockedOut · OnPlayerKnockedOut · OnPlayerWake · CarryPlayer · the Carrying group of the index