An animation is registered with Animations:register_anim and is made of sequences of
the player's model: an optional enter sequence, the main sequence and an optional exit
sequence. A stance holds its main sequence until the player presses a movement key or
picks an animation again; a one-shot gesture plays it once and ends by itself. Clients
only read the two networked variables of the player: fl_animation, the ID of the
animation they are playing, and fl_animation_angle, the angle they are rendered at.
Summary
Hooks
StartCommand handler).Methods
Hooks
Adds the animations panel to the context menu, listing every animation the local player's model supports.
Parameters
- context_menu Panel context menu the panel is parented to
Stops a player who is playing an animation where they stand: the speed they had when it
started and the speed other plugins ask for are dropped, and so is the jump key, which
the client keeps in its commands (see the StartCommand handler). The vertical speed is
kept, so that the player still falls when the ground under them is gone.
Parameters
- actor Player player being moved
- move_data CMoveData movement data of the player
Animations:OnActiveCharacterCleared(owner, _character)
server plugins/animations/plugin/sv_hooks.lua:92Implements hook OnActiveCharacterCleared
Ends the animation of a player who drops their character.
Parameters
- owner Player player whose character is being dropped
- _character Character the character that is being dropped
Implements hook OnActiveCharacterSet
Ends the animation of a player who has switched characters and lets the new character start one right away.
Parameters
- owner Player player whose character was set
- _character Character newly active character
Rebuilds the animations panel so it matches the player's current model.
Implements hook PlayerDisconnected
Ends the animation of a player who is leaving the server.
Parameters
- actor Player
Ends the animation of a player who is spawning, so that they never spawn locked or in the third person view of an animation.
Parameters
- actor Player
Implements hook PlayerThink
Ends the animation of a player who can no longer play it: one who has died, entered a vehicle, been ragdolled or frozen, started noclipping or gone under water, whose sequence has been dropped, who has been off the ground for two checks in a row, or who has been moved away from where they started it.
Parameters
- actor Player
- _cur_time Number current CurTime()
Ends the animation of a player who has died. The framework has dropped the sequence by then, which ends the animation by itself; this makes sure nothing is left behind.
Parameters
- victim Player
Implements hook ShouldHUDPaintCrosshair
Hides the crosshair while the local player is playing an animation.
Returns
- Boolean false while animating, nil otherwise
Takes the movement, jump, crouch and attack input out of the commands of a player who
is playing an animation. On the server, a movement or jump key that is pressed during the
animation makes the player leave it; keys that were already held down when it started do
not count until they have been let go of. The client leaves the jump key in the commands
it builds, since a command reaches the server the way the client has left it and the
server could not tell that the key was pressed otherwise; the jump itself is taken out
of the movement in the Move handler on both sides.
Parameters
- actor Player
- user_cmd CUserCmd
Keeps an animating player rendered at the angle they started the animation at.
Parameters
- actor Player player being animated
Methods
Returns all registered animations.
Returns
- Map animation data by ID
Checks whether a player may start an animation right now. Runs the
PlayerCanPlayAnimation hook once the plugin's own checks have passed.
Parameters
- actor Player
- id String ID of the animation
Returns
- Boolean whether the animation can be started
- String phrase that says why not
- Map arguments of the phrase or nil
Returns the sequences that the model of a player has out of the specified ones.
Parameters
- target Player
- names String name of a sequence, or List<String> of names
Returns
- List<String> names of the sequences the model has, in the order given
Returns a registered animation.
Parameters
- id String ID of the animation
Returns
- Map animation data, nil if it is not registered
Returns all registered animations in the order they were registered in, which is the order the context menu lists them in.
Returns
- List<Map> animation data
Returns the animation a player is playing.
Parameters
- target Player
Returns
- String ID of the animation, nil if the player is not playing one
Works out which sequences a player would play for an animation. The model of the player has to have the enter and the exit sequence, if the animation has them, and at least one of its main sequences.
Parameters
- target Player
- data Map animation data
Returns
- Map sequences: enter (String or nil), variants (List<String> main sequences the model has) and exit (String or nil); nil if the model cannot play the animation
Checks whether a player is playing an animation of this plugin.
Parameters
- target Player
Returns
- Boolean
Checks whether a player is in a state in which no animation can be played: dead, in a vehicle, ragdolled, in observer mode, deep in water, or anything but on foot, which covers noclipping, climbing a ladder and being frozen.
Parameters
- actor Player
Returns
- Boolean
Makes a player leave the animation they are playing the way they would by themselves: with its exit sequence, after which they are free again. An animation without an exit sequence ends at once.
Parameters
- actor Player
Returns
- Boolean false if the player is not playing an animation
Makes a player play an animation: the enter sequence, if it has one, then the main
sequence. The player is turned to the wall if the animation needs one, locked in place
and, with the animations_third_person config on, switched to third person. Starts the
cooldown of the animations_cooldown config.
local started, reason, arguments = Animations:play(actor, 'sit_ground')
if !started then
actor:notify(reason, arguments)
end
Parameters
- actor Player
- id String ID of the animation
Returns
- Boolean whether the animation has started
- String phrase that says why not
- Map arguments of the phrase or nil
Registers an animation that players can play from the context menu. Registering an ID again replaces the animation and keeps its place in the list.
Animations:register_anim({
id = 'sit_ground',
name = 'animation.sit_ground.name',
enter = 'idle_to_sit_ground',
anim = 'sit_ground',
exit = 'sit_ground_to_idle'
})
Parameters
- data Map animation data: id (String), name (String text or phrase), anim (String name of the main sequence, or a List of names, of which one that the model has is picked at random), enter and exit (String optional sequences played before and after it), one_shot (Boolean the main sequence is played once and the animation ends by itself), duration (Number seconds the main sequence is kept for: for a stance 0 or nil keeps it until the player leaves, for a one-shot it replaces the length of the sequence), wall ('behind' or 'front': the player has to stand with their back or their face against a wall and is turned to it) and wall_height (Number height above the feet at which the wall is looked for, the eyes if nil)
Returns
- Map the registered animation data
Ends the animation of a player at once, without its exit sequence: the sequence is stopped, the player can move again, leaves third person if the plugin has put them into it, and the plugin forgets the animation.
Parameters
- actor Player
Returns
- Boolean false if the player is not playing an animation