ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. setPedAnimation

Function

setPedAnimation

Server and clientPedsModified from MTA:SA

Plays an animation on a ped. The animation comes from a game animation block (e.g. ped, dancing, smoking) or from an IFP file loaded with engineLoadIFP. Calling it without a block stops the animation. On the server the animation reaches every player. On the client it only runs in this game: for the local player others see it through pose streaming; for a remote player the function returns false because their appearance comes from their own game.

Syntax

bool setPedAnimation(ped ped [, string block = nil, string anim = nil, int time = -1, bool loop = true, bool updatePosition = true, bool interruptable = true, bool freezeLastFrame = true, int blendTime = 250, bool retainPedState = false, bool movable = auto])

Arguments

pedped
A player or an NPC.
blockstring, optional = nil
Animation block name, e.g. "ped", "dancing", "BEACH", or a block from engineLoadIFP. Omitted = stop the animation.
animstring, optional = nil
Animation name within the block, e.g. "WEAPON_crouch", "dnce_M_a".
timeint, optional = -1
How long the animation lasts in ms; -1 = all of it (or forever when looped).
loopbool, optional = true
true = the animation loops.
updatePositionbool, optional = true
true = the animation moves the ped (e.g. walking), false = the ped stays in place.
interruptablebool, optional = true
true = the player can interrupt the animation by moving.
freezeLastFramebool, optional = true
true = after the animation ends, the ped holds the last frame.
blendTimeint, optional = 250
Blend time from the previous pose in ms.
retainPedStatebool, optional = false
true = the ped keeps its state (e.g. weapon in hand) after the animation.
movablebool, optional = auto
true = the animation plays on the upper body only and the ped can still walk, run and turn (like carrying a box with CARRY/crry_prtial in the game). Omitted = true for animations with prtial in the name, otherwise false.Not in MTA:SA

Differences from MTA:SA

  • Arguments in a different colour differ from MTA:SA.

In MTA:SA

setPedAnimation(ped thePed, string block = nil, string anim = nil, int time = -1, bool loop = true, bool updatePosition = true, bool interruptable = true, bool freezeLastFrame = true, int blendTime = 250, bool retainPedState = false)

Returns

true on success.

Example

addCommandHandler("tancz", function(player)
    setPedAnimation(player, "dancing", "dnce_M_a", -1, true, false)
end)
addCommandHandler("stop", function(player)
    setPedAnimation(player)
end)

See also