AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED][CS] New Menus: pressing Back/Next triggers radio commands (https://forums.alliedmods.net/showthread.php?t=159422)

MeRcyLeZZ 06-16-2011 22:48

[SOLVED][CS] New Menus: pressing Back/Next triggers radio commands
 
Using AMXX new menu system, if the menu has multiple pages and you select Back/Next options, report radio messages will be triggered automatically ("8. Negative" and "9. Enemy Down").

NOTE: it seems this only happens if you have used any of the "radio3" commands before calling the menu.

Is anything wrong with the code or is this a bug in AMXX's new menu system? (someone filed a bug report about this but it's yet UNCONFIRMED)

Code:
#include <amxmodx> public plugin_init() {     register_plugin("New Menus Bug", "0", "test")     register_clcmd("say menu", "show_newmenu") } public show_newmenu(id) {     new menuid = menu_create("New Menu", "new_menu_handle")     menu_additem(menuid, "1", "1")     menu_additem(menuid, "2", "2")     menu_additem(menuid, "3", "3")     menu_additem(menuid, "4", "4")     menu_additem(menuid, "5", "5")     menu_additem(menuid, "6", "6")     menu_additem(menuid, "7", "7")     menu_additem(menuid, "8", "8")     menu_additem(menuid, "9", "9")     menu_display(id, menuid) } public new_menu_handle(id, menuid, item) {     // Menu was closed     if (item == MENU_EXIT)     {         menu_destroy(menuid)         return PLUGIN_HANDLED;     }         // Retrieve and display item number     new number[2], dummy     if (menu_item_getinfo(menuid, item, dummy, number, charsmax(number), _, _, dummy))         client_print(id, print_chat, "You selected item number %s", number)         menu_destroy(menuid)     return PLUGIN_HANDLED }

drekes 06-17-2011 05:07

Re: [CS] New Menus: pressing Back/Next triggers radio commands
 
I had this problem before too, haven't found a solution yet

Exolent[jNr] 06-17-2011 10:54

Re: [CS] New Menus: pressing Back/Next triggers radio commands
 
After doing some testing, I noticed a couple things:
1. When you use a radio menu (for example), your "menu code" is kept at that radio menu's menu code until you use the "exit" option.
2. When you open a custom menu from AMXX on top of a default CS menu (like radio menu), it keeps the default CS menu's menu code.

To fix this, you can just set the menu code to 0 every time you use show_menu() or menu_display().
This fix can also be applied to the AMXX core whenever it gets ready to be fixed.

Thanks to Connor for the offset and function in a post of his.

Code:
#include <amxmodx> #include <fakemeta> // m_iMenuCode = 205, "player" linux offset = 5 #define cs_set_user_menu(%1,%2) set_pdata_int(%1, 205, %2, 5) // ... // reset menu code to 0 so we don't conflict with other CS menus cs_set_user_menu(id, 0) // show our own menu menu_display(id, menu)

EDIT:

Replied to the Bug Report. Hopefully this will be fixed in one of the next few developer builds.

MeRcyLeZZ 06-18-2011 16:58

Re: [CS] New Menus: pressing Back/Next triggers radio commands
 
Quote:

Originally Posted by Exolent[jNr] (Post 1490051)
To fix this, you can just set the menu code to 0 every time you use show_menu() or menu_display().

Thanks! Working perfectly now. And the code also fixes another bug: AMXX menus closing automatically when walking out of buyzones (which has also been reported here: https://bugs.alliedmods.net/show_bug.cgi?id=3199)


All times are GMT -4. The time now is 08:22.

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