Jump to content

setPedAnimation not working with createPed


Recommended Posts

Hey all, I'm trying to make it so when a player loads in it creates a ped of their character and sets an animation.

Before, when I did this with the player rather than the ped, it worked, but was a little spotty (sometimes it applied the animation, sometimes you had to reconnect for it to work) so I thought using a ped would be better. But the animation isn't applying at all.

I've tried adding a timer, and all that did was make the ped spawn later, still no animation. The ped is being brought to the appropriate dimension, and spawning properly.

charPed[1] = createPed(getElementData(player,"char1skin"),1187,-2034.4,69.007,180)
setElementDimension(charPed[1],getElementDimension(player))
setPedAnimation(charPed[1],"ped","seat_idle",-1,false)

Again, it worked properly with the player, just not now. Any help would be appreciated!

Link to comment
5 minutes ago, Patrick2562 said:

setTimer(setPedAnimation, 100, 1, charPed[1],"ped","seat_idle",-1,false)

Use a little delay after createPed.

Hey! So I did try that before posting, I used 500 initially for the time, and it didn't work, but for some reason using your 100 works. Any idea why this could be so I can avoid it later?

Link to comment
  • Moderators
14 minutes ago, Stealthy Serval said:

Hey! So I did try that before posting, I used 500 initially for the time, and it didn't work, but for some reason using your 100 works. Any idea why this could be so I can avoid it later?

I have no idea.

Link to comment

Try this:

charPed[1] = createPed(getElementData(player,"char1skin"),1187,-2034.4,69.007,180)
setElementDimension(charPed[1],getElementDimension(player))

setTimer(function ()
	setPedAnimation (charPed[1], "ped", "SEAT_idle", -1, true, false, false ) 
end, 100, 1)

EDIT: here it works

Edited by Tommy.
  • Thanks 1
Link to comment
  • Moderators
1 hour ago, Tommy. said:

Try this:


charPed[1] = createPed(getElementData(player,"char1skin"),1187,-2034.4,69.007,180)
setElementDimension(charPed[1],getElementDimension(player))

setTimer(function ()
	setPedAnimation (charPed[1], "ped", "SEAT_idle", -1, true, false, false ) 
end, 100, 1)

EDIT: here it works

 

setTimer(function ()
	setPedAnimation (charPed[1], "ped", "SEAT_idle", -1, true, false, false ) 
end, 100, 1)

and

setTimer(setPedAnimation, 100, 1, charPed[1], "ped", "SEAT_idle", -1, true, false, false)

are same.

Link to comment
15 minutes ago, Patrick2562 said:

 


setTimer(function ()
	setPedAnimation (charPed[1], "ped", "SEAT_idle", -1, true, false, false ) 
end, 100, 1)

and


setTimer(setPedAnimation, 100, 1, charPed[1], "ped", "SEAT_idle", -1, true, false, false)

are same.

As he said it did not work I gave him a solution that works with me

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...