SA-MP Forums Archive
Team 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)
+--- Thread: Team Chat (/showthread.php?tid=319381)



Team Chat - SpiderWalk - 18.02.2012

Hello everybody.I tryed all type of codes for Team Chat But not working anyone got any idea??


Re: Team Chat - Nonameman - 18.02.2012

I hope it will be useful for you:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (text[0] == '@') {
        text[0] = ' ';
        new msg[128], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(msg, sizeof(msg), "[Team][%s]:%s", pName, text);
        for (new i = 0; i < GetMaxPlayers(); i++) {
            if (GetPlayerTeam(playerid) == GetPlayerTeam(i))
                SendPlayerMessageToPlayer(i, playerid, msg);
        }
        return 0;
    }
    return 1;
}



Re: Team Chat - SpiderWalk - 19.02.2012



Here is picture how its looks when i did wha Nonameman give me.I dont know how to fix that....


Re: Team Chat - vassilis - 19.02.2012

this is what i am using for team chat:
it will work surely :

pawn Код:
new string[256];
  new playername[MAX_PLAYER_NAME];
  if(text[0] == '!' && text[1] != 0)
  {
    GetPlayerName( playerid, playername, MAX_PLAYER_NAME );
    format( string, 128, "[Team-Chat] %s: %s", playername, text[1] );
    for(new i = 0; i < MAX_PLAYERS; i++ )
    {
      if( IsPlayerConnected(i) && gTeam[playerid] == gTeam[i] )
        SendClientMessage( i, COLOR_YELLOW, string );
    }
    return 0;
    }



Re: Team Chat - SpiderWalk - 19.02.2012

Quote:
Originally Posted by vassilis
Посмотреть сообщение
this is what i am using for team chat:
it will work surely :

pawn Код:
new string[256];
  new playername[MAX_PLAYER_NAME];
  if(text[0] == '!' && text[1] != 0)
  {
    GetPlayerName( playerid, playername, MAX_PLAYER_NAME );
    format( string, 128, "[Team-Chat] %s: %s", playername, text[1] );
    for(new i = 0; i < MAX_PLAYERS; i++ )
    {
      if( IsPlayerConnected(i) && gTeam[playerid] == gTeam[i] )
        SendClientMessage( i, COLOR_YELLOW, string );
    }
    return 0;
    }
Huh finaly working rep++


Re: Team Chat - vassilis - 19.02.2012

Quote:
Originally Posted by SpiderWalk
Посмотреть сообщение
Huh finaly working rep++
Haha no problem.


Re: Team Chat - Nonameman - 19.02.2012

Quote:
Originally Posted by vassilis
Посмотреть сообщение
this is what i am using for team chat:
it will work surely :

pawn Код:
new string[256];
  new playername[MAX_PLAYER_NAME];
  if(text[0] == '!' && text[1] != 0)
  {
    GetPlayerName( playerid, playername, MAX_PLAYER_NAME );
    format( string, 128, "[Team-Chat] %s: %s", playername, text[1] );
    for(new i = 0; i < MAX_PLAYERS; i++ )
    {
      if( IsPlayerConnected(i) && gTeam[playerid] == gTeam[i] )
        SendClientMessage( i, COLOR_YELLOW, string );
    }
    return 0;
    }
Idk why I used SendPlayerMessageToPlayer(), thanks for fixing it.