Raised This Month: $51 Target: $400
 12% 

Solved Block "player <name> has joined the game" messages


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
404UserNotFound
BANNED
Join Date: Dec 2011
Old 10-19-2015 , 19:37   Block "player <name> has joined the game" messages
Reply With Quote #1

So I've been redoing server messages in a custom plugin using a custom version of MoreColors with my own color defines and I've ran into an issue with the name change event still firing causing two name change messages to appear:

* testing changed name to 404 <- Default message
Player testing changed their name to 404 <- Custom message

I've tried hooking the player_changename event two ways:

PHP Code:
HookEvent("player_changename"Event_PlayerChangedName); 
And
PHP Code:
HookEvent("player_changename"Event_PlayerChangedNameEventHookMode_Pre); 
As well as changing SetEventBroadcast to true and false in the code below:

PHP Code:
public Action:Event_PlayerChangedName(Handle:hEvent, const String:strName[], bool:bDontBroadcast
{
    new 
client GetClientOfUserId(GetEventInt(hEvent"userid"));
    new 
String:oldname[MAX_MESSAGE_LENGTH];
    
GetEventString(hEvent"oldname"oldnamesizeof(oldname));
    new 
String:newname[MAX_MESSAGE_LENGTH];
    
GetEventString(hEvent"newname"newnamesizeof(newname));
    if(!
IsValidClient(client))
    {
        return 
Plugin_Continue;
    }
    
SetEventBroadcast(hEventtrue);
    
CPrintToChatAll("{smblue}Player {smyellow}%s {smblue}has changed their name to {smyellow}%s{smblue}."oldnamenewname);

    return 
Plugin_Continue;

I got the idea from TidyChat and even referenced the TidyChat plugin's source code to see if I was doing something wrong (which I wasn't I think).

What's weird is that I've got a custom Disconnect message set up that works just fine and uses similar code to the above and it doesn't still print the original disconnect message (probably because I'm using TidyChat in conjunction with my plugin)

Last edited by 404UserNotFound; 08-20-2016 at 18:49.
404UserNotFound is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 10-19-2015 , 20:31   Re: Block name change message?
Reply With Quote #2

Look at https://forums.alliedmods.net/showpo...6&postcount=11

If you want TF2 just add:
Code:
if(StrEqual(buffer, "#TF_Name_Change"))
{
      return Plugin_Handled;
}
To the second part of the if/else statement.
__________________

Last edited by Chaosxk; 10-19-2015 at 20:31.
Chaosxk is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 10-19-2015 , 20:37   Re: Block name change message?
Reply With Quote #3

Quote:
Originally Posted by Chaosxk View Post
Look at https://forums.alliedmods.net/showpo...6&postcount=11

If you want TF2 just add:
Code:
if(StrEqual(buffer, "#TF_Name_Change"))
{
      return Plugin_Handled;
}
To the second part of the if/else statement.
Perfect, thanks! At least we now know that the event does still fire, but it doesn't actually have the capability of disabling the message. I think it's time for an update to Tidy Chat.

Last edited by 404UserNotFound; 10-19-2015 at 20:47.
404UserNotFound is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 10-20-2015 , 18:46   Re: Block name change message?
Reply With Quote #4

So just to clarify, am I using the Protobuf part of that code, or the 2nd part without the protobuf?
404UserNotFound is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 10-20-2015 , 19:17   Re: Block name change message?
Reply With Quote #5

I believe only CSGO uses Protobuf :O
Miu is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 10-21-2015 , 02:17   Re: Block name change message?
Reply With Quote #6

Quote:
Originally Posted by Miu View Post
I believe only CSGO uses Protobuf :O
Thanks Miu Good information for the future.
404UserNotFound is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 10-21-2015 , 13:04   Re: Block name change message?
Reply With Quote #7

Just use bitbuffer and protobuf at the same time...
PHP Code:
public Action:Hook_TextMsg(UserMsg:iMsgIdHandle:hMsg, const iPlayers[], iPlayersNumbool:bReliablebool:bInit)
{
    new 
String:sBuffer[512];

    if (
GetUserMessageType() == UM_Protobuf) {
        
PbReadString(hMsg"params"sBuffersizeof(sBuffer), 0);
    } else {
        
BfReadString(hMsgsBuffersizeof(sBuffer), false);
    }

    if (
StrContains(sBuffer"#SFUI_Notice_Killed_Teammate") != -1)
        return 
Plugin_Handled;

    if (
StrContains(sBuffer"#Cstrike_TitlesTXT_Game_teammate_attack") != -1)
        return 
Plugin_Handled;

    if (
StrContains(sBuffer"#Hint_try_not_to_injure_teammates") != -1)
        return 
Plugin_Handled;

    if (
StrContains(sBuffer"#Player_Cash_Award_Kill_Teammate") != -1)
        return 
Plugin_Handled;

    return 
Plugin_Continue;

__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 10-21-2015 , 16:05   Re: Block name change message?
Reply With Quote #8

Quote:
Originally Posted by KissLick View Post
Just use bitbuffer and protobuf at the same time...
PHP Code:
public Action:Hook_TextMsg(UserMsg:iMsgIdHandle:hMsg, const iPlayers[], iPlayersNumbool:bReliablebool:bInit)
{
    new 
String:sBuffer[512];

    if (
GetUserMessageType() == UM_Protobuf) {
        
PbReadString(hMsg"params"sBuffersizeof(sBuffer), 0);
    } else {
        
BfReadString(hMsgsBuffersizeof(sBuffer), false);
    }

    if (
StrContains(sBuffer"#SFUI_Notice_Killed_Teammate") != -1)
        return 
Plugin_Handled;

    if (
StrContains(sBuffer"#Cstrike_TitlesTXT_Game_teammate_attack") != -1)
        return 
Plugin_Handled;

    if (
StrContains(sBuffer"#Hint_try_not_to_injure_teammates") != -1)
        return 
Plugin_Handled;

    if (
StrContains(sBuffer"#Player_Cash_Award_Kill_Teammate") != -1)
        return 
Plugin_Handled;

    return 
Plugin_Continue;

I'll give this a try as well just for fun.
404UserNotFound is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 11-01-2015 , 19:13   Re: Block name change message?
Reply With Quote #9

Where would one find a list of everything and anything that could be used in this:

Code:
if(StrEqual(buffer, "#TF_Name_Change"))
{
      return Plugin_Handled;
}
What I'm referring to specifically is the #TF_Name_Change bit. Where would one find all the available messages that one could hook into and/or block using SayText2 hooking.

The above code does indeed work for blocking the stock name change message but I'm wondering if there's other things out there that I can toss in and mess around with.

Last edited by 404UserNotFound; 11-01-2015 at 19:14.
404UserNotFound is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 11-01-2015 , 19:18   Re: Block name change message?
Reply With Quote #10

should be in scripts/titles.txt
Miu is offline
Reply



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 14:23.


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