06.03.2011, 10:25
A better way to do teamchat (IMO) would be using OnPlayerText something like this,
To use team chat just type #hello team. Anything after hash '#' gets send to players on the same team of the sender.
pawn Код:
public OnPlayerText(playerid, text[])
{
if(text[0] == '#')
{
new
s[MAX_PLAYER_NAME],
team = GetPlayerTeam(playerid);
GetPlayerName(playerid, s, MAX_PLAYER_NAME);
format(text, 128,"[TEAMCHAT] %s: %s", s, text[1]);
for(new i; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i))continue;
if(GetPlayerTeam(i) == team)//if you use a "gTeam" type var use that ie, if(gTeam[i] == gTeam[playerid])
SendClientMessage(i,0x00D7FFFF, text);
}
return 0;
}
return 1;
}