I haven't actually tested this in-game, but it should work fine.
This is an enhanced version of ShowMOTDPanel that allows for:
- Hidden MOTD panels
- Big MOTD panel (in TF2)
- Verification that the client can actually receive MOTD panels before sending it
PHP Code:
/**
* Displays an MOTD panel to a client with advanced options
*
* @param client Client index the panel should be shown to
* @param title Title of the MOTD panel (not displayed on all games)
* @param msg Content of the MOTD panel; could be a URL, plain text, or a stringtable index
* @param type Type of MOTD this is, one of MOTDPANEL_TYPE_TEXT, MOTDPANEL_TYPE_INDEX, MOTDPANEL_TYPE_URL, MOTDPANEL_TYPE_FILE
* @param visible Whether the panel should be shown to the client
* @param big true if this should be a big MOTD panel (TF2 only)
* @param verify true if we should check if the client can actually receive HTML MOTDs before sending it, false otherwise
* @param callback A callback to be called if we determine that the client can't receive HTML MOTDs
* @noreturn
*/
stock void AdvMOTD_ShowMOTDPanel(int client, const char[] title, const char[] msg, int type=MOTDPANEL_TYPE_INDEX, bool visible=true, bool big=false, bool verify=false, MOTDFailure callback=INVALID_FUNCTION)
typedef MOTDFailure = function void (int client, MOTDFailureReason reason);
enum MOTDFailureReason {
MOTDFailure_Unknown, // Failure reason unknown
MOTDFailure_Disabled, // Client has explicitly disabled HTML MOTDs
MOTDFailure_Matchmaking, // HTML MOTD is disabled by Quickplay/matchmaking (TF2 only)
MOTDFailure_QueryFailed // cl_disablehtmlmotd convar query failed
};
Example:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <advanced_motd>
public void OnPluginStart() {
RegConsoleCmd("sm_google", Command_Google, "Opens Google in a large MOTD window");
}
public Action Command_Google(int client, int args) {
AdvMOTD_ShowMOTDPanel(client, "Google", "http://www.google.com", MOTDPANEL_TYPE_URL, true, true, true, OnMOTDFailure);
return Plugin_Handled;
}
public void OnMOTDFailure(int client, MOTDFailureReason reason) {
if(reason == MOTDFailure_Disabled) {
PrintToChat(client, "[SM] You have HTML MOTDs disabled.");
} else if(reason == MOTDFailure_Matchmaking) {
PrintToChat(client, "[SM] You cannot view HTML MOTDs because you joined via Quickplay.");
} else if(reason == MOTDFailure_QueryFailed) {
PrintToChat(client, "[SM] Unable to verify that you can view HTML MOTDs.");
} else {
PrintToChat(client, "[SM] Unable to verify that you can view HTML MOTDs for an unknown reason.");
}
}