View Single Post
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 08-20-2015 , 08:19   Re: newmenus problem.
Reply With Quote #4

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:
public RaceMenu_Handler(idmenuitem) {
// ...
   
new menu menu_create(Text"Answers_SubMenu");
   
challenge_menu[id] = menu// save the menu id
// ...
}

public 
Answers_SubMenu(idmenuitem) {
// ...
   
challenge_menu[id] = -1// reset the menu id to an invalid id
// ...
}

public 
Refuse(id) {
   if (
challenge_menu[id] != -1)
      
menu_destroy(challenge_menu[id]); // only destroy if the menu still exists

Depending on how your current "Answers_SubMenu" looks your code would break even if the player presses exit manually. The code above is how you should usually solve this.
__________________
In Flames we trust!
Nextra is offline