Raised This Month: $ Target: $400
 0% 

Disable items in the menu


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-29-2009 , 02:10   Re: Disable items in the menu
Reply With Quote #3

The bad thing about using menu_additem() is that it registers the key and therefore the menu will call the handler when that key is pressed.

So, my solution to use menu_addtext(menu,"\d3. Text Here",1) should theoretically work but it seems that the "new menus" system is flawed when using menu_addtext(). So, unfortunately this will not work.

Using the "old" menu system might be best in this situation.

I have another idea that might "work." brb

UPDATE:

Ok, so I think I found the best work-around:

PHP Code:
public TestMenu(id)
{
    new 
Menu menu_create("\yTest Menu""test_show")
    
    
// g_bool = get_pcvar_num(p_test)
    
    
menu_additem(Menu"\wTest 1""1"0)
    
menu_additem(Menu"\wTest 2""2"0)
    if( 
g_bool )
    {
        
menu_additem(Menu"\dTest 3""99")
    }
    else
    {
        
menu_additem(Menu"\wTest 3""3"0)
    }
    
menu_additem(Menu"\wTest 4""4"0)
    
menu_additem(Menu"\wTest 5""5"0)
    
menu_additem(Menu"\wTest 6""6"0)
    
menu_additem(Menu"\wTest 7""7"0)
    
menu_additem(Menu"\wTest 8""8"0)
    
menu_additem(Menu"\wTest 9""9"0)
    
menu_additem(Menu"\wTest 10""10"0)

    
menu_setprop(Menu,MPROP_EXITNAME,"Salir")
    
menu_setprop(MenuMPROP_EXITMEXIT_ALL)
    
    
menu_display(idMenu0)
    
    return 
PLUGIN_HANDLED
}

public 
test_show(idMenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(Menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
szData[6]
    new 
iAccess
    
new iCallback
    
new szName[64]
    
    
menu_item_getinfo(MenuitemiAccessszData5szName63iCallback)
    
    new 
iData str_to_num(szData)
    
    switch(
iData)
    {
        case 
1..10:
        {
            
// Client selected valid item.
            
client_print(idprint_chat"test %d"iData)
        }
        case 
99:
        {
            
// "id" selected disabled item.
            
TestMenu(id// Re-display the menu to emulate "not being able to select that option."  Unfortunately will only work well on page 0.
            
        
}
    }
    
    
menu_destroy(Menu)
    return 
PLUGIN_HANDLED

Remember to destroy the menu at the end of the function. Also, the "i" prefix if for integers. Use "sz" for strings, I have changed them above accordingly, take a look.
__________________

Last edited by fysiks; 07-29-2009 at 02:37.
fysiks is offline
 



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:29.


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