SA-MP Forums Archive
Team chat being displayed to others.. - 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 being displayed to others.. (/showthread.php?tid=379445)



Team chat being displayed to others.. - Twinklies - 21.09.2012

Everyone can see the team chat when I enter message... It displays like "@Test" it sends msg to all and to team too.
PHP код:
new ChatText[128], Nameasd[MAX_PLAYER_NAME];
    
GetPlayerName(playeridNameasdMAX_PLAYER_NAME);
    
format(ChatTextsizeof(ChatText),"%s %s: %s"RankNameasdtext);
    
SendClientMessageToAll(-1ChatText);
    if(
text[0] == '@')
    {
        new 
string[128];
        
GetPlayerName(playeridstringsizeof(string));
        
format(stringsizeof(string), "[Team] %s: %s"stringtext[1]);
        for(new 
0MAX_PLAYERSi++)
        {
               if(
IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(iGetPlayerColor(playerid), string);
        }
        return 
0;
    }
    return 
1;




AW: Team chat being displayed to others.. - Nero_3D - 21.09.2012

Look at your code...

First you send the message to all, line 4 (in your code block)
And than you send it afterwards to all team members, line 5 - 15

Dont ask us now how to fix that, thats as easy as pie


Re: Team chat being displayed to others.. - clarencecuzz - 22.09.2012

pawn Код:
public OnPlayerText(playerid, text[])
{
    new Nameasd[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Nameasd, MAX_PLAYER_NAME);
    if(text[0] != '@')
    {
        new ChatText[128];
        format(ChatText, sizeof(ChatText),"%s %s: %s", Rank, Nameasd, text);
        SendClientMessageToAll(-1, ChatText);
    }
    else if(text[0] == '@')
    {
        new string[128];
        GetPlayerName(playerid, string, sizeof(string));
        format(string, sizeof(string), "[Team] %s: %s", string, text[1]);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(gTeam[i] == gTeam[playerid])
                {
                    SendClientMessage(i, GetPlayerColor(playerid), string);
                }
            }
        }
    }
    return 0;
}
You're just getting a little confused with how the code is actually working. Examine this and try and understand how it's working.


Re: Team chat being displayed to others.. - Twinklies - 22.09.2012

Thanks for the help guys. I understand now. Thanks! +rep