Player class
Part of Ragdoll
Player extensions of the Ragdoll plugin that work on both realms: reading the ragdoll state of a player and finding the ragdoll that stands in for them. The state and the ragdoll are data table variables of the player, so a client knows them for every player it is being sent.
Summary
Methods
Methods
Spawns a ragdoll copy of the player (model, skin, bodygroups, material and color) and stores it as their ragdoll entity. Does nothing if they already have a valid one. A fallen player first leaves the vehicle they are in; they are then frozen, hidden and stripped of their weapons, and a fire they are burning with moves over to the ragdoll. They get everything back once the ragdoll is let go of or removed. Serverside only.
Parameters
- decay Number optional, defaults to
nilseconds the ragdoll remains after the ragdoll entity is reset; nil removes it right away - fallen Boolean optional, defaults to
falsewhether the player has fallen over rather than died - force Vector optional, defaults to
nilpush to give to every bone of the ragdoll, shortened to 800 units so that it does not throw the ragdoll across the map
Returns
- Entity the ragdoll, or nil if it could not be created
See also
Returns when the player gets up by themselves. Serverside only.
Returns
- Number CurTime() at which they get up; nil if they have no get up timer or it is paused
Returns how long the knocked out player stays out, for HUDs and the like. Both realms know it, as the end of the get up timer is networked.
Returns
- Number seconds until the player comes to by themselves; 0 if they are not knocked out; nil if they are knocked out without a timer, or while the timer is paused, and stay out until something wakes them
Returns the table that describes the ragdoll of the player: what they get back when they get up, the damage immunity and the get up timer. Its fields are listed at the top of plugins/ragdoll/plugin/sv_plugin.lua. Serverside only.
Returns
- Map the ragdoll data, or nil if the player has no ragdoll
Returns the player's ragdoll entity: the body of a player who has fallen over or was knocked out, or the corpse of a dead one.
Returns
- Entity the ragdoll, or a NULL entity if the player has none
Returns the ragdoll state of the player.
Returns
- Number one of the RAGDOLL_ enums
- RAGDOLL_NONE if the player is not ragdolled
Makes the fallen player start getting up by themselves, which is what the jump key and
the getup command do. Refused if they are not fallen over (a knocked out player has to
wait), if they already have a get up timer, running or paused, if someone is dragging
their ragdoll (Player:get_dragger of the Pickup Objects plugin), or if the
PlayerCanGetUp hook says no. Serverside only.
Parameters
- duration Number optional, defaults to
nilseconds it takes, never less than the ragdoll_getup_time config, which is also the default, nor more than 60
Returns
- Boolean true if the player has started getting up
Checks whether the player is lying on the ground and able to get up by themselves.
Returns
- Boolean
Checks whether the get up timer of the player is paused. Serverside only.
Returns
- Boolean
Checks whether the player is knocked out: lying on the ground, unable to get up until the state ends.
Returns
- Boolean
Checks whether the player is in any ragdoll state other than RAGDOLL_NONE. Note that this includes dead players, who are in the RAGDOLL_DUMMY state until they respawn.
Returns
- Boolean
Knocks the player out: they fall over, or stay down if they are fallen over already, and cannot get up by themselves until they come to. While they are out they are not heard over voice chat and cannot switch characters. The PlayerCanKnockOut hook can refuse; PlayerKnockedOut runs afterwards and PlayerWokeUp once they come to. Serverside only.
target:knock_out(30, { attacker = actor }) -- out for half a minute
target:knock_out() -- out until something wakes them
Parameters
- duration Number optional, defaults to
nilseconds after which the player comes to by themselves; nil or 0 keeps them out untilPlayer:wake_up,Player:set_getup_timeor staff gets them up - options Map optional, defaults to
niloptional settings: attacker (Entity whoever knocks the player out) and force (Vector push given to the ragdoll)
Returns
- Boolean true if the player is knocked out now
See also
Pauses the get up timer of the player, for example while someone is carrying them. The player cannot start getting up by themselves while it is paused. Serverside only.
Returns
- Boolean true if a running timer was paused
See also
Lets go of the player's ragdoll and removes it, right away or after its decay time (unless PlayerCanRagdollDecay keeps it). A player whose body the ragdoll had taken over gets it back: unless they are dead or being reset, they are moved to the ragdoll, given their weapons and view back and keep burning if the ragdoll was. Serverside only.
Parameters
- reset Boolean optional, defaults to
falsethe player is being respawned: only make them visible, solid and able to move again
Clears the ragdoll state of the player without getting them up: no hook is asked, the player is not moved to their ragdoll and does not get their weapons back. This is what happens when a player respawns or leaves; the corpse of a dead player then stays for its decay time. Runs PlayerUnragdolled if the player was ragdolled. Serverside only.
Resumes the get up timer of the player with the time it had left when it was paused. Serverside only.
Returns
- Boolean true if a paused timer was resumed
See also
Makes the fallen or knocked out player get up by themselves after a delay, replacing the timer they have and resuming a paused one. The timer is a timed action called 'getup', which shows the player a progress bar. Serverside only.
target:set_getup_time(10) -- get up in ten seconds
target:set_getup_time() -- stay down until something else gets the player up
Parameters
- delay Number optional, defaults to
nilseconds until the player gets up; nil or 0 only stops the timer
Returns
- Boolean false if the player is not alive and lying on the ground
See also
Sets the networked ragdoll entity of the player. Does not spawn or remove anything. Serverside only.
Parameters
- entity Entity
Sets how long the ragdoll of the player ignores damage that was not dealt by a player, such as hitting the ground. Does nothing if the player has no ragdoll. Serverside only.
Parameters
- delay Number optional, defaults to
nilseconds of immunity from now on; nil ends it
Sets the player's ragdoll state and creates or removes their ragdoll to match it. RAGDOLL_FALLENOVER and RAGDOLL_KNOCKEDOUT put a living player on the ground as a ragdoll, with the 'fallen' action; a fallen player may get up by themselves, a knocked out one may not. RAGDOLL_DUMMY leaves a corpse that stays for the ragdoll_decay_time config after the player respawns. RAGDOLL_NONE gets a player who is lying on the ground back up where their ragdoll is. The PlayerCanRagdoll and PlayerCanUnragdoll hooks can refuse the change; PlayerRagdolled and PlayerUnragdolled run after it. Serverside only.
target:set_ragdoll_state(RAGDOLL_FALLENOVER) -- fall over until they get up by themselves
target:set_ragdoll_state(RAGDOLL_KNOCKEDOUT, 30) -- knock out for half a minute
target:set_ragdoll_state(RAGDOLL_NONE) -- get back up
Parameters
- state Number optional, defaults to
RAGDOLL_NONEone of the RAGDOLL_ enums - delay Number optional, defaults to
nilseconds after which a fallen or knocked out player gets up by themselves; nil leaves them down until something gets them up - options Map optional, defaults to
niloptional settings for falling over: force (Vector push given to the ragdoll, such as the force of the damage that knocked the player down) and attacker (Entity whoever knocked the player out, passed to the knockout hooks)
Returns
- Boolean true if the player is now in the state, false if a hook has refused or the state does not apply to them
See also
Brings the knocked out player to: they get up where their ragdoll is, unless the PlayerCanUnragdoll hook keeps them down. Serverside only.
Returns
- Boolean true if the player is up; false if they were not knocked out or a hook has refused