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

Force close open menu on event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Anjin
Senior Member
Join Date: Apr 2015
Old 07-02-2015 , 06:09   Force close open menu on event
Reply With Quote #1

I'm trying to fix this sm_skinchooser bug ASAP so I can buy and start running a server today.

Basically, when you manually call the menu with !models, it still stays open after you switch teams or if the teams are autoswapped after mp_halftime, allowing you to choose the models from the opposite team (the team you were on before). So I want it to force-close the menu when a person changes teams, or if the teams are automatically swapped after halftime.

Any ideas how to do this?

Last edited by Anjin; 07-02-2015 at 11:51.
Anjin is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-02-2015 , 09:23   Re: Force close open menu on event
Reply With Quote #2

What you could do instead is send the new version of the menu to them.

Sending another menu to a player will force the currently open menu to close.

Edit:

A menu can tell if it has been closed this way as its handler will receive a MenuAction_End with param1 set to MenuEnd_Cancelled and param2 set to MenuCancel_Interrupted
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-02-2015 at 09:25.
Powerlord is offline
Anjin
Senior Member
Join Date: Apr 2015
Old 07-02-2015 , 09:40   Re: Force close open menu on event
Reply With Quote #3

It's already coded to show a menu on event player_team, but it doesn't open a new menu if the previous menu has been called manually by the !models command for some reason.

This is how Event_PlayerTeam calls the menu:
PHP Code:
public Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
            new 
client GetClientOfUserId(GetEventInt(event"userid"));
            new 
team GetEventInt(event"team");

            if((
team == || team == 3) && IsValidClient(client) && !IsFakeClient(client))
            {
                
Command_Model(client0);
            }
            return;

This works fine and if you switch teams, the old menu is closed and a new menu is opened.

But if you just do !models and call Command_Model (RegConsoleCmd("sm_models", Command_Model);), the old menu is not closed on team switch:
PHP Code:
public Action:Command_Model(client,args)
{
    
mainmenu BuildMainMenu(client);

    if (
mainmenu == INVALID_HANDLE)
    {
        return 
Plugin_Handled;
    }
    if(
GetConVarInt(g_enabled) == && !IsFakeClient(client))    
    {
        
mainmenu BuildMainMenu(client);
        
DisplayMenu(mainmenuclientGetConVarInt(g_CloseMenuTimer));
    }
    return 
Plugin_Handled;

The only difference that I see is that client is set when Command_Model is called by Event_PlayerTeam, but not when you directly call it. I don't understand why the menu would close in the first case, but not the second

Last edited by Anjin; 07-02-2015 at 12:05.
Anjin is offline
R1KO
Member
Join Date: Sep 2013
Old 07-02-2015 , 17:10   Re: Force close open menu on event
Reply With Quote #4

Use CancelClientMenu
R1KO is offline
Send a message via Skype™ to R1KO
Anjin
Senior Member
Join Date: Apr 2015
Old 07-02-2015 , 18:48   Re: Force close open menu on event
Reply With Quote #5

Yes, perfect! Thank you!

Last edited by Anjin; 07-02-2015 at 18:48.
Anjin is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 07-02-2015 , 20:12   Re: Force close open menu on event
Reply With Quote #6

Alternately, I've also seen this accomplished by faking a client command to select the menu option to exit the menu...9 in csgo, 0 in all other games, i believe...not sure about lfd2 and other games i havent played. CancelClientMenu says it only works on non-external menus, so it works for your plugin as a much better option, but I thought I'd post this here in case it can help someone later on.
__________________
ThatOneGuy is offline
Reply



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 06:24.


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