M MY Multiplayer: Wiki
Side
Kind

setPedAnimation

Client

Makes a ped play an animation from a block, or stops the animation it is playing. The animation applies on this client only.

bool setPedAnimation(element ped [, string|false block = nil, string anim = nil, int time = -1, bool loop = true, bool updatePosition = true, bool interruptible = true, bool freezeLastFrame = true, int blendTime = 250, bool restoreTask = false])

Parameters

NameTypeDescription
pedelementThe ped or player. An element with peds below it in the tree applies to all of them.
blockstring|falseThe animation block's name. false or left out together with anim stops the animation.default nil
animstringThe animation's name inside the block. Without it, the current animation stops.default nil
timeintHow long the animation runs, in milliseconds. -1 has no limit.default -1
loopboolRepeat the animation.default true
updatePositionboolLet the animation move the ped through the world.default true
interruptibleboolLet the game's reactions, such as being pushed, interrupt the animation.default true
freezeLastFrameboolHold the last frame instead of leaving the animation when it ends.default true
blendTimeintBlend time into the animation, in milliseconds.default 250
restoreTaskboolIf the ped was crouching, crouch again when the animation ends.default false

Returns

true if the animation started or stopped on the element given, false if the block does not exist or the element is not a ped.

The animation is kept while the ped is streamed out and resumes at the right point when it comes back.

Example

addCommandHandler("dance", function()
    setPedAnimation(localPlayer, "DANCING", "dance_loop")
end)

addCommandHandler("stopanim", function()
    setPedAnimation(localPlayer)
end)

See also