SA-MP Forums Archive
[Tutorial] [TUT] [RCON USAGE] : Admin Chat ;) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] [TUT] [RCON USAGE] : Admin Chat ;) (/showthread.php?tid=134865)



[TUT] [RCON USAGE] : Admin Chat ;) - Micko9 - 17.03.2010

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!





Re: [TUT] [RCON USAGE] : Admin Chat ;) - Lorenc_ - 11.04.2010

Cool nice tutuorial



Re: [TUT] [RCON USAGE] : Admin Chat ;) - ruckfules99 - 11.04.2010

Seems like your a really good scripter. Please help?


http://forum.sa-mp.com/index.php?topic=166218.0


nice tut.


Re: [TUT] [RCON USAGE] : Admin Chat ;) - Lorenc_ - 11.04.2010

Who?


Re: [TUT] [RCON USAGE] : Admin Chat ;) - Micko9 - 11.04.2010

Quote:
Originally Posted by ruckfules99
Seems like your a really good scripter. Please help?


http://forum.sa-mp.com/index.php?topic=166218.0


nice tut.
sorry for the late answer but please post it in the Script REquest thread . Not here .


Re: [TUT] [RCON USAGE] : Admin Chat ;) - Torran - 11.04.2010

Quote:
Originally Posted by Micko9
Quote:
Originally Posted by ruckfules99
Seems like your a really good scripter. Please help?


http://forum.sa-mp.com/index.php?topic=166218.0


nice tut.
sorry for the late answer but please post it in the Script REquest thread . Not here .
He's not requesting, He wants help


Re: [TUT] [RCON USAGE] : Admin Chat ;) - ruckfules99 - 11.04.2010

Quote:
Originally Posted by Micko9
Quote:
Originally Posted by ruckfules99
Seems like your a really good scripter. Please help?


http://forum.sa-mp.com/index.php?topic=166218.0


nice tut.
sorry for the late answer but please post it in the Script REquest thread . Not here .
I'm not requesting a script. I'm askin for help.

EDIT: Lol Joe answered before me :P


Re: [TUT] [RCON USAGE] : Admin Chat ;) - Amit_B - 11.04.2010

Nice

But you have a mistake in the 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;
}
You've forgot the closer of the 'if' condition - }


Re: [TUT] [RCON USAGE] : Admin Chat ;) - Steven82 - 12.04.2010

why should we use this, if there is already a built in admin system chat


Код:
/rcon say



Re: [TUT] [RCON USAGE] : Admin Chat ;) - Torran - 12.04.2010

Quote:
Originally Posted by Steven82
why should we use this, if there is already a built in admin system chat


Код:
/rcon say
I dont think you understand what Admin chat is?
This tutorial shows you how to make admin chat.. We all know that,
Admin chat is where admins of the server (RCON In This Case) can put a command/symbol before there text,
And it will send whatever they type to ADMINS only, And will only work for admins