Is it possible!!
#1

Hi all! I am wondering if there is a way to hide other players chat to the player and he will be unable to see their chat but can see SenDClientMessage(s). Is it possible, if yes how?
Reply
#2

I'm not fully understanding what you mean.

Are you simply asking if it's possible to hide certain player's chatbox (where the SendClientMessage's appear)? If that's what you mean, the answer is yes (in a way). You could easily have a timer loop the clearing of the chatbox, so it would seem like it's hidden. You could also make a simple textdraw to hide/cover it.
Reply
#3

If I got correctly, this is what you want to do basically. Read the comments carefully.
pawn Код:
//Create a variable where you'll store wheather the chat should be blocked or not.
new ChatBlocked[MAX_PLAYERS];

// Un-Block the chat when player connects
public OnPlayerConnect(playerid)
{
    ChatBlocked[playerid] = 0;
    return 1;
}
public OnPlayerText(playerid,text[])
{
    //check if the player is blocked for getting chats from all players
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(ChatBlocked[i] == 1)
        {
            return 0;
        }
        else SendClientMessageToAll(GetPlayerColor(playerid),text);
    }
    return 1;
}
//now you can make command to (un)block the chat for player.
CMD:chatblock(playerid,params[])
{
    new pID,value;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xCCCCCCCC,"You're not a RCON admin.");
    if(sscanf(params,"ud",pID,value)) return SendClientMessage(playerid,0xFFFFFFFF,"USAGE: /chatblock [playerid] [value]");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,0xCCCCCCCC,"Player is not connected.");
    if(!(-1 < value < 2)) return SendClientMessage(playerid,0xCCCCCCCC,"Invalid value [0-1]");
    ChatBlocked[playerid] = value;
    return 1;
}
Reply
#4

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.

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)