Raised This Month: $ Target: $400
 0% 

newmenus problem.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 08-20-2015 , 08:19   Re: newmenus problem.
Reply With Quote #1

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
luxor
Member
Join Date: Jan 2014
Old 08-20-2015 , 09:09   Re: newmenus problem.
Reply With Quote #2

Quote:
Originally Posted by Nextra View Post
You forgot to post the code to your "Answers_SubMenu" handler, but here's a rough outline of what would solve your problem:
it is useless, not here is the problem...

Quote:
Originally Posted by Nextra View Post
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.
Answers_SubMenu won't be called, because another menu will display and will close my menu..

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...
luxor is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:43.


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