Forum

> > CS2D > Scripts > Send message to spesific user group
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Send message to spesific user group

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Send message to spesific user group

limonata
User Off Offline

Zitieren
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.")
}

alt Re: Send message to spesific user group

VADemon
User Off Offline

Zitieren
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
1× editiert, zuletzt 04.04.16 15:07:53
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht