[Tutorial] [TUT] [RCON USAGE] : Admin Chat ;)
#1

Hope this will help you
O.K. First Of All This is a detailed Tutorial, everything riped in parts ! so if youre a total beginner this should help you too!

O.K. First Start PAWN Scripter in : YourSampServerDirectory/pawno/pawno.exe [INFO : if youre a vista/win 7 user you must rightclick -> Run As Administrator]
[WARRNING : please use samp 0.3a and the samp 0.3a server files or else you might get some errors!]
now press the "New" Icon or : Files -> New
now select all and delete it by pressing backspace or rightclicking the selected and delete .

First lets start with the basic but verry important line ( this declears that we will use SAMP functions witch include all : a_file.inc ... ) :
Put this at the beginning after nothing is writen in the editor :
pawn Код:
#include <a_samp>
also after this declare these things [ VERRY IMPORTANT ] :
pawn Код:
#define red 0xFF0000AA
put that after the #include <a_samp> line!

after that add this at our last line :
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '$' && IsPlayerAdmin(playerd)) {
      new string[128]; GetPlayerName(playerid,string,sizeof(string));
        format(string,sizeof(string),"Admin Chat: %s: %s",string,text[1]); SendMessageToRAdmins(red,string);
      return 0;
}
now lets split this!

pawn Код:
if (text[0] == '$')
this checks if we use $ at the lenght : 0 that means on the begining if $ stands do the next thing :
pawn Код:
new string[128]; GetPlayerName(playerid,string,sizeof(string));
format(string,sizeof(string),"Admin Chat: %s: %s",string,text[1]); SendMessageToRAdmins(red,string);
new = create a new varible/string/bool
the name we set is : string it can be truly anything!
GetPlayerName =
this will compress a players name witch is : "playerid" in the OnPlayerText(playerid, text);
string is the varible or string that were gonna use .
sizeof(string) = we need the maximum length for the formation of "string" , so we ask to recive string's max length !
in this case : [128] is our max lenghtright there!
O.K. lets move on .
format is proccesing a formation of a var / string !
so it formats string and the same thing like GetPlayerName ! now this "Admin Chat: %s: %s" the %s is for : replace this with folowing string . %d is : replace this with folowing declaration . %i is : replace this with folowing integer ( number ) .
but how it knows what string ? here :
pawn Код:
string,text[1]
so the first replace is : string, the second is the text we wrote from the lenght 1 and later on . so $ wont be added .
now this a important part but doesnt actually mater to explain it...maybe some other time..sorry..
ok..after you copied the full code :
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '$' && IsPlayerAdmin(playerd)) {
      new string[128]; GetPlayerName(playerid,string,sizeof(string));
        format(string,sizeof(string),"Admin Chat: %s: %s",string,text[1]); SendMessageToRAdmins(red,string);
      return 0;
}
and after that this code ( because SendMessageToRAdmins doesnt exist yet ^^ ) :
pawn Код:
stock SendMessageToRAdmins(color,const msg[])
{
   for (new i=0; i<MAX_PLAYERS; i++)
   {
      if (IsPlayerConnected(i) && IsPlayerAdmin(i)) SendClientMessage(i,color,msg);
   }
}
congratulations youve made it!

but if you want to add it in the script dont delete all!

full pawn code :
pawn Код:
#include <a_samp>
#define red 0xFF0000AA

public OnPlayerText(playerid, text[])
{
    if(text[0] == '$' && IsPlayerAdmin(playerd)) {
      new string[128]; GetPlayerName(playerid,string,sizeof(string));
        format(string,sizeof(string),"Admin Chat: %s: %s",string,text[1]); SendMessageToRAdmins(red,string);
      return 0;
}

stock SendMessageToRAdmins(color,const msg[])
{
   for (new i=0; i<MAX_PLAYERS; i++)
   {
      if (IsPlayerConnected(i) && IsPlayerAdmin(i)) SendClientMessage(i,color,msg);
   }
}
hope it helped you!


Reply


Messages In This Thread
[TUT] [RCON USAGE] : Admin Chat ;) - by Micko9 - 17.03.2010, 21:20
Re: [TUT] [RCON USAGE] : Admin Chat ;) - by Lorenc_ - 11.04.2010, 00:52
Re: [TUT] [RCON USAGE] : Admin Chat ;) - by ruckfules99 - 11.04.2010, 02:23
Re: [TUT] [RCON USAGE] : Admin Chat ;) - by Lorenc_ - 11.04.2010, 04:02
Re: [TUT] [RCON USAGE] : Admin Chat ;) - by Micko9 - 11.04.2010, 18:42
Re: [TUT] [RCON USAGE] : Admin Chat ;) - by Torran - 11.04.2010, 18:44
Re: [TUT] [RCON USAGE] : Admin Chat ;) - by ruckfules99 - 11.04.2010, 18:44
Re: [TUT] [RCON USAGE] : Admin Chat ;) - by Amit_B - 11.04.2010, 19:19
Re: [TUT] [RCON USAGE] : Admin Chat ;) - by Steven82 - 12.04.2010, 00:19
Re: [TUT] [RCON USAGE] : Admin Chat ;) - by Torran - 12.04.2010, 06:32

Forum Jump:


Users browsing this thread: 1 Guest(s)