AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Add fake menu_additem ( New Menus ) (https://forums.alliedmods.net/showthread.php?t=107436)

xbatista 10-26-2009 14:48

Add fake menu_additem ( New Menus )
 
How to add a fake text to the menu and it can't be pressed, just a text also with numbers . ?

PHP Code:

menu_additem(menu"Hello""fake"0); 

I don't want to use old style menu :/

unnyquee 10-26-2009 15:03

Re: Add fake menu_additem ( New Menus )
 
In your menu_function():
PHP Code:

menu_additem(menu"Fake menu-link""9"0); 

In your menu_handler():
PHP Code:

switch(item)
{
    case 
9:
    {
        return 
PLUGIN_HANDLED;
    }


Hope it works!

xbatista 10-26-2009 15:21

Re: Add fake menu_additem ( New Menus )
 
I don't want it handled, I just want it unpressable :/

uxMal 10-26-2009 15:24

Re: Add fake menu_additem ( New Menus )
 
Make a callback for the menuitem and return ITEM_DISABLED in the callback...

grimvh2 10-26-2009 15:29

Re: Add fake menu_additem ( New Menus )
 
Is there any reason for not wanting it to be called?

Just call your menu back when it gets pressed

Exolent[jNr] 10-26-2009 15:36

Re: Add fake menu_additem ( New Menus )
 
Quote:

Originally Posted by uxMal (Post 972776)
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 ); }

xbatista 10-26-2009 15:38

Re: Add fake menu_additem ( New Menus )
 
Thanks much! I didn't really know what the functions means.
Btw ,works fine.

Emp should add to his 'New Menus' tutorial about this.

Alucard^ 10-26-2009 17:32

Re: Add fake menu_additem ( New Menus )
 
Or maybe you can use:

Code:
/**  * Adds a text line to a menu.  Only available in amxmodx 1.8.1 and above.  *  * @param menu            Menu resource identifier.  * @param text            Text to add.  * @param slot            1 (default) if the line should shift the numbering down.  *                         0 if the line should be a visual shift only.  * @noreturn  * @error                Invalid menu resource.  */ native menu_addtext(menu, const text[], slot=1);

xbatista 10-26-2009 17:36

Re: Add fake menu_additem ( New Menus )
 
That sucks , I've tryied to add text, I was getting errors in log + it not associates with 'item', menucallback did the trick

Alucard^ 10-26-2009 23:33

Re: Add fake menu_additem ( New Menus )
 
Well yeah, thats true, it not associates with item, but... about the errors in log.. that is becouse you are doing something wrong =p. If I am not wrong, you only can use that native when you have an item in the menu.


All times are GMT -4. The time now is 17:44.

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