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

Menu Handle 0 is Invalid


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EvanChrispie
Member
Join Date: Nov 2016
Old 03-11-2017 , 19:15   Menu Handle 0 is Invalid
Reply With Quote #1

Hello, my plugin compiles correctly, but doesn't load in and it shows this error. Anyone know how to fix?
Error:
Code:
L 03/12/2017 - 10:52:04: [SM] Exception reported: Menu handle 0 is invalid (error 4)
L 03/12/2017 - 10:52:04: [SM] Blaming: sssnominate.smx
L 03/12/2017 - 10:52:04: [SM] Call stack trace:
L 03/12/2017 - 10:52:04: [SM]   [0] AddMenuItem
L 03/12/2017 - 10:52:04: [SM]   [1] Line 22, /home/groups/sourcemod/upload_tmp/phpX5jiCs.sp::OnPluginStart
L 03/12/2017 - 10:52:04: [SM] Unable to load plugin "sssnominate.smx": Error detected in plugin startup (see error logs)

PHP Code:
#include <sourcemod>

public Plugin:myInfo =
{
     
name            "",
     
author          "",
     
description  "",
     
version         "",
     
url                 ""
};

new 
Handle:g_hMenuOne INVALID_HANDLE;
new 
Handle:g_hMenuTwo INVALID_HANDLE;
new 
Handle:g_hMenuThree INVALID_HANDLE;
new 
Handle:g_hMenuMain INVALID_HANDLE;

public 
OnPluginStart()
{

    
g_hMenuMain CreateMenu(MenuMainHandler);
    
SetMenuTitle(g_hMenuMain"Nominate Map");
    
AddMenuItem(g_hMenuOne"0" "Tier 1");
    
AddMenuItem(g_hMenuTwo"1""Tier 2");
    
AddMenuItem(g_hMenuThree"2""Tier 3");

    
g_hMenuOne CreateMenu(MenuOneHandler);
    
SetMenuTitle(g_hMenuOne"Tier 1 Maps");
    
AddMenuItem(g_hMenuOne"0""Tier 1");
    
SetMenuExitBackButton(g_hMenuOnetrue);
    
    
g_hMenuTwo CreateMenu(MenuTwoHandler);
    
SetMenuTitle(g_hMenuTwo"Tier 2 Maps ");
    
AddMenuItem(g_hMenuTwo"1""surf_tier2test");
    
SetMenuExitBackButton(g_hMenuTwotrue);
    
    
g_hMenuThree CreateMenu(MenuThreeHandler);
    
SetMenuTitle(g_hMenuThree"Tier 3 Maps");
    
AddMenuItem(g_hMenuThree"2""surf_tier3test");
    
SetMenuExitBackButton(g_hMenuThreetrue);
    
    
RegAdminCmd("sssnominate"Command_MenusADMFLAG_GENERIC);

}

public 
Action:Command_Menus(clientargs)
{
    if (
client 0)
    {
        
DisplayMenu(g_hMenuMainclientMENU_TIME_FOREVER);
    }
    
    return 
Plugin_Handled;
}

public 
MenuMainHandler(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Select && IsClientInGame(param1))
    {
        
DisplayMenu(g_hMenuOneparam1MENU_TIME_FOREVER);
    }
}

public 
MenuOneHandler(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Select && IsClientInGame(param1))
    {
        
DisplayMenu(g_hMenuTwoparam1MENU_TIME_FOREVER);
    }

    else if (
action == MenuAction_Cancel && param2 == MenuCancel_ExitBack && IsClientInGame(param1))
    {
        
DisplayMenu(g_hMenuOneparam1MENU_TIME_FOREVER);
    }
}

public 
MenuTwoHandler(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Select && IsClientInGame(param1))
    {
        
DisplayMenu(g_hMenuThreeparam1MENU_TIME_FOREVER);
    }

    else if (
action == MenuAction_Cancel && param2 == MenuCancel_ExitBack && IsClientInGame(param1))
    {
        
DisplayMenu(g_hMenuOneparam1MENU_TIME_FOREVER);
    }
}

public 
MenuThreeHandler(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Cancel && param2 == MenuCancel_ExitBack && IsClientInGame(param1))
    {

DisplayMenu(g_hMenuTwoparam1MENU_TIME_FOREVER);
     }

__________________
EvanChrispie is offline
sdz
Senior Member
Join Date: Feb 2012
Old 03-11-2017 , 19:48   Re: Menu Handle 0 is Invalid
Reply With Quote #2

I also replied to your other thread. All you did here was a simple mistake in OnPluginStart. Here's the corrections, i'm sure you'll be able to notice them
Spoiler

