Jump to content

getElementData ipairs


Dolinho

Recommended Posts

if I use that goes for all of the specific team

for _,v in ipairs (getPlayersInTeam (getTeamFromName("Novo Jogador do BMV"))) do 
outputChatBox ( "Ola novo jogador", v ,0,255,0,true) 

how will I do for getElementData ?

for _,v in ipairs (getElementData("Red")) do  
outputChatBox ( "Ola novo jogador", v ,0,255,0,true) 

??????????????

If a player has Element Red so he would receive a msg

Link to comment
  • Moderators

lol, your previously code was better.

Yet, mihayy5 his code is still the best solution, since getElementData only returns nil when the code fails, otherwise false.

@Dolinho

Make sure you only send the message to the correct player. Which you can set up in the outputChatBox function.

Link to comment
  
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 

Example

  
for i, v in ipairs(getPlayersByElementData("Red")) do 
outputChatBox("lol msg", v, 0, 255, 0) 
end 
  

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