[Tutorial] [Simple]How to Send Messages only to specific team
#1

The Beginning:
Hello , this is me again with another simple tutorial, today im explaining how to send messages to specific team/kind of
players that you cant do it with
pawn Код:
SendClientMessage
Function.

So lets start , with sending a message to/between admins . so they can only see it.
now forward a new function that called AdminMessage(color,string[])
color : is the color of the message
string: is the string that we want to send.
forwarding is to declare a new function
pawn Код:
forward AdminMessage(color,string[]);// add this on the top of your script[under includes ofc] or before the public version
now lets make the public version of it:
pawn Код:
public AdminMessage(color,string[])// we dont need line ender here ';'
now we are going to loop through the player, so to know who is the online admin from the players.
pawn Код:
public AdminMessage(color,string[])
{//a
        for(new i = 0; i < MAX_PLAYERS; i++)// i = the players.
    {//b
                 if(IsPlayerConnected(i))//we are using this function to check if the i(player) is online or not
        {//c
                        if (IsPlayerAdmin(i))//this function used to condition that i(player) have to be admin
            {//d
                         SendClientMessage(i, color, string);/*
                        now if the all conditions are true , the message going to be sent to the admins ,
                        SendClientMessage = to send a Message , i = the player , which now is an admin ,
                        color = the color of the message , string = the string that is going to be sent to the admins.
                        now this function will be included under a command or else , without a timer.
                        */

                        }//d
                   }//c
          }//b
          return 1;
}//a
and we are done ! , the function is now ready, but wait , ill give u an example of how to use it!
under OnPlayerConnect function add this:
pawn Код:
public OnPlayerConnect(playerid)
{
    new pname[MAX_PLAYER_NAME],//the player name of its size (24)
        string[128];//declaring a string with size of 128
    GetPlayerName(playerid,pname,sizeof(pname));//getting it
    format(string,128,"*'%s' Has Connected!",pname);//formating the message
    AdminMessage(-1, string);//sending it to admins!, -1 = the color , string = the sent string
    return 1;
}
Finishing:
and we are done , hope you learnt something today, if you didnt get something just reply and ill do my best
to help, thanks!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)