|
Senior Member
|

04-27-2008
, 07:18
Re: Need help with new menustyle..
|
#4
|
Quote:
Originally Posted by v3x
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(buffer, 31, "amx_show_activity \r%d", get_cvar_num("amx_show_activity")); menu_additem(menu, buffer, "1", 0, callback);
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", 0, callback); menu_additem(menu, "Something else", "2", 0, callback); menu_setprop(menu, MPROP_EXIT, MEXIT_ALL); menu_display(id, menu, 0); return PLUGIN_HANDLED; } public MenuHandler_TheMenu(id, menu, item) { if(item == MENU_EXIT) { menu_destroy(menu); return PLUGIN_HANDLED; } new command[6], name[64]; new access, callback; menu_item_getinfo(menu, item, access, command, 5, name, 63, callback); new key = str_to_num(command); switch(key) { case 1: client_print(id, print_chat, "You selected something"); case 2: client_print(id, print_chat, "You selected something else"); default: menu_destroy(menu); } return PLUGIN_HANDLED; } public MenuCallBack_TheMenu(id, menu, item) { new command[6], name[64]; new access, callback; menu_item_getinfo(menu, item, access, command, 5, name, 63, callback); 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
|
|