Raised This Month: $ Target: $400
 0% 

New Menu Disable a Option


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NzGamers
Member
Join Date: Jul 2009
Old 10-09-2010 , 03:54   New Menu Disable a Option
Reply With Quote #1

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.
NzGamers is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-09-2010 , 03:59   Re: New Menu Disable a Option
Reply With Quote #2

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
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
NzGamers
Member
Join Date: Jul 2009
Old 10-09-2010 , 04:42   Re: New Menu Disable a Option
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
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
NzGamers is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-09-2010 , 04:59   Re: New Menu Disable a Option
Reply With Quote #4

Show your code that you said doesn't work.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 10-09-2010 , 05:08   Re: New Menu Disable a Option
Reply With Quote #5

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
__________________
JailBreak Mod with Plugin API ( 90% ) Public

Last edited by shuttle_wave; 10-09-2010 at 05:14.
shuttle_wave is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-09-2010 , 05:17   Re: New Menu Disable a Option
Reply With Quote #6

Where is the function for the callback?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 10-09-2010 , 06:52   Re: New Menu Disable a Option
Reply With Quote #7

Quote:
Originally Posted by Exolent[jNr] View Post
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
    
}

__________________
JailBreak Mod with Plugin API ( 90% ) Public
shuttle_wave is offline
NzGamers
Member
Join Date: Jul 2009
Old 10-09-2010 , 10:07   Re: New Menu Disable a Option
Reply With Quote #8

Quote:
Originally Posted by shuttle_wave View Post
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.
NzGamers is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-09-2010 , 11:58   Re: New Menu Disable a Option
Reply With Quote #9

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.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-09-2010 , 18:34   Re: New Menu Disable a Option
Reply With Quote #10

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 View Post
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.
__________________
fysiks 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 10:26.


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