SA-MP Forums Archive
Help me about 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: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help me about chat (/showthread.php?tid=96842)



Help me about chat - xCoder - 11.09.2009

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

xCoder[Attack]: Hey!

Or id

xCoder[0]: Hey!


Re: Help me about chat - Anwix - 11.09.2009

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.


Re: Help me about chat - xCoder - 11.09.2009

Oh THX


Re: Help me about chat - Abernethy - 11.09.2009

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


Re: Help me about chat - Correlli - 11.09.2009

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;
}



Re: Help me about chat - Zeex - 11.09.2009

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?


Re: Help me about chat - saiberfun - 11.09.2009

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


Re: Help me about chat - Correlli - 11.09.2009

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.