Jump to content

Loop question


-.Paradox.-

Recommended Posts

Oh well.

  
function getPlayersByElementData(theData) 
local tableResult = {} 
for i, v in ipairs(getElementsByType("player")) do 
if getElementData(v, theData) then 
table.insert(tableResult, v) 
end 
end 
return tableResult 
end 
  

Now just use my function like this:

  
for i, v in ipairs(getPlayersByElementData("swag")) do 
outputChatBox(getPlayerName(v).." has the specified element data set!", root, 0, 255, 0) 
end 
  

Edited by Guest
Link to comment
Oh well.
  
function getPlayersByElementData(theData) 
local tableResult 
for i, v in ipairs(getElementsByType("player")) do 
if getElementData(v, theData) then 
table.insert(tableResult, v) 
end 
end 
return tableResult 
end 
  

Now just use my function like this:

  
for i, v in ipairs(getPlayersByElementData("swag")) do 
outputChatBox(getPlayerName(v).." has the specified element data set!", root, 0, 255, 0) 
end 
  

Bad argument #1 to 'insert' (table expected got nil)

Anyway thanks i fixed it

By the way, Here is the correction for your code i guess

local tableResult = {} 

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