SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 18/02/2014, 11:02 AM   #1
Vanter
Huge Clucker
 
Vanter's Avatar
 
Join Date: Jul 2013
Posts: 391
Reputation: 16
Default How to make an Admin/Team Chat

What is this tutorial? Making a public for a team or admins, or whatever you want, suit it for yourself.

What will we use? We're going to use public admins this time, notes for teams been added.

Here we go
First, we'll define the color we're using for admin messages, team chat.
and also the DCMD command processor.
PHP Code:
//Defining colors
#define                   COLOR_YELLOW                  0xFFFF00AA
#define                   COLOR_RED                     0xFF0000AA

//Defining DCMD
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 
Now, we're going to create the public we're going to use
PHP Code:
forward SendAdminMessage(colorstring[]);  //defining the public
public SendAdminMessage(colorstring[]) //calling the public
{
    for(new 
0MAX_PLAYERSi++) //looping through all players
    
{
        if(
IsPlayerConnected(i)) //check if he's connected
        
{
             if(
IsPlayerAdmin(i)) //checking if the player is rcon connected, (you can edit it to fit your script, ex: (PlayerInfo[playerid][pAdmin] > 5) --- You can also edit this to make it "if(gTeam[i] == TEAM_EXAMPLE)
            
{
                
SendClientMessage(iCOLOR_YELLOWstring); //Sending the text to all admins, with the color we define.
            
}
        }
    }

Then now we create the command.
PHP Code:
public OnPlayerCommandText(playeridcmdtext[]) //Whenever someone types a command
{
     if(
IsPlayerAdmin(playerid)) //If player is RCON connected, edit it to fit your own.
     
{
         
dcmd(ac,2,cmdtext); //defining the command to pawn.
     
}
     return 
1;

Now, we call the command
PHP Code:
dcmd_ac(playerid,params[])
{
    new 
string[128];  //creating the string we're gonna use
    
new pname[MAX_PLAYER_NAME]; //getting definition of the player username.
    
GetPlayerName(playerid,pname,sizeof(pname)); //putting the playername in shortcut = pname.
    
if(!strlen(params)) //if the player types (/ac) only
    
{
        
SendClientMessage(playerid,COLOR_RED,"(Error) /ac (Message)"); //edit this if you want to
        
return 1;
    }
    
format(string,sizeof(string),"[ADMIN CHAT] Admin %s(%d): %s",pname,playerid,params); //formatting the command into (string)
    
SendAdminMessage(COLOR_YELLOW,string); //Sending string to all admins online as we defined in (public SendAdminMessage)
    //IRC_GroupSay(gGroupID,IRC_ADMINCHANNEL,string); //Use this if you have IRC plugin installed with your ADMINCHANNEL.
    
return 1;

What is DCMD? It's a command processor which is defined by the line we posted above.

I hope this helps you creating private chats for admins and teams.

Thank You,
Vanter
Vanter is offline   Reply With Quote
Reply

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
[Tutorial] How to make Team Chat bustern Tutorials 13 17/12/2014 01:39 PM
How to make Team Chat? NinjahZ Scripting Help 16 09/08/2013 12:28 AM
How to make a team chat? rangerxxll Scripting Help 8 11/03/2012 10:07 PM
How to make a Group/Team Chat? HydraX Scripting Help 7 01/02/2012 02:08 PM
How to make team chat? Player63 Help Archive 1 06/06/2010 12:22 PM


All times are GMT. The time now is 02:05 AM.


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