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
| Name | Type | Description |
|---|---|---|
| ped | element | The ped or player. An element with peds below it in the tree applies to all of them. |
| block | string|false | The animation block's name. false or left out together with anim stops the animation.default nil |
| anim | string | The animation's name inside the block. Without it, the current animation stops.default nil |
| time | int | How long the animation runs, in milliseconds. -1 has no limit.default -1 |
| loop | bool | Repeat the animation.default true |
| updatePosition | bool | Let the animation move the ped through the world.default true |
| interruptible | bool | Let the game's reactions, such as being pushed, interrupt the animation.default true |
| freezeLastFrame | bool | Hold the last frame instead of leaving the animation when it ends.default true |
| blendTime | int | Blend time into the animation, in milliseconds.default 250 |
| restoreTask | bool | If 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)