Raised This Month: $ Target: $400
 0% 

Supressing Name Change Message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
agrif
Junior Member
Join Date: Jan 2010
Old 01-11-2010 , 20:56   Supressing Name Change Message
Reply With Quote #1

I've started to learn how to script for SourceMod, and my first teeny mod (that I've wanted for a while, and I find useful, so cool!) is almost done. The only part that I haven't figured out is how to prevent name changes from displaying something like "* Player 1 has changed his name to Player 2" in the game.

To be clear, I've only tested the following things in Team Fortress 2, but honestly, this is really the only game I care about.

I've tried hooking the player_info event, the one I found first, but it never fired. The player_changename event fires, though, but I can't seem to have any effect on it. If I return Plugin_Handled from my handler, I expected it to either cancel the name change, or not show a message. However, it still changed the name, and printed out a message. I tried, just in case, making a new copy of the event that isn't broadcasted, and suppressing the old one, which also didn't work.

I know for a fact that these event handlers are being called, and one of the functions was as simple as returning only Plugin_Handled, but the message was still printed.

This leads me to believe that the player_changename event is not what causes the message! But, there's no other event, or callback, that handles name changes... not that I've seen.

Is there a way to suppress name change messages?
agrif is offline
Kevin_b_er
SourceMod Donor
Join Date: Feb 2009
Old 01-11-2010 , 22:05   Re: Supressing Name Change Message
Reply With Quote #2

Are doing the event hook as Pre? You must set that last parameter to EventHookMode_Pre to be able to block an event from going out.

native HookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
Kevin_b_er is offline
agrif
Junior Member
Join Date: Jan 2010
Old 01-11-2010 , 22:15   Re: Supressing Name Change Message
Reply With Quote #3

Yes, I have set the event hook as EventHookMode_Pre. I also know that these hooks are firing at the right times, because the other Pre events I have that modify or suppress events work, and I've set up these events the same way.

Is suppressing player_changename supposed to work? I think I've gone insane looking over my code for anything else that could be wrong.
agrif is offline
Kevin_b_er
SourceMod Donor
Join Date: Feb 2009
Old 01-11-2010 , 22:39   Re: Supressing Name Change Message
Reply With Quote #4

I don't have much else as I don't know enough about how name changing works.

One thing you will have much more difficulty doing, however, is actually blocking the name change.

You could always change their name back.
Kevin_b_er is offline
Luggi
Member
Join Date: Dec 2008
Old 01-12-2010 , 11:10   Re: Supressing Name Change Message
Reply With Quote #5

Try setting NoBroadcast to true / Broadcast to false
Luggi is offline
agrif
Junior Member
Join Date: Jan 2010
Old 01-12-2010 , 18:01   Re: Supressing Name Change Message
Reply With Quote #6

Quote:
Originally Posted by Kevin_b_er
One thing you will have much more difficulty doing, however, is actually blocking the name change.

You could always change their name back.
Fortunately (I suppose), I'm not actually trying to block the name change. In this case, I'm the one changing names. I just don't want the notification of name change.

Quote:
Originally Posted by Luggi
Try setting NoBroadcast to true / Broadcast to false
I've tried firing a duplicate event with dontBroadcast = true, then returning Plugin_Handled for the current event. I even had a check for preventing infinite loops. I used the same technique for preventing "player connected" messages without actually blocking player connections. However, this didn't work.

I think the problem with this, as I later found out, is that even a handler that does nothing but return Plugin_Handled does not keep the message from showing up on clients.

This is really only a cosmetic thing; the message is just excess spam on the screen, and I could live with it if I have to. But I've hidden 2 other messages much like it, and it's hard to believe this is impossible to do.
agrif is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 01-12-2010 , 19:23   Re: Supressing Name Change Message
Reply With Quote #7

this is a user message. try...
PHP Code:
#include <sourcemod>

new UserMsg:g_SayText2;

public 
OnPluginStart()
{
    
g_SayText2 GetUserMessageId("SayText2");
    
HookUserMessage(g_SayText2UserMessageHooktrue);
}

public 
Action:UserMessageHook(UserMsg:msg_idHandle:bf, const players[], playersNumbool:reliablebool:init)
{
    
decl String:message[256];
    
BfReadString(bfmessagesizeof(message));
    
BfReadString(bfmessagesizeof(message));
    if (
StrContains(message"Name_Change") != -1)
        return 
Plugin_Handled;

    return 
Plugin_Continue;

__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
agrif
Junior Member
Join Date: Jan 2010
Old 01-12-2010 , 21:23   Re: Supressing Name Change Message
Reply With Quote #8

Thank you, very much! This is exactly what I was looking for. I'd never heard of UserMessages until now, though, so I don't feel too bad about being confused.

Knowing what to look for, now, I see that this has been asked before, so I apologize for the repeat question. In fairness, I was expecting an event based solution, so my searches weren't general enough to catch the answer before.

For future reference to those searching, this is what I learned about the name change message data for TF2:

  1. short: client ID
  2. string: "#TF_Name_Change"
  3. string: old name
  4. string: new name
just as a last question (sort of unimportant), does anyone know if this is true for L4D(2), CS:S, ...? Especially the client ID as a short at the beginning. I know that the string at #2 is probably different, but I'm mostly worried about the client ID at #1.
agrif is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 01-12-2010 , 22:48   Re: Supressing Name Change Message
Reply With Quote #9

yes i would assume so, when its a SayText2 message that index is used to determine the color of the text. if it were a normal TextMsg, the index isnt included.
__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
agrif
Junior Member
Join Date: Jan 2010
Old 01-13-2010 , 14:05   Re: Supressing Name Change Message
Reply With Quote #10

I'm glad you told me that. When I was trying to figure out what that first value was, I tried it with two bots and got values 1 and 2, and assumed that was client ID... but the bots were on different teams. That's what I get for assuming things!

Anyway, thanks to all who've responded here, it's great to know help is available when it's needed!
agrif is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:51.


Powered by vBulletin®
Copyright ©2000 - 2023, vBulletin Solutions, Inc.
Theme made by Freecode