newmenus problem.
How can i check if a player has a menu open or closed ?
i mean... i create a menu with menu_create (added some items with menu_additem blablabla) after I displayed it menu_display to that player.... but another plugin used show_menu( 0, 0, "^n", 1 ); to destroy all menus from all players... and when the first plugin auto-destroyed the menu (created with menu_create) i receive an error... like that : L 08/18/2015 - 23:26:42: Start of error session. L 08/18/2015 - 23:26:42: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20150818.log") L 08/18/2015 - 23:26:42: Invalid menu id 3(5) L 08/18/2015 - 23:26:42: [AMXX] Displaying debug trace (plugin "plugin.amxx", version "1.0") L 08/18/2015 - 23:26:42: [AMXX] Run time error 10: native error (native "menu_destroy") L 08/18/2015 - 23:26:42: [AMXX] [0] race.sma::Auto-Refuse (line 317) the issue is that we don't have a menu_exists... (http://www.amxmodx.org/api/newmenus) and when i call the menu_destroy native, the menu is already destroyed. |
Re: newmenus problem.
For starters there is player_menu_info() which allows you to check if a menu is being displayed to the player, and which one it is.
But I don't think that is your problem, your problem is probably that you don't correctly handle your menu being closed. When another plugin overwrites your menu, your menu callback is fired with MENU_EXIT (as you can see here and here). Your plugin handles that event and probably destroys the menu. It makes no sense to call menu_destroy() again on the menu, so this behavior is expected. Unless you can show me a test case where the menu really is destroyed without your plugin noticing it, I don't believe this is an issue with AMXX. |
Re: newmenus problem.
My plugin.
Code:
public RaceMenu_Handler(id, menu, item) // there is a hander to another menu... but here is created the problematic menu. now i looked after player_menu_info() and it should solve my problem... but anyway how can i know if this is my menu, not another menu.. because maybe i don't want to close any menu, just my menu. ps: yea.. this can work too Code:
.... Code:
... |
Re: newmenus problem.
To put it bluntly menu_exists(menu) is crappy API design. Menu ids are reused by AMXX and not owned by plugins, so that native would not help. Even if that weren't the case, your plugin can very easily tell if a menu has been destroyed or not by assigning it to an array and remembering the menu id by itself.
You forgot to post the code to your "Answers_SubMenu" handler, but here's a rough outline of what would solve your problem: PHP Code:
|
Re: newmenus problem.
Quote:
Quote:
All the things will happen in this way : 1. menu created and desplayed from RaceMenu_Handler - my plugin 2. menu will be closed/distroyed and Answers_SubMenu won't be called - another plugin (which i deleted the source :| ) 3. refuse will be called and a error will be appear - my plugin so.. if is not an issue, and a new native menu_exists can't be created... how cand i know if my menu is destroyed or not ? tell me... |
Re: newmenus problem.
What AMXX version do you use? If you're using 1.8.3-dev, Answers_SubMenu will be called for sure.
|
Re: newmenus problem.
]meta list
Currently loaded plugins: description stat pend file vers src load unlod [ 1] AMX Mod X RUN - amxmodx_mm_i386. v1.8.3-d ini Start ANY [ 2] CStrike RUN - cstrike_amxx_i38 v1.8.3-d pl2 ANY ANY [ 3] FakeMeta RUN - fakemeta_amxx_i3 v1.8.3-d pl2 ANY ANY [ 4] Engine RUN - engine_amxx_i386 v1.8.3-d pl2 ANY ANY [ 5] Ham Sandwich RUN - hamsandwich_amxx v1.8.3-d pl2 ANY ANY [ 6] MySQL RUN - mysql_amxx_i386. v1.8.3-d pl2 ANY ANY [ 7] Fun RUN - fun_amxx_i386.so v1.8.3-d pl2 ANY ANY [ 8] CSX RUN - csx_amxx_i386.so v1.8.3-d pl2 ANY ANY 8 plugins, 8 running |
Re: newmenus problem.
Then I don't see the issue ; Nextra showed you in a link, that when show_menu is called, if there is already a newmenu displayed, the callback will be called. What said Nextra should solve your issue.
Make sure you're using latest dev build. |
Re: newmenus problem.
Nice fail edited meta list.
|
Re: newmenus problem.
We fixed precisely this scenario in 1.8.3 by ensuring that the menu handler will be called if other plugins overwrite your menu. Your issue is that you are trying to destroy the menu twice, which strongly points towards Answers_SubMenu being called. It is called, destroys the menu and then the timer hits and attempts to destroy it again.
|
All times are GMT -4. The time now is 04:14. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.