Messages only for Administrators - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Messages only for Administrators (
/showthread.php?tid=275735)
Messages only for Administrators -
Kingunit - 10.08.2011
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.
Re: Messages only for Administrators -
Sascha - 10.08.2011
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
Re: Messages only for Administrators -
wouter0100 - 10.08.2011
Above first.
Re : Messages only for Administrators -
Soumi - 10.08.2011
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
-
Kingunit - 10.08.2011
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[])
Re: Messages only for Administrators -
Laronic - 11.08.2011
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;
}
Re: Messages only for Administrators -
Kush - 11.08.2011
Quote:
Originally Posted by Kingunit
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(color, string[]);
You forgot to declare the function. Place this before the function.
Re: Messages only for Administrators -
Kingunit - 11.08.2011
The stock already worked. Thank you.