Forum

> > CS2D > Scripts > Send message to spesific user group
Forums overviewCS2D overview Scripts overviewLog in to reply

English Send message to spesific user group

3 replies
To the start Previous 1 Next To the start

old Send message to spesific user group

limonata
User Off Offline

Quote
Hi, how i can sent message to a list of usgn id?

For example:

1
2
3
4
5
6
admins = {1,2,3}

function sendMsgToAdmins(){
	local adm_id = ??
	msg2(adm_id,"This msg is for admins only.")
}

old Re: Send message to spesific user group

VADemon
User Off Offline

Quote
I'd start off with a different table (dictionary) to store admin USGNs in:
1
2
3
4
admins = {
   [50998] = true,
   [7844] = true
}
With this table you can easily check a USGN:
1
2
3
if admins[ player(id, "usgn") ] == true then
   msg(player(id, "name") .. " is an admin")
end

Full code iterates through existing players and checks their USGNs:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
admins = {
   [50998] = true,
   [7844] = true
}

function sendMsgToAdmins(messageText)
   local playerList = player(0, "table")

   for i = 1, #playerList do
      local id = playerList[i]
      
      if admins[ player(id, "usgn") ] == true then
          msg2(id, messageText)
      end
   end
end

Ultimately all you need to do is to call the function:
1
sendMsgToAdmins("Hello, Moto!")

UPDated: See user Hajt's post
edited 1×, last 04.04.16 03:07:53 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview