[Tutorial] How To Create Two Types Admin Chat.[Helpful to Newbies]
#1

Hello There Guys,
I made this Tutorial For Newbie Scripters to Get Help in Making Two Types Of A.chat.
I have seen many made Two type of a.chat like JuniorAdminChat and SeniorAdminChat etc. but they had Problem that Even Junior Admin Can see Senior Admin Chat. But Of course He can't Use it because we had Set Level of Usage of Admin Chat to Higher Then Junior Admin Chat.
So, here we Start
Creating Junior Admin Chat STEP BY STEP


STEP 1


We Will Make Junior Admin Chat First.
For Junior Admin Chat
First We will make The text for Using Junior Admin Chat.

We will Write The Following Code Under OnPlayerText(playerid, text[])

pawn Code:
if(text[0] == '.' && PlayerInfo[playerid][Level] > 1) //You Can Change '.' to any text you want example: '#' '!' '*' and etc.
We have Used ( . ) for using Junior Admin Chat.

STEP 2


Now We will make a Function which will Loop Through All Players To Check if The User which Used Junior Admin Chat is Connected or Not.

Now after you Add above Code. Add The Following Ones.
pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) // This will Loop Through All The Connected Players To check that if User of Junior Admin Chat is Connected Or NOT!
Now we have Added The Text to use admin chat and added The Function To Check if User is Connected or Not.

STEP 3


This time we will make at Which Level Can Junior Admin Chat Can be used.
so For this we need to write the Following Code:

pawn Code:
if(PlayerInfo[playerid][Level] > 1) // This Will Check if That Player's Level is Equal Or Greater Then level 1
Ok Now We Have Successfully Added Text, PlayerConnected Check Function and Assigned the level.

STEP 4


Its time to make the Chat Function!
for this we need to make New string and the Playername.
pawn Code:
new string[128], GetPlayerName(playerid, string, sizeof(string));
Okay now We have added this Too.
Now we will make the chat
See the Following Code
pawn Code:
format(string, sizeof(string),"JuniorAdminChat %s: %s",string, text[1]); //First %s is for the Admin Name second %s is The Text he write.
MessageToJuniorAdmins(green, string); //You Can Choose any Color You want for Admin Chat. Just change green to any color.
return 0;
}
Here we complete the Junior Admin Chat
LAST STEP


Now We will Add Callback for MessageToJuniorAdmins
type the following code at End of Your Script.
pawn Code:
public MessageToJuniorAdmins(color, const, string[])
{
       for(new i = 0; i < MAX_PLAYERS; i++}
       {
       if(IsPlayerConnected(i) == 1)
       if(PlayerInfo[playerid][Level] > 1) //Level You have Assigned for This Chat
       SendClientMessage(i, color, string)
       }
       return 1;
}
and Add Following At the Top of your Script
pawn Code:
forward MessageToJuniorAdmins(color, const, string[])
Here is the Proper Code of Junior Admin Chat.
pawn Code:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '.' && PlayerInfo[playerid][Level] >= 1)
    {
        new string[128]; GetPlayerName(playerid,string,sizeof(string));
        format(string,sizeof(string),"JuniorAdminChat: %s: %s",string,text[1]);
        MessageToJuniorAdmins(green,string);
        return 0;
    }
NOTE: For Senior admin Chat you need to Perform Same Function by Just Changing MessageToJuniorAdmins to MessageToSeniorAdmins and The levels. + The text JuniorAdminChat to SeniorAdminChat

Thank You For Reading The Tutorial. I Hope it would Helped You a Bit
Reply
#2

good 6/10
Reply
#3

You should explain a bit more.
Reply
#4

Not to be naughty, but you shoulden't use caps on almost every word. Good tutorial
Reply
#5

Good Work!

+REP my friend great work so helpful for newbies and scripters who wants to script admin system
Reply
#6

Good tutorial.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)