Raised This Month: $ Target: $400
 0% 

Add fake menu_additem ( New Menus )


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-26-2009 , 14:48   Add fake menu_additem ( New Menus )
Reply With Quote #1

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 :/
__________________
xbatista is offline
Send a message via Skype™ to xbatista
unnyquee
Senior Member
Join Date: Jun 2009
Location: Constanta, Romania
Old 10-26-2009 , 15:03   Re: Add fake menu_additem ( New Menus )
Reply With Quote #2

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!
__________________
unnyquee is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-26-2009 , 15:21   Re: Add fake menu_additem ( New Menus )
Reply With Quote #3

I don't want it handled, I just want it unpressable :/
__________________
xbatista is offline
Send a message via Skype™ to xbatista
uxMal
Member
Join Date: Oct 2007
Old 10-26-2009 , 15:24   Re: Add fake menu_additem ( New Menus )
Reply With Quote #4

Make a callback for the menuitem and return ITEM_DISABLED in the callback...
uxMal is offline
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
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-26-2009 , 15:38   Re: Add fake menu_additem ( New Menus )
Reply With Quote #6

Thanks much! I didn't really know what the functions means.
Btw ,works fine.

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

Last edited by xbatista; 10-26-2009 at 15:42.
xbatista is offline
Send a message via Skype™ to xbatista
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 10-26-2009 , 15:29   Re: Add fake menu_additem ( New Menus )
Reply With Quote #7

Is there any reason for not wanting it to be called?

Just call your menu back when it gets pressed
__________________
I am out of order!
grimvh2 is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 10-26-2009 , 17:32   Re: Add fake menu_additem ( New Menus )
Reply With Quote #8

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);
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-26-2009 , 17:36   Re: Add fake menu_additem ( New Menus )
Reply With Quote #9

That sucks , I've tryied to add text, I was getting errors in log + it not associates with 'item', menucallback did the trick
__________________
xbatista is offline
Send a message via Skype™ to xbatista
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 10-26-2009 , 23:33   Re: Add fake menu_additem ( New Menus )
Reply With Quote #10

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.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
Reply



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