Team chat being displayed to others..
#1

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;

Reply
#2

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
Reply
#3

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.
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)