TrickyTommy Posted August 12, 2017 Share Posted August 12, 2017 Hi! I want to send a message for the people, who has "Admin" as an element Data. This is what i could do so far: function sendMessageToAdmins(msg) for k, v in ipairs (getElementsByType("player")) do if getElementData (v, "Admin", true) then outputChatBox (msg, v) end end dunno how to continue. Link to comment
NeXuS™ Posted August 12, 2017 Share Posted August 12, 2017 The "true" in your getElementData is not required, as it's optional arguments is true too. Does this not work, or what? You miss an "end", maybe thats why. 1 Link to comment
TrickyTommy Posted August 12, 2017 Author Share Posted August 12, 2017 8 minutes ago, NeXuS™ said: The "true" in your getElementData is not required, as it's optional arguments is true too. Does this not work, or what? You miss an "end", maybe thats why. Actually, i found the piece of code on Wikipedia, but i don't really know what this part "k, v in ipairs" of the code does. I looked it up, but did not really understand the explanations. Link to comment
NeXuS™ Posted August 12, 2017 Share Posted August 12, 2017 Try to understand it from here. 1 Link to comment
Oussema Posted August 12, 2017 Share Posted August 12, 2017 1 hour ago, TrickyTommy said: Hi! I want to send a message for the people, who has "Admin" as an element Data. This is what i could do so far: function sendMessageToAdmins(msg) for k, v in ipairs (getElementsByType("player")) do if getElementData (v, "Admin", true) then outputChatBox (msg, v) end end dunno how to continue. function sendMessageToAdmins(msg) for i, admin in pairs (getElementsByType("player")) do if getElementData (admin, "Admin") then outputChatBox ("ADMIN Message: ".. msg, admin) end end end 1 Link to comment
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