Raised This Month: $51 Target: $400
 12% 

New Menus and Old Menus


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 03-09-2010 , 12:39   New Menus and Old Menus
Reply With Quote #1

Hey guys, I've been constantly looking though various codes here and there and have always seen different types of menus, and when running code can really see differences..

Some menus allow for a user to declare when it is white text or dark text (as if it were a disabled option) and some codes don't allow this. I have a code that I'm working on that I want to have the feature functionality and I've seen people throw around the "new menu system"

However, I've seen three menu systems throughout the code I've seen.. Is there a thread on this forum that actually shows the new menu system and how to use it? I've looked through scripting help and code snippet's stickies and have not really seen anything..

Means a lot guys, thanks!
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
fR4gn0tiX!
Senior Member
Join Date: Nov 2009
Location: Georgia, Tbilisi
Old 03-09-2010 , 12:41   Re: New Menus and Old Menus
Reply With Quote #2

http://forums.alliedmods.net/showthread.php?t=46364
__________________
fR4gn0tiX! is offline
Send a message via Skype™ to fR4gn0tiX!
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 03-09-2010 , 12:57   Re: New Menus and Old Menus
Reply With Quote #3

Thanks a lot fR4gn0tiX!
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 03-09-2010 , 13:10   Re: New Menus and Old Menus
Reply With Quote #4

Hmmm, very useful tutorial! Just one question that I didn't directly see addressed there.. I noticed that at the new menu item you can use \r before what you say, I am assuming that this is the color red to the text.

How can you perform a check on CVARs to choose the color?

Like, if (!get_cvar_num(CVAR))

Then \d

else

\w

I noticed you could do this with format, but is this the way to do it in this menu system?
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-09-2010 , 14:27   Re: New Menus and Old Menus
Reply With Quote #5

You could do something like:
Code:
if( blah )
   menu_additem(menu, "\dI'm Selection #1", "1", 0);
else
   menu_additem(menu, "\wI'm Selection #1", "", 0);
But using format is not a bad option.

edit: You should have posted this in Scripting Help btw.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-09-2010 , 14:29   Re: New Menus and Old Menus
Reply With Quote #6

Use callbacks in new menus to choose the color.

Also, why did you post this in Off-Topic?
You are obviously talking about scripting.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 03-09-2010 , 15:16   Re: New Menus and Old Menus
Reply With Quote #7

Well it originally was just a post to find the thread, but then it started becoming scripting help.. My bad =/
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 03-09-2010 , 16:21   Re: New Menus and Old Menus
Reply With Quote #8

How exactly do Callbacks work? I didn't really understand it via the New Menu tutorial..

Also, could I have this moved to Scripting help rather than creating a new topic.. Don't wanna make a load of threads for one big question
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-09-2010 , 21:25   Re: New Menus and Old Menus
Reply With Quote #9

Code:
#include < amxmodx > #define MAX_PLAYERS 32 new bool:g_bToggle[ MAX_PLAYERS + 1 ]; new g_hMenu; public plugin_init( ) {     register_plugin( "Callback Test", "0.0.1", "Exolent" );         register_clcmd( "say /toggle", "CmdToggle" );         new hCallback = menu_makecallback( "CallbackToggle" );     g_hMenu = menu_create( "Toggle Menu", "MenuToggle" );         menu_additem( g_hMenu, "On", "1", _, hCallback );     menu_additem( g_hMenu, "Off", "0", _, hCallback ); } public client_disconnect( iPlayer ) {     g_bToggle[ iPlayer ] = false; } public CmdToggle( iPlayer ) {     menu_display( iPlayer, g_hMenu ); } public CallbackToggle( iPlayer, hMenu, iItem ) {     new iAccess, szInfo[ 2 ], hCallback;     menu_item_getinfo( hMenu, iItem, iAccess, szInfo, charsmax( szInfo ), _, _, hCallback );         switch( szInfo[ 0 ] )     {         case '1':         {             if( g_bToggle[ iPlayer ] )             {                 // toggle is already on, so disable the "On" item                 return ITEM_DISABLED;             }         }         case '0':         {             if( !g_bToggle[ iPlayer ] )             {                 // toggle is already off, so disable the "Off" item                 return ITEM_DISABLED;             }         }     }         // enable the items if they are allowed     return ITEM_ENABLED; } public MenuToggle( iPlayer, hMenu, iItem ) {     if( iItem == MENU_EXIT )     {         return;     }         new iAccess, szInfo[ 2 ], hCallback;     menu_item_getinfo( hMenu, iItem, iAccess, szInfo, charsmax( szInfo ), _, _, hCallback );         switch( szInfo[ 0 ] )     {         case '1':         {             // this will only be called if callback returns ITEM_ENABLED             g_bToggle[ iPlayer ] = true;         }         case '0':         {             // this will only be called if callback returns ITEM_ENABLED             g_bToggle[ iPlayer ] = false;         }     }         menu_display( iPlayer, g_hMenu ); }

If the callback returns ITEM_DISABLED, the item and number will be grayed out and nothing will happen if the key is pressed.

Of course, this could be reduced to smaller code, but it was just an example.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
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 19:20.


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