[Tutorial] How to make an Admin/Team Chat
#1

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
Reply


Messages In This Thread
How to make an Admin/Team Chat - by Vanter - 18.02.2014, 11:02

Forum Jump:


Users browsing this thread: 1 Guest(s)