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

Cool nice tutuorial
Reply
#3

Seems like your a really good scripter. Please help?


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


nice tut.
Reply
#4

Who?
Reply
#5

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 .
Reply
#6

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
Reply
#7

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
Reply
#8

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 - }
Reply
#9

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


Код:
/rcon say
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)