How to play an animation in lua

I’m trying to make a script that plays some animations on the player to enhance RP, but I can’t find any documentation at all on how to play animations on the player. I know about the PlayEntityAnim native, and I have found the animation names list, but I don’t know how to use it.
Is there any documentation at all on how the native works? The natives.lua file has PlayEntityAnim(entity, animation, propName, p3, p4, p5, p6, delta, bitset), which doesn’t help, since I still have no clue what the variables are for. If there’s a native to get the player entity, and check if the animation is finished, that would be helpful too.

Following some more research, I have found out some new info. First you need to call the function RequestAnimDict("anim@dictionary"), then instead of PlayEntityAnim you need to use TaskPlayAnim like they use here. It might be useful in the future to anyone trying to play animations in their scripts.

2 Likes

And I’ve now encountered another issue. The animations only work for me, other people see the animations on my character, when I activate the script, but when other people activate the script, they don’t get any animations. Is there anything that could be causing this? The animations are fully clientside.

@therealwox said in How to play an animation in lua:

The animations are fully clientside.

I believe this is your problem… they arent server side so only you see them.

@therealwox said in How to play an animation in lua:

And I’ve now encountered another issue. The animations only work for me, other people see the animations on my character, when I activate the script, but when other people activate the script, they don’t get any animations. Is there anything that could be causing this? The animations are fully clientside.

You have to run the animation on said pedestrian on each client. Or run it on the one that owns it.

@kanersps said in How to play an animation in lua:

You have to run the animation on said pedestrian on each client. Or run it on the one that owns it.

I should have made it more clear, the script is animating the player, it’s a sort of more advanced ‘hands up’ script, so I’d assume that technically the player would own their own ped, or is the server supposed to handle such animations?

im currently trying to do that for the cuffed animation

@therealwox Any progress?

can we chat i have some questions about hands up script here is my teamspeak ip
vs32.tserverhq.com:7130