Raised This Month: $ Target: $400
 0% 

seriously need help with the new menu system!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 08-07-2005 , 11:44   seriously need help with the new menu system!
Reply With Quote #1

// EDIT

whatever key is pressed, only the menu_handler is called,
can't get it to respond to the specific item pressed!
please see test code below!
FeuerSturm is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-07-2005 , 16:04  
Reply With Quote #2

I dont think this is a bug with AMXX as i have got my menu to work.
If u want i will move this thread into Scripting Help and help you with you source
Freecode is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 08-07-2005 , 16:46  
Reply With Quote #3

i don't think that the comments in the amxmodx.inc are really
helpful, so i still can't get it to call the correct function after an
option from the menu was chosen.
i got the callbacks to work like they should, but like i said,
there's still a problem with the options as only the default menu handler is called after a key was pressed.

here's my current test menu:

Code:
#include <amxmodx> #include <amxmisc> #include <dodx> new PL_AUTHOR[] = "[RST] FireStorm" new PL_NAME[] = "New Menu Example" new PL_VERSION[] = "1.0" new examplemenu new MENU_NAME[] = "Example Menu" new cmd1[] = "menuitem_1" new cmd2[] = "menuitem_2" public plugin_init(){     register_plugin(PL_NAME,PL_VERSION,PL_AUTHOR)     register_clcmd("amx_examplemenu","show_examplemenu",ADMIN_ADMIN,"show example menu")     examplemenu = menu_create(MENU_NAME,"menu_handler",0)     menu_additem(examplemenu,"ALLIES ONLY Item",cmd1,ADMIN_ADMIN,menu_makecallback("example_callback1"))     menu_additem(examplemenu,"AXIS ONLY Item",cmd2,ADMIN_ADMIN,menu_makecallback("example_callback2")) } public show_examplemenu(id,level,cid){     if (!cmd_access(id,level,cid,1)){         return PLUGIN_HANDLED     }     menu_display(id,examplemenu,0)     return PLUGIN_HANDLED } public menu_handler(id){     client_print(id,print_chat,"Key has been pressed!") } public menuitem_1(id){     client_print(id,print_chat,"Allied Item selected!") } public menuitem_2(id){     client_print(id,print_chat,"Axis Item selected!") } public example_callback1(id){     new callreturn     if(get_user_team(id) == ALLIES){         callreturn = ITEM_ENABLED     }     else {         callreturn = ITEM_DISABLED     }     return callreturn } public example_callback2(id){     new callreturn     if(get_user_team(id) == AXIS){         callreturn = ITEM_ENABLED     }     else {         callreturn = ITEM_DISABLED     }     return callreturn }

thanks for help!
FeuerSturm is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-08-2005 , 17:59  
Reply With Quote #4

Here try this tell me if it works

Code:
#include <amxmodx> #include <amxmisc> #include <dodx> new PL_AUTHOR[] = "[RST] FireStorm" new PL_NAME[] = "New Menu Example" new PL_VERSION[] = "1.0" new examplemenu,call1,call2 new MENU_NAME[] = "Example Menu" new cmd1[] = "menuitem_1" new cmd2[] = "menuitem_2" public plugin_init() {     register_plugin(PL_NAME,PL_VERSION,PL_AUTHOR)     register_clcmd("amx_examplemenu","show_examplemenu",ADMIN_ADMIN,"show example menu")     examplemenu = menu_create(MENU_NAME,"menu_handler",0)     call1 = menu_makecallback("example_callback1")     call2 = menu_makecallback("example_callback2")         buildMenu(); } public buildMenu() {     menu_additem(examplemenu,"ALLIES ONLY Item",cmd1,ADMIN_ADMIN,call1)     menu_additem(examplemenu,"AXIS ONLY Item",cmd2,ADMIN_ADMIN,call2) } public show_examplemenu(id,level,cid){     if (!cmd_access(id,level,cid,1)){         return PLUGIN_HANDLED     }     menu_display(id,examplemenu,0)     return PLUGIN_HANDLED } public menu_handler(id, menu, item){     client_print(id,print_chat,"Key has been pressed!") } public menuitem_1(id){     client_print(id,print_chat,"Allied Item selected!") } public menuitem_2(id){     client_print(id,print_chat,"Axis Item selected!") } public example_callback1(id, menu, item) {     new callreturn     if(get_user_team(id) == ALLIES){         callreturn = ITEM_ENABLED     }     else {         callreturn = ITEM_DISABLED     }     return callreturn } public example_callback2(id, menu, item) {     new callreturn     if(get_user_team(id) == AXIS){         callreturn = ITEM_ENABLED     }     else {         callreturn = ITEM_DISABLED     }     return callreturn }
Freecode is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 08-08-2005 , 22:25  
Reply With Quote #5

nope, doesn't work, only menu_handler is called on whatever key
i press.

so does anyone know what const command[]="" has to be
if it's not a function?!


p.s.: thanks for the try freecode, but just reorganizing my non working code doesn't do it!
but at least the try is worth a karma point, here you go karma[freecode]++
FeuerSturm is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-09-2005 , 14:25  
Reply With Quote #6

oh noe. u missunderstood the command[]="" .
Its for passing some info for you to noe which item it is.

Here is how i do it in my shero menu. I pass the hero # through the cmd[]=""
Code:
format(cmd,4,"%d",x);         menu_additem(g_sheroMenu , fItem , cmd , 0 , g_HeroCall);
and then i read it in the menu handler like this

Code:
menu_item_getinfo(menu, item, access, cmd,4, iName, 63,callback);     new idHero = str_to_num(cmd);

hope that makes sense
Freecode is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 08-09-2005 , 16:45  
Reply With Quote #7

so const command[]="" will be the number you press on the menu?!

i'm even more confused about your code snippet above now, thanks

i'll try it now, but once again, the descriptions in the include aren't really helpful.
FeuerSturm is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-09-2005 , 17:03  
Reply With Quote #8

no. u pass w/e u want in const command[]="". So u can pass ur function name in there. or anything else u want. Because in ur menu handler u will get the items info like this
Code:
menu_item_getinfo(menu, item, access, cmd,4, iName, 63,callback);

So in my case. In the code i post above i pass on a nimber into const command[]="" but you can pass anything u want. a specific name/ number/ anything. So in the menu handler when u read the items info u will get that info that u passed and make ur needed calls
Freecode is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 08-09-2005 , 17:13  
Reply With Quote #9

yeah, i just tried it and got it to work!

thanks a bunch freecode, i love you!

i'm using public menu_handler(id, menu, item){
and then menu_item_getinfo and finally have the
item number that was chosen!
(0 for item 1, 1 for item 2!)

like i said, thanks dude!
FeuerSturm is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-09-2005 , 17:28  
Reply With Quote #10

no prob
Freecode 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 23:41.


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