-.Paradox.- Posted September 22, 2014 Posted September 22, 2014 Is it possible to loop the players with the same specified element data? If possible please a little help how would be appreciated.
crismar Posted September 22, 2014 Posted September 22, 2014 (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 September 22, 2014 by Guest
-.Paradox.- Posted September 22, 2014 Author Posted September 22, 2014 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 = {}
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