Raised This Month: $ Target: $400
 0% 

Need help with new menustyle..


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
[X]-RayCat
Senior Member
Join Date: Sep 2006
Old 04-27-2008 , 07:18   Re: Need help with new menustyle..
Reply With Quote #4

Quote:
Originally Posted by v3x View Post
I haven't tinkered around with the new menu system much, so I don't know if there's a better way to do this. To set the cvar when you press a key, simply use the pre-existing menu item and align the value to the right with \r (it may be an upper-case "R" [one aligns to the right and one is red-unsure]). Then call the menu again in the handler and it'll update it.
PHP Code:
new buffer[32];
format(buffer31"amx_show_activity \r%d"get_cvar_num("amx_show_activity"));
 
menu_additem(menubuffer"1"0callback); 
As for your other question, if I understand the new menu system correctly, this is how it's done:
PHP Code:
#include <amxmodx>
 
public plugin_init()
{
    
register_plugin("Menu Example""0.1""v3x");
    
register_clcmd("themenu""ClCmd_TheMenu");
}
 
public 
ClCmd_JumpMenu(id
{
    new 
menu menu_create("Yams:""MenuHandler_TheMenu");
 
    new 
callback menu_makecallback("MenuCallBack_TheMenu");
 
    
menu_additem(menu"Something""1"0callback);
    
menu_additem(menu"Something else""2"0callback);
 
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
 
    
menu_display(idmenu0);
 
    return 
PLUGIN_HANDLED;
}
 
public 
MenuHandler_TheMenu(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
 
    new 
command[6], name[64];
    new 
accesscallback;
 
    
menu_item_getinfo(menuitemaccesscommand5name63callback);
 
    new 
key str_to_num(command);
 
    switch(
key)
    {
        case 
1client_print(idprint_chat"You selected something");
        case 
2client_print(idprint_chat"You selected something else");
        default: 
menu_destroy(menu);
    }
 
    return 
PLUGIN_HANDLED;
}
 
public 
MenuCallBack_TheMenu(idmenuitem)
{
    new 
command[6], name[64];
    new 
accesscallback;
 
    
menu_item_getinfo(menuitemaccesscommand5name63callback);
 
    new 
key str_to_num(command);
 
    switch(
key)
    {
        case 
1:
        {
            if(!
is_user_alive(id))
                return 
ITEM_DISABLED;
        }
        case 
2:
        {
            if(
is_user_alive(id))
                return 
ITEM_ENABLED;
        }
    }
 
    return 
ITEM_ENABLED;

My examples aren't the greatest, but you get the point.

It's 7:00 and I'm tired, so you should consider yourself lucky that I'm helping you at this hour. Goodnight & good luck!

PS: If I'm wrong on anything, please correct me.
Thanks, i will try.

Go get some sleep
[X]-RayCat 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 23:52.


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