AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   New AMXX Menu System (https://forums.alliedmods.net/showthread.php?t=46364)

LaineN 08-17-2009 15:01

Re: New AMXX Menu System
 
But how to detect if the menu was replaced by another menu instead of being closed?

fysiks 08-17-2009 15:06

Re: New AMXX Menu System
 
If you only use those 5 submenus then it will work perfectly. If you overwrite the menu with some other menu not in this heirarchy then you would set the value of g_iCurrentMenu appropriately.

Emp` 08-17-2009 15:24

Re: New AMXX Menu System
 
Quote:

Originally Posted by LaineN (Post 903599)
But how to detect if the menu was replaced by another menu instead of being closed?

If a menu overwrites another menu, MENU_EXIT is called on the first menu.

Emp` 08-17-2009 20:15

Re: New AMXX Menu System
 
Quote:

Originally Posted by Alka (Post 903694)
A little kinda OFF-Topic, but on OldMenus overwrite can be detected ?

Correct.

LaineN 08-18-2009 03:36

Re: New AMXX Menu System
 
It doesn't detect old menus for me.

I use this plugin to see what g_current_menu[id] is:

PHP Code:

#include <amxmodx>
#include <engine>

enum
{
    
MENU_NONE,
    
    
MENU_MAIN,
    
MENU_SUB1,
    
MENU_SUB2,
    
MENU_SUB3,
    
MENU_SUB4,
    
MENU_SUB5
};

new 
g_current_menu[33];

public 
plugin_init()
{
    
register_clcmd("say /menu""ShowMainMenu");
}

public 
client_putinserver(id)
{
    
g_current_menu[id] = MENU_NONE;
}

public 
client_PreThink(id)
{
    if ( 
is_user_connected(id) )
    {
        
set_hudmessage(255255255, -1.00.000.01.00.250.25, -1);
        
show_hudmessage(id"g_current_menu[id] = %i"g_current_menu[id]);
    }
}

public 
ShowMainMenu(id)
{
    
g_current_menu[id] = MENU_MAIN;
    
    new 
menu menu_create("Main Menu""MainMenuHandle");
    
menu_additem(menu"Sub Menu 1""1");
    
menu_additem(menu"Sub Menu 2""2");
    
menu_additem(menu"Sub Menu 3""3");
    
menu_additem(menu"Sub Menu 4""4");
    
menu_additem(menu"Sub Menu 5""5");
    
    
menu_display(idmenu);
}

public 
MainMenuHandle(idmenuitem)
{
    if ( 
item == MENU_EXIT )
    {
        
g_current_menu[id] = MENU_NONE;
        
menu_destroy(menu);
        return;
    }
    
    static 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfocharsmax(info), __callback);
    
menu_destroy(menu);
    
    switch ( 
info[0] )
    {
        case 
'1'ShowSubMenu1(id);
        case 
'2'ShowSubMenu2(id);
        case 
'3'ShowSubMenu3(id);
        case 
'4'ShowSubMenu4(id);
        case 
'5'ShowSubMenu5(id);
    }
}

public 
ShowSubMenu1(id)
{
    
g_current_menu[id] = MENU_SUB1;
    
    new 
menu menu_create("Sub Menu 1""SubMenu1Handle");
    
menu_additem(menu"1""1");
    
menu_additem(menu"2""2");
    
menu_additem(menu"3""3");
    
menu_additem(menu"4""4");
    
menu_additem(menu"5""5");
    
menu_additem(menu"6""6");
    
    
menu_display(idmenu);
}

public 
SubMenu1Handle(idmenuitem)
{
    if ( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        
ShowMainMenu(id);
        return;
    }
    
    static 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfocharsmax(info), __callback);
    
menu_destroy(menu);
    
    switch ( 
info[0] )
    {
        case 
'1'client_print(idprint_chat"You selected 1");
        case 
'2'client_print(idprint_chat"You selected 2");
        case 
'3'client_print(idprint_chat"You selected 3");
        case 
'4'client_print(idprint_chat"You selected 4");
        case 
'5'client_print(idprint_chat"You selected 5");
        case 
'6'client_print(idprint_chat"You selected 6");
    }
    
    
ShowSubMenu1(id);
}

public 
ShowSubMenu2(id)
{
    
g_current_menu[id] = MENU_SUB2;
    
    new 
menu menu_create("Sub Menu 2""SubMenu2Handle");
    
menu_additem(menu"1""1");
    
menu_additem(menu"2""2");
    
menu_additem(menu"3""3");
    
menu_additem(menu"4""4");
    
menu_additem(menu"5""5");
    
menu_additem(menu"6""6");
    
    
menu_display(idmenu);
}

public 
SubMenu2Handle(idmenuitem)
{
    if ( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        
ShowMainMenu(id);
        return;
    }
    
    static 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfocharsmax(info), __callback);
    
menu_destroy(menu);
    
    switch ( 
info[0] )
    {
        case 
'1'client_print(idprint_chat"You selected 1");
        case 
'2'client_print(idprint_chat"You selected 2");
        case 
'3'client_print(idprint_chat"You selected 3");
        case 
'4'client_print(idprint_chat"You selected 4");
        case 
'5'client_print(idprint_chat"You selected 5");
        case 
'6'client_print(idprint_chat"You selected 6");
    }
    
    
ShowSubMenu2(id);
}

public 
ShowSubMenu3(id)
{
    
g_current_menu[id] = MENU_SUB3;
    
    new 
menu menu_create("Sub Menu 3""SubMenu3Handle");
    
menu_additem(menu"1""1");
    
menu_additem(menu"2""2");
    
menu_additem(menu"3""3");
    
menu_additem(menu"4""4");
    
menu_additem(menu"5""5");
    
menu_additem(menu"6""6");
    
    
menu_display(idmenu);
}

