I got it working. Here is a way to use it if anyone needs to run animations!
Citizen.CreateThread(function()
local pid = PlayerPedId()
RequestAnimDict("random")
RequestAnimDict("random@arrests")
RequestAnimDict("random@arrests@busted")
while (not HasAnimDictLoaded("random@arrests@busted")) do Citizen.Wait(0) end
TaskPlayAnim(pid,"random@arrests","idle_2_hands_up",1.0,-1.0, 5000, 0, 1, true, true, true)
end)
Don’t know if you need all 3 RequestAnimDict’s but I did it and it worked
EDIT: This can only be run on the client, so fire an event from the server to the client like:
-Server
TriggerClientEvent('arrestme', target)
-Client
RegisterNetEvent("arrestme")
AddEventHandler('arrestme', function()
Here
end)
Hello, I’m looking to force an animation on a player. The Event is working but I can’t get the animation to run. I think I’m misusing the function.
PS Is there a better way to get a list of the players? I currently put each player that joins in a list for later, and call a function I created getPlayerByName()
Yeah I looked at it, it uses the native function TaskHandsUp() to play the animation.
function TaskHandsUp(ped, duration, facingPed, p3, p4)
I’ve looked on multiple sites and most of them say different things about how to use this function. Not sure what works because I’ve tried them with no success… function TaskPlayAnim(ped, animDictionary, animationName, speed, speedMultiplier, duration, flag, playbackRate, lockX, lockY, lockZ)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsControlJustPressed(0, 323) then --Start holding X
TaskArrestPed(GetPlayerPed(-1), 1000, GetPlayerPed(-1), -1, true) -- Perform animation.
RequestAnimDict("random@arrests@busted")
RequestAnimDict("get_up@cuffed")
TaskPlayAnim("random@arrests@busted")
TaskPlayAnim("get_up@cuffed")
end
end
end)
well need to make a function for the command and i think i would try a different native maybe but u need the client and server script to make sure it works right
@GanjaMonster Ok. U are making me sweat for it. So maybe the “TaskPlayAnimAdvanced” would be a nice choice-. Do u know what the first param is “p0” is? Is it PlayerId,PlayerPedID or even GetPlayerPed(-1)? U know when to use what? :=)
@GanjaMonster Like said in the op; “The Event is working but I can’t get the animation to run.” I’m experienced in many languages (And lua is one) it’s just there is no information on how to use most of the functions. I had to look around, and found 2 different ways to use Wait() and CreateThread, but the working one is Citizen.Wait() and Citizen.CreateThread. The native functions are worse no idea what does what just putting numbers in places and it worked D:
I’ll release my full rp player arrest script when it’s done just have to setup walking when hands are cuffed
I got the two commands finished so far have to get detaining working
/arrest PlayerName
/cuff PlayerName
I got the two commands finished so far have to get detaining working
/arrest PlayerName
/cuff PlayerName
Can’t it be PlayerId instad of name?
I just tried every thing and I can’t get it to work. Am just testing on my own player which should also work right?