06.01.2014, 15:43
The above would block text sent by player A and won't reach anyone else because "return 0" blocks the text from that player being sent to the server.
If I get you correctly, you want player A to be unable to see whatever another player says?
Everyone could be chatting along nicely, but you don't want Player A to see all the messages?
Then you can use the same approach (ChatBlocked variable).
Every time a player inputs some text into the chatbox and presses ENTER, OnPlayerText is called.
You can loop through all players and use SendClientMessage to send the text to him if his chat isn't blocked.
And of course, block the inputted text using "return 0", otherwise the text will still be send to all players.
If I get you correctly, you want player A to be unable to see whatever another player says?
Everyone could be chatting along nicely, but you don't want Player A to see all the messages?
Then you can use the same approach (ChatBlocked variable).
Every time a player inputs some text into the chatbox and presses ENTER, OnPlayerText is called.
You can loop through all players and use SendClientMessage to send the text to him if his chat isn't blocked.
And of course, block the inputted text using "return 0", otherwise the text will still be send to all players.
pawn Код:
new bool:ChatBlocked[MAX_PLAYERS];
public OnPlayerText(playerid, text[])
{
// Setup local variables
new Msg[128], Name[24];
// Get the player's name
GetPlayerName(playerid, Name, 24);
// Pre-format the text to be sent
format(Msg, 128, "%s: %s", Name, text);
// Send the inputted text to all players who are NOT blocked
for (new i; i < MAX_PLAYERS; i++)
{
// If this player is allowed to see chat from other players
if (ChatBlocked[i] == false)
{
// Send the text to him
SendClientMessage(i, 0xFFFFFFFF, Msg);
}
}
// Block the text from appearing normally in everyone's chatbox
return 0;
}