Page 1 of 1

Hide player chat

Posted: Sat Feb 04, 2017 2:00 am
by decompile
Hey Guys,

How can I toggle the player chat someone?

It should block the say/say_team messages from any other player when you have hidechat on, else everything normal.

I thought about it, and you can probably do it with UserMessage or?

Re: Hide player chat

Posted: Sat Feb 04, 2017 5:43 am
by D3CEPTION
yes you can, but usermsgs are useful when you create customized block filters. in your case, if you merely try to toggle there is a m_iHideHUD property on the player. cant test it right now but should go sthn like this:

Syntax: Select all

from players.constants import HideHudFlags
player.set_property_int("m_Local.m_iHideHUD",HideHudFlags.CHAT)

Re: Hide player chat

Posted: Sat Feb 04, 2017 5:54 am
by satoon101
While that could "work", it would have side effects that I don't think are wanted. Once you turn the hud back on, the chat messages will still be accessible in the chat history. This might not be all that bad, however, the main side effect is that useful messages from the server itself (for instance, from SP plugins) will also be hidden.

The best way would be to hook SayText2, find if the message is from say/say_team, and remove the specific user from the recipient filter if they are included.

Re: Hide player chat

Posted: Sat Feb 04, 2017 6:07 am
by D3CEPTION
there are even more things that could be said. you forgot to mention all that. but your answer isnt overall that bad. maybe he will be more specific on his next reply.

Re: Hide player chat

Posted: Sat Feb 04, 2017 10:00 am
by L'In20Cible
D3CEPTION wrote:yes you can, but usermsgs are useful when you create customized block filters. in your case, if you merely try to toggle there is a m_iHideHUD property on the player. cant test it right now but should go sthn like this:

Syntax: Select all

from players.constants import HideHudFlags
player.set_property_int("m_Local.m_iHideHUD",HideHudFlags.CHAT)

You can directly use Player.hidden_huds. Also, you don't want to "set" this value, you want to add it:

Syntax: Select all

player.hidden_huds |= HideHudFlags.CHAT


As a side note, when the enumerator is plurial, that means the values are bit fields.

Re: Hide player chat

Posted: Sat Feb 04, 2017 10:35 am
by D3CEPTION
ah nice you changed your profile pic on all your accounts after i suggested that they represent your criminal activities :D,

i think we should wait for what exactly he wants to do anyway, i only wanted to show him the property and not drift off topic too much. you must have overread that i especially wrote
"there are even more things that could be said"
so that noone jumps off topic too much. Hehe, you just couldnt resist to reply anyway, couldnt you? :D

Re: Hide player chat

Posted: Sat Feb 04, 2017 10:57 am
by Ayuto
D3CEPTION wrote:
"there are even more things that could be said"

I guess because there is no reason to say more if one argument already shows that the suggested solution doesn't fit in this case.

L'In20Cible just provided valuable information for future use. Please just take this as an information and not as an attack against you.

Re: Hide player chat

Posted: Sat Feb 04, 2017 11:09 am
by L'In20Cible
D3CEPTION wrote:ah nice you changed your profile pic on all your accounts after i suggested that they represent your criminal activities :D,

Of course, I just woke up and changed my avatar cause of your comment back in october. Trust me, you are the last reason why I would do anything.

D3CEPTION wrote:i think we should wait for what exactly he wants to do anyway, i only wanted to show him the property and not drift off topic too much. you must have overread that i especially wrote
"there are even more things that could be said"
so that noone jumps off topic too much. Hehe, you just couldnt resist to reply anyway, couldnt you? :D

If we don't reply, this is the end of the world. If we reply, this is the end of the world. Like mentionned, I added valuable information to your proposed solution so nobody reading that thread get mis-informed. Don't bring back your toxic attitude, especially not into someone's else thread; this is disrespectful.

I will remove all post off-topic, so don't reply unless you have information/solution to add on decompile's request.

Re: Hide player chat

Posted: Mon Feb 06, 2017 4:15 pm
by decompile
Hey,

sorry for the delay. My pc broke and couldnt do anything the past days.

Thanks for youre response guys, but the best answer is probably yet from satoon.

I dont want to hide the whole chat, since probably important messages such as from my plugin, lets say advertisements, wont go through.
I only want to disable the player chat which is just say/say_team from other players if its enabled.

Recently I noticed that i was using a plugin without my knowledge, which used:

Syntax: Select all

new g_bBlock[MAXPLAYERS+1];

public OnPluginStart()
{
HookUserMessage(GetUserMessageId("SayText2"), UserMessage, true);
RegConsoleCmd("sm_hidechat", hidechat);
}

public Action:hidechat(client, args)
{
g_bBlock[client] = !g_bBlock[client];
ReplyToCommand(client, "[SM] Hide chat (%s)", g_bBlock[client] ? "on":"off");

return Plugin_Handled;
}

public OnClientPostAdminCheck(client)
{
g_bBlock[client] = false;
}

public Action:UserMessage(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
if(reliable && playersNum == 1)
{
return g_bBlock[players[0]] ? Plugin_Handled:Plugin_Continue;
}
return Plugin_Continue;
}


But my guess is, that this causes my crash issue from one of my latest posts.