Jump to content

getElementData ipairs


Dolinho

Recommended Posts

Posted

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

Posted
function theCheck() 
    for _,v in ipairs (getElementsByType("player")) do 
        if getElementData(v,"Red") then 
            outputChatBox ( "Ola novo jogador", v ,0,255,0,true) 
        end 
    end 
end  

Resources I made:

Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!

 

Posted

?

local players = getElementsByType('player') 
      for index, p in ipairs(players) do 
            if getElementData(p, 'Red') ~= nil then 
                  --Your message here 
            end 
      end 

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)

My bad, I was connected from my mobile, Try this

    for i, v in ipairs((getElementData(getElementsByType('player'), 'Red')) ~= nil) do 
            --Your message here 
    end 

Edited by Guest

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.

  • Moderators
Posted

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.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
  
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 
  

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