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

Adds the animations panel to the context menu, listing every animation the local player's model supports.
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).
Ends the animation of a player who drops their character.
Ends the animation of a player who has switched characters and lets the new character start one right away.
Rebuilds the animations panel so it matches the player's current model.
Ends the animation of a player who is leaving the server.
Ends the animation of a player who is spawning, so that they never spawn locked or in the third person view of an animation.
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.
Ends the animation of a player who has died.
Hides the crosshair while the local player is playing an animation.
Takes the movement, jump, crouch and attack input out of the commands of a player who is playing an animation.
Keeps an animating player rendered at the angle they started the animation at.

Methods

all()shared
Returns all registered animations.
Checks whether a player may start an animation right now.
Returns the sequences that the model of a player has out of the specified ones.
get(id)shared
Returns a registered animation.
Returns all registered animations in the order they were registered in, which is the order the context menu lists them in.
Returns the animation a player is playing.
Works out which sequences a player would play for an animation.
Checks whether a player is playing an animation of this plugin.
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.
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.
Makes a player play an animation: the enter sequence, if it has one, then the main sequence.
Registers an animation that players can play from the context menu.
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.

Hooks

Animations:ContextMenuCreated(context_menu)

client plugins/animations/plugin/cl_hooks.lua:11

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

Animations:Move(actor, move_data)

shared plugins/animations/plugin/sh_plugin.lua:78

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:92

Implements 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

Animations:OnActiveCharacterSet(owner, _character)

server plugins/animations/plugin/sv_hooks.lua:83

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

Animations:OnContextMenuOpen()

client plugins/animations/plugin/cl_hooks.lua:112

Rebuilds the animations panel so it matches the player's current model.

Animations:PlayerDisconnected(actor)

server plugins/animations/plugin/sv_hooks.lua:75

Implements hook PlayerDisconnected

Ends the animation of a player who is leaving the server.

Parameters

  • actor Player

Animations:PlayerSpawn(actor)

server plugins/animations/plugin/sv_hooks.lua:69

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

Animations:PlayerThink(actor, _cur_time)

server plugins/animations/plugin/sv_hooks.lua:33

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()

Animations:PostPlayerDeath(victim)

server plugins/animations/plugin/sv_hooks.lua:62

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

Animations:ShouldHUDPaintCrosshair()

client plugins/animations/plugin/cl_hooks.lua:122

Implements hook ShouldHUDPaintCrosshair

Hides the crosshair while the local player is playing an animation.

Returns

  • Boolean false while animating, nil otherwise

Animations:StartCommand(actor, user_cmd)

shared plugins/animations/plugin/sh_plugin.lua:45

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

Animations:UpdateAnimation(actor)

shared plugins/animations/plugin/sh_plugin.lua:95

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

Animations:can_play(actor, id)

server plugins/animations/plugin/sv_plugin.lua:240

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

Animations:find_sequences(target, names)

shared plugins/animations/plugin/lib/sh_animations.lua:82

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

Animations:get_playing(target)

shared plugins/animations/plugin/lib/sh_animations.lua:126

Returns the animation a player is playing.

Parameters

  • target Player

Returns

  • String ID of the animation, nil if the player is not playing one

Animations:get_sequences(target, data)

shared plugins/animations/plugin/lib/sh_animations.lua:109

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

Animations:is_playing(target)

shared plugins/animations/plugin/lib/sh_animations.lua:133

Checks whether a player is playing an animation of this plugin.

Parameters

  • target Player

Returns

  • Boolean

Animations:is_restricted(actor)

server plugins/animations/plugin/sv_plugin.lua:218

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

Animations:leave(actor)

server plugins/animations/plugin/sv_plugin.lua:335

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

Animations:play(actor, id)

server plugins/animations/plugin/sv_plugin.lua:265

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

Animations:register_anim(data)

shared plugins/animations/plugin/lib/sh_animations.lua:38

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

Animations:stop(actor)

server plugins/animations/plugin/sv_plugin.lua:352

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

Defined in