public 
SubMenu3Handle(idmenuitem)
{
    if ( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        
ShowMainMenu(id);
        return;
    }
    
    static 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfocharsmax(info), __callback);
    
menu_destroy(menu);
    
    switch ( 
info[0] )
    {
        case 
'1'client_print(idprint_chat"You selected 1");
        case 
'2'client_print(idprint_chat"You selected 2");
        case 
'3'client_print(idprint_chat"You selected 3");
        case 
'4'client_print(idprint_chat"You selected 4");
        case 
'5'client_print(idprint_chat"You selected 5");
        case 
'6'client_print(idprint_chat"You selected 6");
    }
    
    
ShowSubMenu3(id);
}

public 
ShowSubMenu4(id)
{
    
g_current_menu[id] = MENU_SUB4;
    
    new 
menu menu_create("Sub Menu 4""SubMenu4Handle");
    
menu_additem(menu"1""1");
    
menu_additem(menu"2""2");
    
menu_additem(menu"3""3");
    
menu_additem(menu"4""4");
    
menu_additem(menu"5""5");
    
menu_additem(menu"6""6");
    
    
menu_display(idmenu);
}

public 
SubMenu4Handle(idmenuitem)
{
    if ( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        
ShowMainMenu(id);
        return;
    }
    
    static 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfocharsmax(info), __callback);
    
menu_destroy(menu);
    
    switch ( 
info[0] )
    {
        case 
'1'client_print(idprint_chat"You selected 1");
        case 
'2'client_print(idprint_chat"You selected 2");
        case 
'3'client_print(idprint_chat"You selected 3");
        case 
'4'client_print(idprint_chat"You selected 4");
        case 
'5'client_print(idprint_chat"You selected 5");
        case 
'6'client_print(idprint_chat"You selected 6");
    }
    
    
ShowSubMenu4(id);
}

public 
ShowSubMenu5(id)
{
    
g_current_menu[id] = MENU_SUB5;
    
    new 
menu menu_create("Sub Menu 5""SubMenu5Handle");
    
menu_additem(menu"1""1");
    
menu_additem(menu"2""2");
    
menu_additem(menu"3""3");
    
menu_additem(menu"4""4");
    
menu_additem(menu"5""5");
    
menu_additem(menu"6""6");
    
    
menu_display(idmenu);
}

public 
SubMenu5Handle(idmenuitem)
{
    if ( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        
ShowMainMenu(id);
        return;
    }
    
    static 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfocharsmax(info), __callback);
    
menu_destroy(menu);
    
    switch ( 
info[0] )
    {
        case 
'1'client_print(idprint_chat"You selected 1");
        case 
'2'client_print(idprint_chat"You selected 2");
        case 
'3'client_print(idprint_chat"You selected 3");
        case 
'4'client_print(idprint_chat"You selected 4");
        case 
'5'client_print(idprint_chat"You selected 5");
        case 
'6'client_print(idprint_chat"You selected 6");
    }
    
    
ShowSubMenu5(id);


And when I overwrite for example 'Main Menu' with the 'AMX Mod X Menu' or 'Select a team' menu, the value of g_current_menu[id] still is 1. But when I overwrite it with a menu from any of my own plugins with new menu system the value goes to 0.

Is there a way to detect the old menu overwrites?

Exolent[jNr] 08-18-2009 03:45

Re: New AMXX Menu System
 
Try:
Code:
new bool:g_bShowingMenu[ 33 ]; public plugin_init( ) {     register_message( get_user_msgid( "ShowMenu" ), "MessageShowMenu" ); } public MessageShowMenu( iMsgId, iDest, client ) {     if( g_bShowingMenu[ client ] )     {         g_bShowingMenu[ client ] = false;         return;     }         // player opened a new menu } ShowYourOwnMenu( client ) {     g_bShowingMenu[ client ] = true;         // show menu }

SnoW 08-18-2009 06:02

Re: New AMXX Menu System
 
I believe you should also hook death, spawn and disconnect if you want to know surely a player is viewing some menu.

LaineN 08-18-2009 15:56

Re: New AMXX Menu System
 
Quote:

Originally Posted by Exolent[jNr] (Post 904208)
Try:

Lol! :| That worked for 'Buy Menu' and 'Select a team' menu, but not for 'AMX Mod X Menu'. Is there any differences between them?

EDIT: I have one more problem with this menus :/

If I have a menu like this:
PHP Code:

new menu menu_create("Main Menu""MainMenuHandle");
menu_additem(menu"1""1");
menu_additem(menu"2""2");
menu_additem(menu"3""3");
menu_additem(menu"4""4");
menu_additem(menu"5""5");
menu_additem(menu"6""6");
menu_additem(menu"7""7");
menu_additem(menu"8""8");

menu_display(idmenu); 

The menu automatically adds an Next and a Back for the menu and the 8 will be in the second page.
I've tried with menu_setprop(menu, MPROP_PERPAGE, 0); and I get them on the same page but the Exit button disappear, do I have to add it by myself to get it to work or is there any other way?

Alka 08-18-2009 16:52

Re: New AMXX Menu System
 
Try menu_setprop( menu, MPROP_PERPAGE, 8 );

Exolent[jNr] 08-18-2009 16:58

Re: New AMXX Menu System
 
Quote:

Originally Posted by Alka (Post 904776)
Try menu_setprop( menu, MPROP_PERPAGE, 8 );

Doesn't work.
I've tried it and it gave me an error in the logs saying that you can't have more than 7 per page.


All times are GMT -4. The time now is 05:57.

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