Raised This Month: $ Target: $400
 0% 

menu_destroy doesn't clear the variable?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Elusive138
Senior Member
Join Date: Dec 2010
Old 09-30-2011 , 03:53   menu_destroy doesn't clear the variable?
Reply With Quote #1

PHP Code:
new menu menu_create(titlehandler// menu == new menu id
menu_destroy(menu// menu == old, invalid menu id 
Is there any particular reason menu_destroy doesn't set the variable to 0, like ArrayDestroy does?

For now I'm using this, is there a better method or another way I should be doing things?
PHP Code:
menu_safedestroy(&menuid) {
    if (
menuid)
        
menu_destroy(menuid);
    
menuid 0;


Last edited by Elusive138; 09-30-2011 at 03:57.
Elusive138 is offline
Jenkins
AlliedModders Donor
Join Date: Jul 2011
Old 09-30-2011 , 09:10   Re: menu_destroy doesn't clear the variable?
Reply With Quote #2

i use:
Code:
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
and in handle:
Code:
if(item == MENU_EXIT)
{
	menu_destroy(menu)
	return PLUGIN_HANDLED
}
example menu:
Code:
public Menu(id)
{
	new menu = menu_create("Menu", "MenuHandle")
	
	menu_additem(menu, "Restart Round", "1", 0)
	
	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
	menu_display(id, menu, 0)
}

public MenuHandle(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED
	}
	
	new data[6], name[64]
	new access, callback
	
	menu_item_getinfo (menu, item, access, data, 5, name, 63, callback)
	new key = str_to_num (data)
	
	switch(key)
	{
		case 1:
		{
			//code
		}
	}
	return PLUGIN_CONTINUE
}
Jenkins is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 09-30-2011 , 09:51   Re: menu_destroy doesn't clear the variable?
Reply With Quote #3

Yeah, just set the handle to null manually.
__________________
hleV 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 19:35.


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