Hide player chat

Please post any questions about developing your plugin here. Please use the search function before posting!
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Hide player chat

Postby decompile » Sat Feb 04, 2017 2:00 am

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?
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Re: Hide player chat

Postby D3CEPTION » Sat Feb 04, 2017 5:43 am

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)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Hide player chat

Postby satoon101 » Sat Feb 04, 2017 5:54 am

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.
Image
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Re: Hide player chat

Postby D3CEPTION » Sat Feb 04, 2017 6:07 am

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.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Hide player chat

Postby L'In20Cible » Sat Feb 04, 2017 10:00 am

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.
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Re: Hide player chat

Postby D3CEPTION » Sat Feb 04, 2017 10:35 am

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
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Hide player chat

Postby Ayuto » Sat Feb 04, 2017 10:57 am

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.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Hide player chat

Postby L'In20Cible » Sat Feb 04, 2017 11:09 am

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.
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: Hide player chat

Postby decompile » Mon Feb 06, 2017 4:15 pm

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.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 23 guests