[UNSOLVED]team chat isn't working
#1

When i am typing #hello it just says in main chat: FuTuRe(0): #hello instead of [Team Chat]FuTuRe(0): hello

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128], tmpname[MAX_PLAYER_NAME];
    if(text[0] == '#')
        {
      GetPlayerName(playerid, tmpname, sizeof(tmpname));
            if(gTeam[playerid] == TEAM_MEDIC)format(string, sizeof(string), "[Team Chat]%s(%d): %s", tmpname,playerid, text[1]); // Specify which gTeams you need this for.
          if(gTeam[playerid] == TEAM_COP)format(string, sizeof(string), "[Team Chat]%s(%d): %s", tmpname,playerid, text[1]); // Specify which gTeams you need this for.   for(new i = 0; i < MAX_PLAYERS; i++)
            {
              for(new i=0;i<MAX_PLAYERS;i++)
              {
                    if(IsPlayerConnected(i) && GetPlayerTeam(i) == GetPlayerTeam(playerid)) SendClientMessage(i, oranje, string);
                    return 0;
                }
             }
            return 0;
        }
    return 0;
}
Reply
#2

updated code
Reply
#3

Quote:
Originally Posted by `FuTuRe-
pawn Код:
if(text[0] == '#')
Heyho.
I made it a other way. Maybe use this, cuz its working with me (i did same as you did XD):
pawn Код:
if(strfind(text, "#", true)==0)
Cheers!
Reply
#4

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '#')
    {
        if(gTeam[playerid] == TEAM_MEDIC || gTeam[playerid] == TEAM_COP)
        {
          new string[128], tmpname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, tmpname, sizeof(tmpname));
            format(string, sizeof(string), "[Team Chat]%s(%d): %s", tmpname,playerid, text[1]);

            for(new i=0;i<MAX_PLAYERS;i++)
            {
                if(IsPlayerConnected(i) && GetPlayerTeam(i) == GetPlayerTeam(playerid))
                {
                    SendClientMessage(i, oranje, string);
                }
                return 0;
            }
        }
        return 0;
    }
    return 1;
}
Reply
#5

its because you have

for(new i=0;i<MAX_PLAYERS;i++)


Change it, or else, client message will be sent to all...
Reply
#6

Still not working but i've found the problem. When i unload my admin FS the team chat is working. When it's loaded it's not working


This is the code from my Admin / Account FS
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (pmuted[playerid]== 1 ) return 0;
        new string[256];
        {
        if(text[0] == '@')
        {
          if(pInfo[playerid][level] > 0)
          {
                format(string, sizeof(string), "[Admin Chat] %s(%i): %s", pInfo[playerid][name], playerid, text[1]);

              for(new j = 0; j < MAX_PLAYERS; j++)
                {
                    if(IsPlayerConnected(j) && pInfo[j][level] > 0) SendClientMessage(j, ADMIN, string);
                }
            }
            else SendClientMessage(playerid,oranje,"You aren't admin!");
            return 0;
        }
      new textstring[256];
        format(textstring, sizeof(textstring), "%s(%i): %s", pInfo[playerid][name],playerid, text);
        SendClientMessageToAll(GetPlayerColor(playerid),textstring);
        }
        return 0;
}
And this is the code from the GM self.
pawn Код:
public OnPlayerText(playerid, text[])
{
if(text[0] == '#')
{
if(gTeam[playerid] == TEAM_MEDIC || gTeam[playerid] == TEAM_COP)
{
  new string[128], tmpname[MAX_PLAYER_NAME];
GetPlayerName(playerid, tmpname, sizeof(tmpname));
format(string, sizeof(string), "[Team Chat]%s(%d): %s", tmpname,playerid, text[1]);

for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i) && GetPlayerTeam(i) == GetPlayerTeam(playerid))
{
SendClientMessage(i, oranje, string);
}
return 0;
}
}
return 0;
}
return 1;
}
Reply
#7

If you have
Код:
static gTeam[MAX_PLAYERS];
Then use this :
Код:
public OnPlayerText(playerid, text[])
{
  new string[256];
  new playername[MAX_PLAYER_NAME];
  if(text[0] == '!' && text[1] != 0)
  {
    GetPlayerName( playerid, playername, MAX_PLAYER_NAME );
    format( string, 128, "[Team] %s: %s", playername, text[1] );
    for(new i = 0; i < MAX_PLAYERS; i++ )
    {
      if( IsPlayerConnected(i) && gTeam[playerid] == gTeam[i] )
        SendClientMessage( i, YourColor, string );
    }
    return 0;
  }

  return 1;
}
That should work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)