[Simple]How to Send Messages only to specific team -
xMCx - 06.12.2012
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
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!
Re: [Simple]How to Send Messages only to specific team -
gtakillerIV - 06.12.2012
Not bad, but you could've explain abit more, other than that good job.
Re: [Simple]How to Send Messages only to specific team -
[D]ry[D]esert - 06.12.2012
Good job. it will be good for newbies.
Re: [Simple]How to Send Messages only to specific team -
iSaad - 06.12.2012
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 ?
Re: [Simple]How to Send Messages only to specific team -
gtakillerIV - 06.12.2012
Why use Foreach when you can use the normal loop? Seriously come on..
Re: [Simple]How to Send Messages only to specific team -
iSaad - 06.12.2012
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 ...
Re: [Simple]How to Send Messages only to specific team -
x96664 - 06.12.2012
Not bad !
Re: [Simple]How to Send Messages only to specific team -
xMCx - 06.12.2012
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
Re: [Simple]How to Send Messages only to specific team -
iSaad - 07.12.2012
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.
Re: [Simple]How to Send Messages only to specific team -
RajatPawar - 07.12.2012
Goddamn it, each scripter has his own choice, and a good job. Quite easy