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_PlayerChangedName, EventHookMode_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", oldname, sizeof(oldname));
new String:newname[MAX_MESSAGE_LENGTH];
GetEventString(hEvent, "newname", newname, sizeof(newname));
if(!IsValidClient(client))
{
return Plugin_Continue;
}
SetEventBroadcast(hEvent, true);
CPrintToChatAll("{smblue}Player {smyellow}%s {smblue}has changed their name to {smyellow}%s{smblue}.", oldname, newname);
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)