SA-MP Forums Archive
Problem with 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: Problem with team chat (/showthread.php?tid=348411)



Problem with team chat - Face9000 - 05.06.2012

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?


Re: Problem with team chat - JaKe Elite - 05.06.2012

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


Re: Problem with team chat - HuSs3n - 05.06.2012

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++)


Re: Problem with team chat - Face9000 - 05.06.2012

Thanks,working.