Raised This Month: $ Target: $400
 0% 

Add fake menu_additem ( New Menus )


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-26-2009 , 15:36   Re: Add fake menu_additem ( New Menus )
Reply With Quote #5

Quote:
Originally Posted by uxMal View Post
Make a callback for the menuitem and return ITEM_DISABLED in the callback...
Best answer of the thread.

Example 1:

Code:
new g_hCallback; public plugin_init( ) {     g_hCallback = menu_makecallback( "MenuCallback" ); } ShowMenu( client ) {     new hMenu = menu_create( "Some Menu", "MenuHandler" );         menu_additem( hMenu, "You can press me", "1" );     menu_additem( hMenu, "You can't press me", "2", _, g_hCallback );     menu_additem( hMenu, "You can press me, too", "3" );         menu_display( client, hMenu ); } public MenuCallback( client, hMenu, iItem ) {     // iItem starts at 0     if( iItem == 1 ) {         return ITEM_DISABLED;     }         return ITEM_ENABLED; } public MenuHandler( client, hMenu, iItem ) {     menu_destroy( hMenu );         if( iItem == MENU_EXIT ) {         return;     }         switch( iItem ) {         case 0: {             client_print( client, print_chat, "You chose option #1" );         }         case 2: {             client_print( client, print_chat, "You chose option #3" );         }     }         ShowMenu( client ); }

Example 2:

Code:
new g_hMenu; public plugin_init( ) {     new hCallback = menu_makecallback( "MenuCallback" );         g_hMenu = menu_create( "Some Menu", "MenuHandler" );         menu_additem( g_hMenu, "You can press me", "1" );     menu_additem( g_hMenu, "You can't press me", "2", _, hCallback );     menu_additem( g_hMenu, "You can press me, too", "3" ); } ShowMenu( client ) {     menu_display( client, g_hMenu ); } public MenuCallback( client, hMenu, iItem ) {     // iItem starts at 0     if( iItem == 1 ) {         return ITEM_DISABLED;     }         return ITEM_ENABLED; } public MenuHandler( client, hMenu, iItem ) {     if( iItem == MENU_EXIT ) {         return;     }         switch( iItem ) {         case 0: {             client_print( client, print_chat, "You chose option #1" );         }         case 2: {             client_print( client, print_chat, "You chose option #3" );         }     }         ShowMenu( client ); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 17:44.


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