Raised This Month: $32 Target: $400
 8% 

Execute function when the MotD is Closed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arrow768
Veteran Member
Join Date: Nov 2011
Location: Austria
Old 05-24-2014 , 11:39   Execute function when the MotD is Closed
Reply With Quote #1

Is there a way to run a function when the client closes the MotD window ?
I know that its possible to run a function when the client selects a team, but that is too late.


Why I need this:
I am showing a video in the MotD window when a client connects to the server.
But as soon as they click "ok", I would like to stop the video (So the video doesnt continue to run in the background).

I have tried to implement it with jquery visibility api from mathiasbynens and it works on a desktop browser (the video is paused when the tab is changed), but its not working with the ingame browser.

So I thought of loading a blank page in the motd when the users clicks on ok.
Is there another way to stop playing the video once the client clicks on ok (closes the motd window)?
__________________
Arrow768 is offline
TheWho
AlliedModders Donor
Join Date: Jul 2012
Old 05-24-2014 , 12:29   Re: Execute function when the MotD is Closed
Reply With Quote #2

Check if they are in a team because everyone would choose a team after clicking ok..
Hook player_team and set a variable to true after the first team choose.
And then maybe open "about:blank" in the background.
TheWho is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 05-24-2014 , 18:11   Re: Execute function when the MotD is Closed
Reply With Quote #3

You might be able to block the original motd which opens, make a new one which includes the Cmd_ClosedHTMLPage as a cmd parameter and show that to the client instead. At that point, you can listen for the closed_htmlpage command which will now be fired every time you close your custom motd. Once that's detected you can show a blank html page which is hidden, stopping the video from playing.
__________________

Last edited by 11530; 05-24-2014 at 18:14.
11530 is offline
Arrow768
Veteran Member
Join Date: Nov 2011
Location: Austria
Old 05-24-2014 , 19:36   Re: Execute function when the MotD is Closed
Reply With Quote #4

@TheWho,
I have already thought about it, but I would like to stop playing the video when the user closes the motd (if somehow possible)

@11530
That sounds like an interesting idea, but how would I block the MotD from opening ? - Is there a event that fires when the MotD opens ?
__________________
Arrow768 is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 05-24-2014 , 20:21   Re: Execute function when the MotD is Closed
Reply With Quote #5

Quote:
Originally Posted by Arrow768 View Post
@11530
That sounds like an interesting idea, but how would I block the MotD from opening ? - Is there a event that fires when the MotD opens ?
You block the current motd by hooking the VGUIMenu message and if the VGUI is the motd, then return Plugin_Handled. Probably need to check for some custom info too to differentiate it from your custom one.

And yes, but only if the "cmd" "Cmd_ClosedHTMLPage" parameter is supplied when making it. It'll then fire closed_htmlpage.
__________________

Last edited by 11530; 05-24-2014 at 20:24.
11530 is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 05-26-2014 , 01:47   Re: Execute function when the MotD is Closed
Reply With Quote #6

Pretty sure the closed motd page callbavks don't fire any more, atleast in some games. They seemed to stop working for me anyway, around the time valve broke quickplay.
What you could do is try a jquery mouseover type deal that navigates to about:blank or something when you mouseout, but that is probably not what you want.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram 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 20:04.


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