If I would, lets say make a npc do the mechanic animation, how would you achieve that?
Well you would first need to get the entity of the npc, you can do this a few ways, easiest and most safe way would be to create the ped and just make it variable.
Here is an example.
local model = ` ig_benny` -- The spawn-name of the ped. Keep it as a back tick.
local myPed = CreatePed(4, model, coordsx, coordsy, coordz, heading, true, true)
So now, we have the ped spawning and it is a variable, if you are using it in a larger scope, then just remove the local to make it a global variable.
From Here, we need request the animation to play, you will also need to make sure it loads before attempting to play it:
local dict, anim = 'mp_car_bomb', 'onback_bwd'
while not HasAnimDictLoaded(dict) do -- Wait for the animation to load.
RequestAnimDict(dict)
Wait(100)
end
TaskPlayAnimAdvanced(myPed, dict, adnim, coords, 0.0, 0.0, heading - 180, 1.0, 0.5, 3000, 1, 0.0, 1, 1) -- Plays the animation
Final:
local model = ` ig_benny` -- The spawn-name of the ped. Keep it as a back tick.
local myPed = CreatePed(4, model, coordsx, coordsy, coordz, heading, true, true)
local dict, anim = 'mp_car_bomb', 'onback_bwd'
while not HasAnimDictLoaded(dict) do -- Wait for the animation to load.
RequestAnimDict(dict)
Wait(100)
end
TaskPlayAnimAdvanced(myPed, dict, adnim, coords, 0.0, 0.0, heading - 180, 1.0, 0.5, 3000, 1, 0.0, 1, 1) -- Plays the animation
Now, this should spawn the ped and play the animation.
[Make sure to add the coords + heading]
1 Like