FuriouZ Posted December 12, 2014 Share Posted December 12, 2014 Hey How can I create all peds from a table ? I can create randomly only one, but how I can create all peds with one function? Something like this: local dancers = { { 214, 1450.94434, -1674.35669, 16.21225, 280 }, { 1451.04382, -1672.26038, 16.21225, 280 } }; local skin, posx, posy, posz, rot = unpack ( dancers ( #dancers ) ) createPed (skin, posx, posy, posz, rot) Link to comment
ViRuZGamiing Posted December 12, 2014 Share Posted December 12, 2014 You should look through the table Link to comment
FuriouZ Posted December 12, 2014 Author Share Posted December 12, 2014 I have done tables only randomly Like this: local validHelmets = { { "moto", "moto" }, { "helmet", "helmet" } } local texture, model = unpack ( validHelmets [ math.random ( #validHelmets ) ] ) But how can I do same thing without math.random, so the script will create all the peds, not only one random one.. Link to comment
Dealman Posted December 12, 2014 Share Posted December 12, 2014 You'd have to create a for loop to loop through all of the indexes in the table. Link to comment
manawydan Posted December 12, 2014 Share Posted December 12, 2014 try this local dancers = { { 214, 1450.94434, -1674.35669, 16.21225, 280 }, { 1451.04382, -1672.26038, 16.21225, 280 } }; for i=1,#dancers do createPed (dancers[i][1],dancers[i][2],dancers[i][3],dancers[i][4],dancers[i][5]) end Link to comment
FuriouZ Posted December 12, 2014 Author Share Posted December 12, 2014 Thanks manawydan ! EDIT: Why animation doesn't start ? No errors in debug Code is server-sided for i=1,#dancers do local c_Dancers = createPed (dancers[i][1],dancers[i][2],dancers[i][3],dancers[i][4],dancers[i][5]) setPedAnimation(c_Dancers, "DANCE", "dnce_M_a") end Link to comment
MTA Team botder Posted December 12, 2014 MTA Team Share Posted December 12, 2014 The client didn't create the ped yet. When you create a ped serverside then it will take some ticks until the ped will be created clientside and that's why setting the animation may not work. Link to comment
manawydan Posted December 12, 2014 Share Posted December 12, 2014 try change "DANCE" to "DANCING" Link to comment
FuriouZ Posted December 12, 2014 Author Share Posted December 12, 2014 try change "DANCE" to "DANCING" Nothing, also no errors in debug Tried even animation given in wiki Link to comment
FuriouZ Posted December 12, 2014 Author Share Posted December 12, 2014 I figured out so far, that I have to use setTimer inside for i=1,#dancers do local c_Dancers = createPed (dancers[i][1],dancers[i][2],dancers[i][3],dancers[i][4],dancers[i][5]) --Here end But how? I don't really know.. It should be something like this: for i=1,#dancers do local c_Dancers = createPed (dancers[i][1],dancers[i][2],dancers[i][3],dancers[i][4],dancers[i][5]) setTimer(setPedAnimation(c_Dancers, "DANCING", "dnce_M_a"), 5000,1) end But there's something wrong that I can't figure out This way it's working, but I can't use table local c_Dancer = createPed (214, 1450.94434, -1674.35669, 16.21225, 280) function setanim() setPedAnimation(c_Dancer, "DANCING", "dnce_M_a") end setTimer(setanim, 5000,1) Link to comment
DiSaMe Posted December 12, 2014 Share Posted December 12, 2014 Animations, weapon ammo, stats and other stuff are not visible to the client unless they were set since the last time the ped was streamed in. If animation is applied before the ped has time to be streamed in for the client, the animation won't show. In either case, it won't show when the player goes far away and returns back. The simplest workaround is setting a timer which keeps applying the animation every few seconds. By the way... setTimer(setPedAnimation(c_Dancers, "DANCING", "dnce_M_a"), 5000,1) This executes setPedAnimation, which most likely returns true, and then passes true as the first argument to setTimer. Which changes nothing except calling setTimer with invalid arguments, producing a warning message. Instead, you need to pass the called function and its arguments as arguments of setPedAnimation: setTimer(setPedAnimation, 5000,1, c_Dancers, "DANCING", "dnce_M_a") Link to comment
FuriouZ Posted December 12, 2014 Author Share Posted December 12, 2014 Thank you so much ! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now