Jump to content

Loop question


-.Paradox.-

Recommended Posts

Posted

Is it possible to loop the players with the same specified element data?

If possible please a little help how would be appreciated.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted (edited)

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

Contact me if you are looking for a Web Developer.

3rd of October 2014 - Founder of RomaniaZ

Posted
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 = {} 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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