View Full Version : [HELP] Menu
puga4off
10-14-2014, 21:37
Hi everyone. I just read that one of the reasons of ending menu is MenuEnd_Selected. How do not close menu if item was selected (Im making plugin, where client can choose several options in menu). First idea was to create menu on action MenuAction_Selected, but if client was on the second page and i create menu at this iteam, the menu will be changed. What to do? Thanks
I think what people do is just recreate the entire menu.
... At least I do based on seeing some other plugin do that.
To get to the second page... I guess you could check Param2. 0-6 (appears as options 1-7 in the menu) would be page 1, 7+ being page 2, etc.
Probably could use modulo or something.
friagram
10-15-2014, 04:28
You don't need to make new menus. If menus don't change, you should be storing them as global handles and keeping them open.
Anyways, you can use https://sm.alliedmods.net/api/index.php?fastload=show&id=189& to get the page, and then use https://sm.alliedmods.net/api/index.php?fastload=show&id=183& to display the menu to them.
I usually just make a menu function like showmenu(client, item=0) and pass the item into that to return them.
puga4off
10-16-2014, 03:40
static MyCreateMenu(client, item = 0)
{
new Handle:hmenu = CreateMenu(MyMenuHandler);
SetMenuExitButton(hmenu, true);
SetMenuTitle(hmenu, "some menu");
if (hmenu == INVALID_HANDLE)
{
return;
}
//add items
DisplayMenuAtItem(hmenu, client, item, 20);
}
public MyMenuHandler(Handle:menu, MenuAction:action, client, field)
{
switch(action)
{
case MenuAction_Select :
{
//do something
}
case MenuAction_End :
{
//CloseHandle(menu); alright i will keep menu handle somewhere globaly
}
default : {}
}
}But it closed when client just selected something, how to allow him select more fields without closing
Powerlord
10-16-2014, 11:00
case MenuAction_Select :
{
// do something with the selected item
new item = GetMenuSelectionPosition();
MyCreateMenu(client, item);
}
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.