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

Advanced ShowMOTDPanel


Post New Thread Reply   
 
Thread Tools Display Modes
DJ Data
SourceMod Donor
Join Date: Dec 2012
Location: Switzerland
Old 09-14-2015 , 12:44   Re: Advanced ShowMOTDPanel
Reply With Quote #21

Very well done, thanks for keeping the 1.6 code in there
__________________
SourcePawn Coding Level: Novice
DJ Data is offline
fragnichtnach
AlliedModders Donor
Join Date: Oct 2008
Old 02-07-2016 , 06:32   Re: Advanced ShowMOTDPanel
Reply With Quote #22

Quote:
Originally Posted by Dr. McKay View Post
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
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.");
    }

I have tested it in CS:GO.
Plugin is loaded (sm plugins ->"example.smx" example.smx).
Modt does not show.
There is no errormessage!

I don't think it is working at the moment.

I used this because I've go problems with ShowMOTDPanel. As well nothing was opening with this command. (I have clientsided cl_disablehtmlmotd 0.)

Is there actually a problem with opening the motd out of running game?
fragnichtnach is offline
fragnichtnach
AlliedModders Donor
Join Date: Oct 2008
Old 02-09-2016 , 00:48   Re: Advanced ShowMOTDPanel
Reply With Quote #23

I read somewhere else: "The latest steam client update broke the webkit in-game for anything other than initial page hit"
Is this The Problem?
fragnichtnach is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-11-2016 , 10:25   Re: Advanced ShowMOTDPanel
Reply With Quote #24

Quote:
Originally Posted by fragnichtnach View Post
I read somewhere else: "The latest steam client update broke the webkit in-game for anything other than initial page hit"
Is this The Problem?
the original motd panel has never worked in csgo.
Mitchell is offline
You9
Member
Join Date: Mar 2016
Old 04-29-2016 , 21:57   Re: Advanced ShowMOTDPanel
Reply With Quote #25

It's should work in CS:GO?
Because the default ShowMOTDPanel working, but AdvMOTD_ShowMOTDPanel not working No errors or something, validate enabled and stuff.
You9 is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 08-11-2017 , 04:55   Re: Advanced ShowMOTDPanel
Reply With Quote #26

The transitional syntax version of AdvMOTD_OnQueryFinished function isn't completing the callback with Call_Finish(). It always fails silently. The pretransitional one is fine, on the other hand.

Here's a fixed copy that actually completes the call and removes the forward instantiation in favor of just packing in the function.

Code:
#if defined _advmotd_enabled
 #endinput
#endif
#define _advmotd_enabled

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
};

typedef MOTDFailure = function void (int client, MOTDFailureReason reason);

/**
 * 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) {
	char connectmethod[32];
	if(verify && GetClientInfo(client, "cl_connectmethod", connectmethod, sizeof(connectmethod))) {
		if(StrContains(connectmethod, "quickplay", false) != -1 || StrContains(connectmethod, "matchmaking", false) != -1) {
			if(callback != INVALID_FUNCTION) {
				Call_StartFunction(null, callback);
				Call_PushCell(client);
				Call_PushCell(MOTDFailure_Matchmaking);
				Call_Finish();
			}
			return;
		}
	}
	
	KeyValues kv = new KeyValues("data");
	kv.SetString("title", title);
	kv.SetNum("type", type);
	kv.SetString("msg", msg);
	if(big) {
		kv.SetNum("customsvr", 1);
	}
	
	if(verify) {
		DataPack pack = new DataPack();
		pack.WriteCell(kv);
		pack.WriteCell(visible);
		pack.WriteFunction(callback);
		
		QueryClientConVar(client, "cl_disablehtmlmotd", AdvMOTD_OnQueryFinished, pack);
	} else {
		ShowVGUIPanel(client, "info", kv, visible);
		CloseHandle(kv);
	}
}

public void AdvMOTD_OnQueryFinished(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue, DataPack pack) {
	pack.Reset();
	KeyValues kv = pack.ReadCell();
	bool visible = pack.ReadCell();
	Function callback = pack.ReadFunction();
	delete pack;
	
	if(result != ConVarQuery_Okay || StringToInt(cvarValue)) {
		delete kv;
		
		if(callback != INVALID_FUNCTION) {
			Call_StartFunction(INVALID_HANDLE, callback);
			Call_PushCell(client);
			Call_PushCell((result != ConVarQuery_Okay) ? MOTDFailure_QueryFailed : MOTDFailure_Disabled);
			Call_Finish();
		}
		return;
	}
	
	ShowVGUIPanel(client, "info", kv, visible);
	delete kv;
}
Attached Files
File Type: inc advanced_motd.inc (3.0 KB, 176 views)
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 08-11-2017 at 05:00. Reason: attached for ez download
nosoop is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 02-17-2018 , 20:10   Re: Advanced ShowMOTDPanel
Reply With Quote #27

Is MOTD support callbacks like if I would like to receive an event when flash player finished playing the music?

I am using Disco plugin.
And I don't like it looping the track instead of playing tracklist.

So, first solution is to modify php such a way it close web-page as soon as track is finished playing. I hope MOTD has ability to track such event and return a callback. So, I can jump to next track via SourceMod plugin.

Second solution, of course, add tracklist support to php or swf player, but I'm not very familiar with php or Action Script.

Of course, there is always 3-rd variant: make script for auto-calculating each song length and save it into .cfg, so plugin will use it to track end of each song.

Last edited by Dragokas; 02-17-2018 at 23:13.
Dragokas is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 02-18-2018 , 03:20   Re: Advanced ShowMOTDPanel
Reply With Quote #28

Quote:
Originally Posted by Dragokas View Post
Is MOTD support callbacks like if I would like to receive an event when flash player finished playing the music?

I am using Disco plugin.
And I don't like it looping the track instead of playing tracklist.

[...]
Nope; as far as I can tell a page can't make the client send callback actions by itself.

For your particular use case, you could write something up with WebSockets for client-server comms, but assuming you had control over your web server stack, your best bet would be to deliver a stream of audio using some HTTP streaming application so it's mostly synced across clients, then use a minimal amount of HTML to source and playback the audio (and you can show playlist info by passing data from your streaming server to your game server).
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop 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 02:58.


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