Problem with team chat
#1

Hello,i've done this code for the team chat:

pawn Код:
if(text[0] == ';')
    {
        new nameee[24];
        new string[256];
        GetPlayerName(playerid,nameee,sizeof nameee);
        if( gTeam[playerid] == TEAM_USA)
        {
            GetPlayerName(playerid,nameee,sizeof(nameee));
            format(string,sizeof(string),"Usa Team Chat: [%i](%s): %s",playerid,nameee,text[1]);
            SendClientMessageToAll(COLOR_LIGHTRED, string);
            TeamChatLog(string);
        }
        if( gTeam[playerid] == TEAM_GERMANY)
        {
            GetPlayerName(playerid,nameee,sizeof(nameee));
            format(string,sizeof(string),"Germany Team Chat: [%i](%s): %s",playerid,nameee,text[1]);
            SendClientMessageToAll(COLOR_LIGHTRED, string);
            TeamChatLog(string);
        }
        if( gTeam[playerid] == TEAM_RUSSIA)
        {
            GetPlayerName(playerid,nameee,sizeof(nameee));
            format(string,sizeof(string),"Russia Team Chat: [%i](%s): %s",playerid,nameee,text[1]);
            SendClientMessageToAll(COLOR_LIGHTRED, string);
            TeamChatLog(string);
        }
        if( gTeam[playerid] == TEAM_JAPAN)
        {
            GetPlayerName(playerid,nameee,sizeof(nameee));
            format(string,sizeof(string),"Japan Team Chat: [%i](%s): %s",playerid,nameee,text[1]);
            SendClientMessageToAll(COLOR_LIGHTRED, string);
            TeamChatLog(string);
            return 0;
        }
    }
It's OnPlayerText.

I've 2 problems.

The first,when i do like ;test - It sends the message in the normal chat and in the team chat,so double messages.

The second,every team can see the team chat.Ex: If i'm team japan,i can see russia team chat,usa team chat and so on,same with other teams.

What's wrong?
Reply
#2

change the return of OnPlayerText to 0 instead of 1
do that if your OnPlayerText are return to 1
Reply
#3

the chat can be seen by all, simply because you use SendClientMessageToAll
try this
pawn Код:
if(text[0] == ';')
    {
        new nameee[24];
        new string[256];
        GetPlayerName(playerid,nameee,sizeof nameee);
        if( gTeam[playerid] == TEAM_USA)
        {
            GetPlayerName(playerid,nameee,sizeof(nameee));
            format(string,sizeof(string),"Usa Team Chat: [%i](%s): %s",playerid,nameee,text[1]);
        }
        else if( gTeam[playerid] == TEAM_GERMANY)
        {
            GetPlayerName(playerid,nameee,sizeof(nameee));
            format(string,sizeof(string),"Germany Team Chat: [%i](%s): %s",playerid,nameee,text[1]);
        }
        else if( gTeam[playerid] == TEAM_RUSSIA)
        {
            GetPlayerName(playerid,nameee,sizeof(nameee));
            format(string,sizeof(string),"Russia Team Chat: [%i](%s): %s",playerid,nameee,text[1]);
        }
        else if( gTeam[playerid] == TEAM_JAPAN)
        {
            GetPlayerName(playerid,nameee,sizeof(nameee));
            format(string,sizeof(string),"Japan Team Chat: [%i](%s): %s",playerid,nameee,text[1]);
        }
        foreach(Player,i)
        {
               if(gTeam[i] == gTeam[playerid])
               {
                  SendClientMessage(i,COLOR_LIGHTRED, string);
                 TeamChatLog(string);
               }
        }
        return 0;
    }
if you dont use foreach replace it with for(new i=0; i<MAX_PLAYERS; i++)
Reply
#4

Thanks,working.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)