SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 10/08/2011, 10:14 PM   #1
Kingunit
High-roller
 
Kingunit's Avatar
 
Join Date: Dec 2010
Location: The Netherlands
Posts: 1,426
Reputation: 120
Default Messages only for Administrators

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.
__________________
Kingunit is offline  
Old 10/08/2011, 10:17 PM   #2
Sascha
High-roller
 
Sascha's Avatar
 
Join Date: Jul 2009
Location: Germany
Posts: 1,494
Reputation: 70
Default Re: Messages only for Administrators

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
__________________
Don't bother to contact me, I'm out of SA-MP
Sascha is offline  
Old 10/08/2011, 10:17 PM   #3
wouter0100
Big Clucker
 
wouter0100's Avatar
 
Join Date: Aug 2010
Posts: 164
Reputation: 0
Default Re: Messages only for Administrators

Above first.
wouter0100 is offline  
Old 10/08/2011, 10:18 PM   #4
Soumi
Huge Clucker
 
Soumi's Avatar
 
Join Date: Feb 2011
Location: Tunisia
Posts: 307
Reputation: 39
Default Re : Messages only for Administrators

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
__________________

Blueberry Prison Roleplay coming back?! MAYBE!
Soumi is offline  
Old 10/08/2011, 10:19 PM   #5
Kingunit
High-roller
 
Kingunit's Avatar
 
Join Date: Dec 2010
Location: The Netherlands
Posts: 1,426
Reputation: 120
Default

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 (c) 1997-2006, ITB CompuPhase


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

Last edited by JaTochNietDan; 11/08/2011 at 04:57 AM. Reason: Use the edit button.
Kingunit is offline  
Old 11/08/2011, 02:51 AM   #6
Laronic
Huge Clucker
 
Laronic's Avatar
 
Join Date: Mar 2011
Posts: 412
Reputation: 57
Default Re: Messages only for Administrators

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;
}
Laronic is offline  
Old 11/08/2011, 02:58 AM   #7
Kush
Gangsta
 
Join Date: May 2011
Posts: 781
Reputation: 123
Default Re: Messages only for Administrators

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 (c) 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.
Kush is offline  
Old 11/08/2011, 03:20 AM   #8
Kingunit
High-roller
 
Kingunit's Avatar
 
Join Date: Dec 2010
Location: The Netherlands
Posts: 1,426
Reputation: 120
Default Re: Messages only for Administrators

The stock already worked. Thank you.
__________________
Kingunit is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Administrators Base By Amator (Los Santos) Amator Filterscripts 16 30/09/2011 09:54 PM
For all SAMP administrators. Max_Coldheart General 11 29/06/2011 12:27 PM
[FilterScript] P-Messages [Random Messages system] Pooh7 Filterscripts 5 30/11/2010 04:43 PM


All times are GMT. The time now is 07:53 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.