Messages only for Administrators
#1

Hello,

I saw in many scripts that they are using something like:

pawn Code:
SendMessageToAdmins(COLOR_RED"Hello"); // Just for example
How can I create something like that.
Reply
#2

SendMessageToAdmins(COLOR_RED, "Hello");^^ (you forgot a ","),..
anyways here's an example
pawn Code:
forward SendMessageToAdmins(color, msg[])
{
  for(new i=0; i<GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
    {
      if(PlayerInfo[i][Admin] == 1)
      {
        SendClientMessage(i, color, msg);
      }
    }
  }
  return 1;
}
remember that PlayerInfo[i][Admin] is just an example.. you need to replace it with your code to check whether a player is an admin
Reply
#3

Above first.
Reply
#4

pawn Code:
public SendMessageToAdmins(color, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerAdmin(i))
        {
            SendClientMessage(i, color, string);
        }
    }
    return 1;
}
Here you go.

EDIT: Too late
Reply
#5

Awsome, I'm going to try this. Much easier to create some messages for admins.

Hmm, when I installed it I recieve a error:
Code:
C:\Users\Jurrien\Documents\Deathmatch\gamemodes\deathmatch.pwn(4250) : warning 235: public function lacks forward declaration (symbol "SendMessageToAdmins")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Line:
pawn Code:
public SendMessageToAdmins(color, string[])
Reply
#6

change the 'public' to 'stock'

pawn Code:
COMMAND:hiadmins(playerid, params[])
{
    SendMessageToAdmins(0xFF0000AA, "Hi Admins!");
    return 1;
}

stock SendMessageToAdmins(color, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerAdmin(i))
        {
            SendClientMessage(i, color, string);
        }
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by Kingunit
View Post
Hmm, when I installed it I recieve a error:
Code:
C:\Users\Jurrien\Documents\Deathmatch\gamemodes\deathmatch.pwn(4250) : warning 235: public function lacks forward declaration (symbol "SendMessageToAdmins")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Line:
pawn Code:
public SendMessageToAdmins(color, string[])
PHP Code:
forward SendMessageToAdmins(colorstring[]); 
You forgot to declare the function. Place this before the function.
Reply
#8

The stock already worked. Thank you.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)