Help me about chat
#1

Hi I have 4 team and i want something!
If team attack onplayertext:

xCoder[Attack]: Hey!

Or id

xCoder[0]: Hey!
Reply
#2

You could try something like:

Код:
public OnPlayerText(playerid, text[])
{
	new string[256], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	if (gTeam[playerid] == TEAM_ATTACK)
	{
	  format(string, sizeof(string), "%s[Attack]: %s", name, text[]);
	  SendClientMessageToAll(COLOR_WHITE, string);
	}
	else if (gTeam[playerid] == TEAM_DEFENCE)
	{
 		format(string, sizeof(string), "%s[Defence]: %s", name, text[]);
 		SendClientMessageToAll(COLOR_WHITE, string);
	}
	return false;
}
Untested.
Reply
#3

Oh THX
Reply
#4

I think you might need to loop through all the players to check what team they're on though. Not sure.
Reply
#5

Anwix, your code is very bad and it won't work.

Use this:
pawn Код:
public OnPlayerText(playerid, text[])
{
  new string[128], name[MAX_PLAYER_NAME];
  GetPlayerName(playerid, name, sizeof(name));
  if(gTeam[playerid] == TEAM_ATTACK)
  {
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if(gTeam[i] == gTeam[playerid])
      {
        format(string, sizeof(string), "%s [Attack]: %s", name, text);
        SendClientMessage(i, COLOR_WHITE, string);
      }
    }
  }
  else if(gTeam[playerid] == TEAM_DEFENCE)
  {
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if(gTeam[i] == gTeam[playerid])
      {
        format(string, sizeof(string), "%s [Defence]: %s", name, text);
        SendClientMessage(i, COLOR_WHITE, string);
      }
    }
  }
  return 0;
}
Reply
#6

Quote:
Originally Posted by Don Correlli
Anwix, your code is very bad and it won't work.
Why?
And he didn't said that messages should be shown only to player's team mates. If even so, how do you think if they need to see "[Attacker]" tag?
Reply
#7

Quote:
Originally Posted by Don Correlli
Anwix, your code is very bad and it won't work.
yo don he didnt say he wants TeamChat like in only taqlk to sdum1#
he said he wants to display what team the ppl are of
Reply
#8

Quote:
Originally Posted by ZeeX
Quote:
Originally Posted by Don Correlli
Anwix, your code is very bad and it won't work.
Why?
Because he used text[] instead of text:
Quote:
Originally Posted by Anwix
Код:
format(string, sizeof(string), "%s[Attack]: %s", name, text[]);
Quote:
Originally Posted by SaiBerFun
yo don he didnt say he wants TeamChat like in only taqlk to sdum1#
he said he wants to display what team the ppl are of
Sorry, i didn't really got his question.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)