Raised This Month: $169 Target: $400
 42% 

Advanced ShowMOTDPanel


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 12-31-2013 , 03:28   Advanced ShowMOTDPanel
Reply With Quote #1

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[] msgint type=MOTDPANEL_TYPE_INDEXbool visible=truebool big=falsebool verify=falseMOTDFailure callback=INVALID_FUNCTION)

typedef MOTDFailure = function void (int clientMOTDFailureReason 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 clientint args) {
    
AdvMOTD_ShowMOTDPanel(client"Google""http://www.google.com"MOTDPANEL_TYPE_URLtruetruetrueOnMOTDFailure);
    return 
Plugin_Handled;
}

public 
void OnMOTDFailure(int clientMOTDFailureReason 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.");
    }

Attached Files
File Type: inc advanced_motd_pretransitional.inc (3.2 KB, 215 views)
File Type: inc advanced_motd.inc (3.2 KB, 419 views)
__________________

Last edited by Dr. McKay; 06-29-2015 at 01:42.
Dr. McKay is offline
404UNF
( ͡ ͜ʖ ͡)
Join Date: Dec 2011
Location: 🍁
Old 12-31-2013 , 05:14   Re: Advanced ShowMOTDPanel
Reply With Quote #2

I. Freakin'. Love. You.
__________________
I'm not a SourcePawn expert, I just play one on TV.
Want to join the SourceMod Discord server? Click here!
<- Links fixed!
404UNF is offline
Alex30555
Member
Join Date: Sep 2011
Location: Paris
Old 12-31-2013 , 06:22   Re: Advanced ShowMOTDPanel
Reply With Quote #3

Nice Thanks.
__________________
Alex30555 is offline
404UNF
( ͡ ͜ʖ ͡)
Join Date: Dec 2011
Location: 🍁
Old 01-01-2014 , 14:15   Re: Advanced ShowMOTDPanel
Reply With Quote #4

Thanks to this excellent native, I was able to FINALLY create a working "Big MOTD on connect" plugin. It uses some code from MasteroftheXP's Block MOTD plugin which is why there seems to be an issue where using this causes players to not be able to select a class or a team.

Here's the code

Spoiler
__________________
I'm not a SourcePawn expert, I just play one on TV.
Want to join the SourceMod Discord server? Click here!
<- Links fixed!

Last edited by 404UNF; 01-01-2014 at 14:16.
404UNF is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 01-01-2014 , 16:45   Re: Advanced ShowMOTDPanel
Reply With Quote #5

If the HTML MOTD fails, you should send them a regular ShowMOTDPanel text MOTD.

Also, why are you hooking the "Train" message?
__________________

Last edited by Dr. McKay; 01-01-2014 at 16:47.
Dr. McKay is offline
404UNF
( ͡ ͜ʖ ͡)
Join Date: Dec 2011
Location: 🍁
Old 01-01-2014 , 16:54   Re: Advanced ShowMOTDPanel
Reply With Quote #6

Quote:
Originally Posted by Dr. McKay View Post
If the HTML MOTD fails, you should send them a regular ShowMOTDPanel text MOTD.

Also, why are you hooking the "Train" message?
It's from the Block MOTD plugin from MasteroftheXP. I didn't know what it was, so I just kept it in there.

The HTML MOTD displays properly, but (and this may have been because I unloaded the plugin whilst the MOTD panel was up) it disallowed me from choosing a team or even joining the game.

The only reason I was trying to make a "big MOTD on connect" plugin was for a friend who wanted it for his server.
__________________
I'm not a SourcePawn expert, I just play one on TV.
Want to join the SourceMod Discord server? Click here!
<- Links fixed!
404UNF is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 01-01-2014 , 17:56   Re: Advanced ShowMOTDPanel
Reply With Quote #7

Quote:
Originally Posted by abrandnewday View Post
It's from the Block MOTD plugin from MasteroftheXP. I didn't know what it was, so I just kept it in there.

The HTML MOTD displays properly, but (and this may have been because I unloaded the plugin whilst the MOTD panel was up) it disallowed me from choosing a team or even joining the game.

The only reason I was trying to make a "big MOTD on connect" plugin was for a friend who wanted it for his server.
The big MOTD destroys vgui panels underneath it, including the team selection screen.

psychonic's Dynamic MOTD plugin has an option to use the big MOTD.
__________________
Dr. McKay is offline
404UNF
( ͡ ͜ʖ ͡)
Join Date: Dec 2011
Location: 🍁
Old 01-01-2014 , 18:15   Re: Advanced ShowMOTDPanel
Reply With Quote #8

Quote:
Originally Posted by Dr. McKay View Post
The big MOTD destroys vgui panels underneath it, including the team selection screen.

psychonic's Dynamic MOTD plugin has an option to use the big MOTD.
Well wait....if it destroys the team selection screen, why would someone use a big MOTD on connect? No-one would be able to join!
__________________
I'm not a SourcePawn expert, I just play one on TV.
Want to join the SourceMod Discord server? Click here!
<- Links fixed!
404UNF is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 01-01-2014 , 18:20   Re: Advanced ShowMOTDPanel
Reply With Quote #9

Quote:
Originally Posted by abrandnewday View Post
Well wait....if it destroys the team selection screen, why would someone use a big MOTD on connect? No-one would be able to join!
psychonic's plugin accounts for and fixes this.
__________________
Dr. McKay is offline
404UNF
( ͡ ͜ʖ ͡)
Join Date: Dec 2011
Location: 🍁
Old 01-01-2014 , 18:26   Re: Advanced ShowMOTDPanel
Reply With Quote #10

Quote:
Originally Posted by Dr. McKay View Post
psychonic's plugin accounts for and fixes this.
Ohhhhhhh. I see now! Thanks for clarifying
__________________
I'm not a SourcePawn expert, I just play one on TV.
Want to join the SourceMod Discord server? Click here!
<- Links fixed!
404UNF 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 17:31.


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