Sign in to follow this  
TrickyTommy

outputChatBox something for people who has "Admin" as elementData?

Recommended Posts

TrickyTommy    0

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

Share this post


Link to post
NeXuS™    295

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.

  • Thanks 1

Share this post


Link to post
TrickyTommy    0
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. 

Share this post


Link to post
Oussema    15
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

 

  • Thanks 1

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.