[Tutorial] [Tutorial] Simple Group Chat
#1



So for over the past couple weeks of me being back, I have been hounded with a few people asking me constantly to release some of my small codes for chats etc. This will be a very short tutorial in how to explain how to make a small group chat system.

Remember you can edit this to use with whatever group you want

Step One:
Your first step may be quite easy but it is where alot of people, especially new coders get stuck. So what you want to do, is start by making a basically a public function that revolves around a string format.
Code:
forward AdminMessage(color, const string, level);
public AdminMessage(color, const string, level)
{
You then want to get all the players that are within the server by using this line next
Code:
for(new i = 0; i < MAX_PLAYERS; i++)
{
You then want to check if the player is connected who will be using the command at that time and also check if they are an Admin or whatever Variable you want them to be apart of

Code:
          if(IsPlayerConnected(i))
          {
	       if(IsPlayerAdmin(playerid))
	       {
		          SendClientMessage(i, color, string);
So your whole public and forward function will look like this
Code:
forward AdminMessage(color, const string, level);
public AdminMessage(color, const string, level)
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(IsPlayerAdmin(playerid))
			{
				SendClientMessage(i, color, string);
			}
		}
	}
	return 1;
}
Now you have done Step one, you will now be able to put Step two into your code to be able to format the text or message you want everyone in that variable to see.
Code:
new string1[256];
format(string1,sizeof(string1),"{FF0033}((Adminstrator %s: %s))", //YourRoleplayNameFunctionHere//, params);
AdminMessage(-1, string1,1);
So this is a little code line from my script, that uses and admin chat system for this feature. Very nice and simple. Plus very fast processing aswell.
Code:
CMD:a(playerid, params[])
{
	if(IsPlayerConnected(playerid))
	{
	    new string20[256];
	    if(PlayerInfo[playerid][pAdmin] >= 1)
	    {
	        if(isnull(params))
	        {
	            SendClientMessage(playerid,-1,"{FFA500}[Server]: {FFFFFF}/a [admin chat text]");
	        }
	        else
	        {
	            format(string20,sizeof(string20),"{FF0033}((Adminstrator %s: %s))", RPName(playerid), params);
				AMSG(-1, string20,1);
	        }
	    }
	    else
		{
		    SendClientMessage(playerid,-1,"{CC3399}[Error]: {FFFFFF}You do not have a high enough admin rank");
	    }
	}
	return 1;
}
Reply


Messages In This Thread
[Tutorial] Simple Group Chat - by Ciandlah - 02.09.2018, 10:21
Re: [Tutorial] Simple Group Chat - by Calisthenics - 02.09.2018, 10:42
Re: [Tutorial] Simple Group Chat - by Ciandlah - 02.09.2018, 11:49
Re: [Tutorial] Simple Group Chat - by Eoussama - 02.09.2018, 12:22
Re: [Tutorial] Simple Group Chat - by RogueDrifter - 02.09.2018, 14:33
Re: [Tutorial] Simple Group Chat - by CaptainBoi - 02.09.2018, 14:35
Re: [Tutorial] Simple Group Chat - by Eoussama - 02.09.2018, 14:38
Re: [Tutorial] Simple Group Chat - by CaptainBoi - 02.09.2018, 14:54
Re: [Tutorial] Simple Group Chat - by Eoussama - 02.09.2018, 15:05
Re: [Tutorial] Simple Group Chat - by Lokii - 02.09.2018, 15:32

Forum Jump:


Users browsing this thread: 1 Guest(s)