Raised This Month: $ Target: $400
 0% 

Help with topmenus not displaying


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pilger
Senior Member
Join Date: Sep 2010
Old 04-28-2015 , 23:28   Help with topmenus not displaying
Reply With Quote #1

Hey guys,

I'm trying to learn how to use the topmenus feature, but I've found very little information about it here and on the internet.

I'm trying to do something like this:
Code:
#pragma semicolon 1

#include <string>
#include <sourcemod>
#include <topmenus>

new Handle:hNewTopmenu;

public OnPluginStart()
{
    LoadTranslations("common.phrases");

    RegConsoleCmd("newtopmenu", NewTopmenu);
}

public OnAllPluginsLoaded()
{
    CreateNewTopmenu();
}


public    Action:NewTopmenu (client, args)
{
    PrintToChatAll("ADEMIR!");
    DisplayTopMenu(hNewTopmenu, client, TopMenuPosition_Start);
    return Plugin_Handled;
}

CreateNewTopmenu ()
{
    new TopMenuObject:category1, TopMenuObject:category2 = INVALID_TOPMENUOBJECT;

    hNewTopmenu = CreateTopMenu(DefaultCategoryHandler);
   
    category1 = AddToTopMenu(hNewTopmenu, "TEST1!", TopMenuObject_Category, DefaultCategoryHandler, INVALID_TOPMENUOBJECT);

    category2 = AddToTopMenu(hNewTopmenu, "TEST1!", TopMenuObject_Category, DefaultCategoryHandler, INVALID_TOPMENUOBJECT);

    AddToTopMenu(hNewTopmenu,  "sm_poke", TopMenuObject_Item, AdminMenu_Poke, category2, "sm_poke", ADMFLAG_SLAY);
}

public DefaultCategoryHandler (Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength)
{
    if (action == TopMenuAction_DisplayTitle)
    {
        Format(buffer, maxlength, "Display Title", param);
        PrintToChatAll("Title");
    }
    else if (action == TopMenuAction_DisplayOption)
    {
        Format(buffer, maxlength, "Display Option", param);
        PrintToChatAll("Option");
    }

}

public AdminMenu_Poke (Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength)
{
    if (action == TopMenuAction_DisplayOption)
    {
        Format(buffer, maxlength, "Poke");
    }
    else if (action == TopMenuAction_SelectOption)
    {
        PrintToChatAll("POKE!");
        /* Do something! client who selected item is in param */
    }
}
But the menu isn't being displayed to the client.

Any ideas?
__________________

Last edited by pilger; 04-28-2015 at 23:35.
pilger is offline
pilger
Senior Member
Join Date: Sep 2010
Old 04-28-2015 , 23:38   Re: Help with topmenus not displaying
Reply With Quote #2

Nevermind this, guys. I've found the problem. I was trying to create two categories with the same name by mistake.
Code:
    category1 = AddToTopMenu(hNewTopmenu, "TEST1!", TopMenuObject_Category, DefaultCategoryHandler, INVALID_TOPMENUOBJECT);

    category2 = AddToTopMenu(hNewTopmenu, "TEST1!", TopMenuObject_Category, DefaultCategoryHandler, INVALID_TOPMENUOBJECT);
Once I changed to
Code:
    category1 = AddToTopMenu(hNewTopmenu, "TEST1!", TopMenuObject_Category, DefaultCategoryHandler, INVALID_TOPMENUOBJECT);

    category2 =  AddToTopMenu(hNewTopmenu, "TEST2!", TopMenuObject_Category,  DefaultCategoryHandler, INVALID_TOPMENUOBJECT);
It worked just fine.

If the Moderators don't mind, I'm gonna leave this here for future reference, since there's little material about this subject on the forums. Might help someone in the future.
__________________

Last edited by pilger; 04-28-2015 at 23:40.
pilger 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 01:56.


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