Last edited by sdz; 03-11-2017 at 19:49.
sdz is offline
EvanChrispie
Member
Join Date: Nov 2016
Old 03-11-2017 , 20:32   Re: Menu Handle 0 is Invalid
Reply With Quote #3

Quote:
Originally Posted by EasSidezz View Post
I also replied to your other thread. All you did here was a simple mistake in OnPluginStart. Here's the corrections, i'm sure you'll be able to notice them
Spoiler
So I copied your code and it compiled fine, then it loaded in fine. But when I do the command in game nothing happens.
__________________
EvanChrispie is offline
sdz
Senior Member
Join Date: Feb 2012
Old 03-11-2017 , 20:33   Re: Menu Handle 0 is Invalid
Reply With Quote #4

Because you haven't added any items to g_hMenuMain, only set a title

Last edited by sdz; 03-11-2017 at 20:34.
sdz is offline
EvanChrispie
Member
Join Date: Nov 2016
Old 03-11-2017 , 20:39   Re: Menu Handle 0 is Invalid
Reply With Quote #5

Quote:
Originally Posted by EasSidezz View Post
Because you haven't added any items to g_hMenuMain, only set a title
Wouldn't this be adding menu items though?
PHP Code:
    SetMenuTitle(g_hMenuMain"Nominate Map"); 
    
AddMenuItem(g_hMenuOne"0" "Tier 1");  
    
AddMenuItem(g_hMenuTwo"1""Tier 2"); 
    
AddMenuItem(g_hMenuThree"2""Tier 3"); 
__________________
EvanChrispie is offline
sdz
Senior Member
Join Date: Feb 2012
Old 03-11-2017 , 20:50   Re: Menu Handle 0 is Invalid
Reply With Quote #6

Quote:
Originally Posted by EvanChrispie View Post
Wouldn't this be adding menu items though?
PHP Code:
    SetMenuTitle(g_hMenuMain"Nominate Map"); 
    
AddMenuItem(g_hMenuOne"0" "Tier 1");  
    
AddMenuItem(g_hMenuTwo"1""Tier 2"); 
    
AddMenuItem(g_hMenuThree"2""Tier 3"); 
That's adding items to g_hMenuOne, g_hMenuTwo and g_hMenuThree

PHP Code:
/**
 * Appends a new item to the end of a menu.
 *
 * @param menu                Menu Handle.
 * @param info                Item information string.
 * @param display            Default item display string.
 * @param style                Drawing style flags.  Anything other than DEFAULT or 
 *                            DISABLED will be completely ignored when paginating.
 * @return                    True on success, false on failure.
 * @error                    Invalid Handle or item limit reached.
 */
native AddMenuItem(Handle:menu
                    const 
String:info[], 
                    const 
String:display[], 
                    
style=ITEMDRAW_DEFAULT); 
I assume you would want to change it to something like this
PHP Code:
    SetMenuTitle(g_hMenuMain"Nominate Map"); 
    
AddMenuItem(g_hMenuMain"0" "Tier 1");  
    
AddMenuItem(g_hMenuMain"1""Tier 2"); 
    
AddMenuItem(g_hMenuMain"2""Tier 3"); 

Last edited by sdz; 03-11-2017 at 20:52.
sdz is offline
EvanChrispie
Member
Join Date: Nov 2016
Old 03-12-2017 , 00:24   Re: Menu Handle 0 is Invalid
Reply With Quote #7

Quote:
Originally Posted by EasSidezz View Post
That's adding items to g_hMenuOne, g_hMenuTwo and g_hMenuThree

PHP Code:
/**
 * Appends a new item to the end of a menu.
 *
 * @param menu                Menu Handle.
 * @param info                Item information string.
 * @param display            Default item display string.
 * @param style                Drawing style flags.  Anything other than DEFAULT or 
 *                            DISABLED will be completely ignored when paginating.
 * @return                    True on success, false on failure.
 * @error                    Invalid Handle or item limit reached.
 */
native AddMenuItem(Handle:menu
                    const 
String:info[], 
                    const 
String:display[], 
                    
style=ITEMDRAW_DEFAULT); 
I assume you would want to change it to something like this
PHP Code:
    SetMenuTitle(g_hMenuMain"Nominate Map"); 
    
AddMenuItem(g_hMenuMain"0" "Tier 1");  
    
AddMenuItem(g_hMenuMain"1""Tier 2"); 
    
AddMenuItem(g_hMenuMain"2""Tier 3"); 
That makes more sense, thanks for your help.
__________________

Last edited by EvanChrispie; 03-12-2017 at 00:24.
EvanChrispie 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 10:09.


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