[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
#2

Not bad, but you could've explain abit more, other than that good job.
Reply
#3

Good job. it will be good for newbies.
Reply
#4

No it would be bad for newbies, as i always say "Tutorials" should contain the latest scripting methods,
so you are using normal loops instead of using foreach.

Edit: And why not using a stock ?
Reply
#5

Why use Foreach when you can use the normal loop? Seriously come on..
Reply
#6

Quote:
Originally Posted by gtakillerIV
Посмотреть сообщение
Why use Foreach when you can use the normal loop? Seriously come on..
Yes SERIOUSLY! why use normal loops when there is foreach ? come on seriously ...
Reply
#7

Not bad !
Reply
#8

thanks all ,
but if you didnt learn how to make and to understand the normal loops
how would you understand foreach? and about the stock
you can make this in many ways , iam explaining a simple one thats all ,
but thanks for your comment
Reply
#9

Quote:
Originally Posted by xMCx
Посмотреть сообщение
thanks all ,
but if you didnt learn how to make and to understand the normal loops
how would you understand foreach? and about the stock
you can make this in many ways , iam explaining a simple one thats all ,
but thanks for your comment
foreach is easy there is nothing in it that is difficult to understand.
Reply
#10

Goddamn it, each scripter has his own choice, and a good job. Quite easy
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)