FuriouZ Posted December 12, 2014 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) Homepage @ http://rageresources.blogspot.com/ Offical Facebook @ https://www.facebook.com/pages/Rage-Scr ... fref=photo
ViRuZGamiing Posted December 12, 2014 Posted December 12, 2014 You should look through the table "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
FuriouZ Posted December 12, 2014 Author 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.. Homepage @ http://rageresources.blogspot.com/ Offical Facebook @ https://www.facebook.com/pages/Rage-Scr ... fref=photo
Dealman Posted December 12, 2014 Posted December 12, 2014 You'd have to create a for loop to loop through all of the indexes in the table. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
manawydan Posted December 12, 2014 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 "Querer não é poder, mas tentar é avançar"!
FuriouZ Posted December 12, 2014 Author 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 Homepage @ http://rageresources.blogspot.com/ Offical Facebook @ https://www.facebook.com/pages/Rage-Scr ... fref=photo
MTA Team botder Posted December 12, 2014 MTA Team 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. GitHub: Debug Console • MTA-Discord Relay Scripting: How to draw a line chart with DirectX functions? • Doppler Effect in MTA • Get the client's FPS • Customizable Blur Shader
manawydan Posted December 12, 2014 Posted December 12, 2014 try change "DANCE" to "DANCING" "Querer não é poder, mas tentar é avançar"!
FuriouZ Posted December 12, 2014 Author Posted December 12, 2014 try change "DANCE" to "DANCING" Nothing, also no errors in debug Tried even animation given in wiki Homepage @ http://rageresources.blogspot.com/ Offical Facebook @ https://www.facebook.com/pages/Rage-Scr ... fref=photo
FuriouZ Posted December 12, 2014 Author 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) Homepage @ http://rageresources.blogspot.com/ Offical Facebook @ https://www.facebook.com/pages/Rage-Scr ... fref=photo
DiSaMe Posted December 12, 2014 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") -
FuriouZ Posted December 12, 2014 Author Posted December 12, 2014 Thank you so much ! Homepage @ http://rageresources.blogspot.com/ Offical Facebook @ https://www.facebook.com/pages/Rage-Scr ... fref=photo
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