AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   menu_destroy doesn't clear the variable? (https://forums.alliedmods.net/showthread.php?t=168496)

Elusive138 09-30-2011 03:53

menu_destroy doesn't clear the variable?
 
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;



Jenkins 09-30-2011 09:10

Re: menu_destroy doesn't clear the variable?
 
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
}


hleV 09-30-2011 09:51

Re: menu_destroy doesn't clear the variable?
 
Yeah, just set the handle to null manually.


All times are GMT -4. The time now is 19:35.

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