Open metita opened 4 years ago
motd function always will show hostname by default if string for title is empty i guess
motd function always will show hostname by default if string for title is empty i guess
String empty or not it will get replaced.
Did you have an test case code?
You calling ServerName and trying to display a motd?
If you set a custom ServerName hooking the message, once you open a motd , that value will get replaced with default servername, thats all.
UTIL_ShowMOTD uses ServerName Message, look at the begin and end of function. Since MOTD messages aways display a serverName, what amxx team do is send ServerName message with motd title by show_motd param. And at the end send's the original hostname on ServerName message.
Now i have sure that you need to do something to avoid that on ServerName message hook. Or just show a code example of how you hook in ServerName message.
There should be a way from the native itself to not hook ServerName it is quite annoying, literally you need a permanent task that set the custom ServerName and that will do the work, but thats not a great idea.
It is a simple thing what I do.
register_message( get_user_msgid( "ServerName" ), "OnServerName" );
public OnServerName( )
{
set_msg_arg_string( 1, "Hi" );
}
ServerName message is fine, i think it is related wth this?
https://forums.alliedmods.net/showthread.php?t=114873
Sinte this change string itself, also you can try to compare with hostname cvar
ServerName message is fine, i think it is related wth this?
https://forums.alliedmods.net/showthread.php?t=114873
Sinte this change string itself, also you can try to compare with hostname cvar
Not sure if that will works, if show_motd gets executed, ServerName will restore his default value, nothing will change AFAIK.
I guess when amxmodx call ServerName messages this is not reflected on registered message, so this is buggy. This is the real problem.
A solution is a pull request to call message.
EDIT: You can try to call show_motd function, after that call ServerName with your string. I have sure that will solve this problem.
No, I don't think that will do the work, each call of show_motd will replace ServerName on client-side regardless of execution. This is a common unexpected behavior I guess, many friends have the same problem and are using or a permanent set_task or avoiding the usage of show_motd, my mod at least calls show_motd many times because there is a menu which explains concepts/rules of my mod.
In each call to show_motd need to call ServerName message to avoid that, or you do in your code, or a future fix from amxx team will do in their code. Anyway i will try to make a pull request later to change this.
Ps. This is already made in amxmodx util code, but using hostname instead of old name at the message.
Yeah, that may be a good solution, save ServerName changed value somewhere (like cache?) and then restoring it once show_motd gets displayed.
@Arkshine any insight?
Not sure if this is intended or a unexpected behavior but when calling ServerName message and editing it to display a custom one, when calling show_motd that custom message will get replaced with the original hostname, not sure if this should work like that but I think that should be addressed if possible. (Unless it's something client-side).