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?
__________________