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

Canceling a menu on round end/start


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
imburnt916
Junior Member
Join Date: Apr 2015
Location: California
Old 08-25-2016 , 22:22   Canceling a menu on round end/start
Reply With Quote #1

Im having problems closing a menu (in SM 1.6 [Dont ask why...]) when the round ends, is there any sure fire way of doing this? CancelMenu() seems to crash the server when trying to close it.

Code:
stock ShowPOptions(client){
    new Handle:g_hLGMenu = CreateMenu(Handle_Perk); // This is global as I was trying to use CloseHandle after I had declared a global Handle elsewhere in the plugin
    SetMenuTitle(g_hLGMenu, "");
    AddMenuItem(g_hLGMenu, "", "");
    AddMenuItem(g_hLGMenu, "", "");
    AddMenuItem(g_hLGMenu, "", "", ITEMDRAW_DISABLED);
    AddMenuItem(g_hLGMenu, "", "");
    AddMenuItem(g_hLGMenu, "", "");
    AddMenuItem(g_hLGMenu, "", "", ITEMDRAW_DISABLED);
    AddMenuItem(g_hLGMenu, "", "", ITEMDRAW_DISABLED);
    AddMenuItem(g_hLGMenu, "", "", ITEMDRAW_DISABLED);
    DisplayMenu(g_hLGMenu, client, MENU_TIMEOUT_NORMAL);
}
__________________
Sourcemod developer and server manager.
imburnt916 is offline
ReFlexPoison
☠☠☠
Join Date: Jul 2011
Location: ☠☠☠
Old 08-25-2016 , 23:41   Re: Canceling a menu on round end/start
Reply With Quote #2

When you say "close menu" are you referring to closing the menu on the players screen, or closing the handle itself?

Generally when the round ends, at least on tf2, I thought all the menus already close once the next round starts?
ReFlexPoison is offline
imburnt916
Junior Member
Join Date: Apr 2015
Location: California
Old 08-25-2016 , 23:50   Re: Canceling a menu on round end/start
Reply With Quote #3

Quote:
Originally Posted by ReFlexPoison View Post
When you say "close menu" are you referring to closing the menu on the players screen, or closing the handle itself?

Generally when the round ends, at least on tf2, I thought all the menus already close once the next round starts?
The handle, so that if a player tries to make a menu selection nothing happens.
__________________
Sourcemod developer and server manager.
imburnt916 is offline
jakesmokie
Member
Join Date: Aug 2016
Old 08-26-2016 , 00:19   Re: Canceling a menu on round end/start
Reply With Quote #4

I hope it's right way
PHP Code:
Menu g_hLGMenu;

public 
void OnPluginStart()
{
    
g_hLGMenu CreateMenu(Handle_Perk);
    
    
g_hLGMenu.SetTitle("Title + %s""Format");
}

stock void ShowPOptions(int iClient)
{
    
g_hLGMenu.RemoveAllItems();
    
    
// Add your own items
    
g_hLGMenu.AddItem("info""title");
    
    
g_hLGMenu.Display(iClientMENU_TIMEOUT_NORMAL);
}

public 
int Handle_Perk(Menu mMenuMenuAction mActionint iClientint iPos)
{
    
// Do whatever you want
}

public 
void OnRoundStart(Event eEvent, const char[] sNamebool bSilent)
{
    
g_hLGMenu.Cancel();

jakesmokie is offline
imburnt916
Junior Member
Join Date: Apr 2015
Location: California
Old 08-26-2016 , 00:33   Re: Canceling a menu on round end/start
Reply With Quote #5

Quote:
Originally Posted by jakesmokie View Post
I hope it's right way
PHP Code:
Menu g_hLGMenu;

public 
void OnPluginStart()
{
    
g_hLGMenu CreateMenu(Handle_Perk);
    
    
g_hLGMenu.SetTitle("Title + %s""Format");
}

stock void ShowPOptions(int iClient)
{
    
g_hLGMenu.RemoveAllItems();
    
    
// Add your own items
    
g_hLGMenu.AddItem("info""title");
    
    
g_hLGMenu.Display(iClientMENU_TIMEOUT_NORMAL);
}

public 
int Handle_Perk(Menu mMenuMenuAction mActionint iClientint iPos)
{
    
// Do whatever you want
}

public 
void OnRoundStart(Event eEvent, const char[] sNamebool bSilent)
{
    
g_hLGMenu.Cancel();

This is 1.7 if im not mistaken
__________________
Sourcemod developer and server manager.
imburnt916 is offline
jakesmokie
Member
Join Date: Aug 2016
Old 08-26-2016 , 02:20   Re: Canceling a menu on round end/start
Reply With Quote #6

Just use 1.6 functions and on roundstart call CancelMenu()
jakesmokie is offline
imburnt916
Junior Member
Join Date: Apr 2015
Location: California
Old 08-27-2016 , 17:36   Re: Canceling a menu on round end/start
Reply With Quote #7

Quote:
Originally Posted by jakesmokie View Post
Just use 1.6 functions and on roundstart call CancelMenu()
Read OP.
__________________
Sourcemod developer and server manager.
imburnt916 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:10.


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