AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   New Menu Disable a Option (https://forums.alliedmods.net/showthread.php?t=140121)

NzGamers 10-09-2010 03:54

New Menu Disable a Option
 
PHP Code:

        formatex(szMenuItemscharsmax(szMenuItems), "\dHE Nade ( $%i )"get_pcvar_num(p_iCostHe));
        
menu_additem(g_iMenuszMenuItems"1"0); 


im using /d to show the disabled colour. but i want to make that option not able to be pressed. so when i press 1 it wont work. and the menu will be still there.

Exolent[jNr] 10-09-2010 03:59

Re: New Menu Disable a Option
 
Moved to Scripting Help because you are actually making it yourself.

You should use a callback to handle situations like this.
Here's an example: https://forums.alliedmods.net/showpo...0&postcount=95

NzGamers 10-09-2010 04:42

Re: New Menu Disable a Option
 
Quote:

Originally Posted by Exolent[jNr] (Post 1319755)
Moved to Scripting Help because you are actually making it yourself.

You should use a callback to handle situations like this.
Here's an example: https://forums.alliedmods.net/showpo...0&postcount=95

i did that it doesnt work. even tho its grey/disabled when i press on that option it still goes to the handler. how would i do like old menu. like if i dont enable the key they cant press

Exolent[jNr] 10-09-2010 04:59

Re: New Menu Disable a Option
 
Show your code that you said doesn't work.

shuttle_wave 10-09-2010 05:08

Re: New Menu Disable a Option
 
PHP Code:

// HideNSeek Shop Main Menu
public HideNSeekShop(id)
{
    new 
g_iMenu menu_create("\yHide'NSeek Shop Menu:^n""HideNSeekShopMenu_handler");
    new 
callback menu_makecallback("MenuCallback");
    
    static 
szMenuItems[64];
    
    
// He Grenade
    
if(cs_get_user_money(id) < get_pcvar_num(p_iCostHe))
    {
        
formatex(szMenuItemscharsmax(szMenuItems), "\dHE Nade ( $%i )"get_pcvar_num(p_iCostHe));
        
menu_additem(g_iMenuszMenuItems"1"_callback);
    }
    else if(
cs_get_user_money(id) >= get_pcvar_num(p_iCostHe))
    {
        
formatex(szMenuItemscharsmax(szMenuItems), "\wHE Nade ( \y$%i\w )"get_pcvar_num(p_iCostHe));
        
menu_additem(g_iMenuszMenuItems"1"0);
    } 

use that as an example

Exolent[jNr] 10-09-2010 05:17

Re: New Menu Disable a Option
 
Where is the function for the callback?

shuttle_wave 10-09-2010 06:52

Re: New Menu Disable a Option
 
Quote:

Originally Posted by Exolent[jNr] (Post 1319819)
Where is the function for the callback?

isnt it on the link u gave.

PHP Code:

public MenuCallback(clientmenuitem)
{
    new 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfo2__callback);
    
    if( 
str_to_num(info) == )
    {
        
// item 1
        
return is_user_alive(client) ? ITEM_ENABLED ITEM_DISABLED;
    }
    
    return 
ITEM_ENABLED;
}

public 
MenuHandle(clientmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return;
    }
    
    new 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfo2__callback);
    
menu_destroy(menu);
    
    if( 
str_to_num(info) == )
    {
        
// player is alive and chose item #1
    
}



NzGamers 10-09-2010 10:07

Re: New Menu Disable a Option
 
Quote:

Originally Posted by shuttle_wave (Post 1319903)
isnt it on the link u gave.

PHP Code:

public MenuCallback(clientmenuitem)
{
    new 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfo2__callback);
    
    if( 
str_to_num(info) == )
    {
        
// item 1
        
return is_user_alive(client) ? ITEM_ENABLED ITEM_DISABLED;
    }
    
    return 
ITEM_ENABLED;
}

public 
MenuHandle(clientmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return;
    }
    
    new 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfo2__callback);
    
menu_destroy(menu);
    
    if( 
str_to_num(info) == )
    {
        
// player is alive and chose item #1
    
}



yes i have that in my code and i did according to ur example. when i press on that number is still works. I want it so u cant press on that option. its disabled.

Exolent[jNr] 10-09-2010 11:58

Re: New Menu Disable a Option
 
:rtfm: Stop copying and pasting!
Read the code before you use it.

If you even read the code from that post, you would see it was a menu for alive players, so the option is disabled if you are dead and enabled if you are alive.
With that said, try to figure out how the callback function works.

fysiks 10-09-2010 18:34

Re: New Menu Disable a Option
 
When using the callback (in the link that Exolent gave you) you won't need to do the \d at all. The menu functions do that for you.

Quote:

Originally Posted by shuttle_wave (Post 1319812)
PHP Code:

// HideNSeek Shop Main Menu
public HideNSeekShop(id)
{
    
// stuff
    


use that as an example

Wow, if you don't know what you are doing then don't post.


All times are GMT -4. The time now is 10:26.

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