Jump to content

Table


FuriouZ

Recommended Posts

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

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

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

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

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

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...