Raised This Month: $32 Target: $400
 8% 

Menu showing up but keys not catched


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Isobold
Veteran Member
Join Date: Mar 2004
Old 07-21-2005 , 13:37   Menu showing up but keys not catched
Reply With Quote #1

I tried several examples, even those from the documentation, but I just can't get the menus to work right ...
They are showing up, but the keys are not catched as they should ...

What am I doing wrong???

Code:
#define Keysmenu_1 (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) #define Keysmenu_2 (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) ... public plugin_init() {     register_plugin("AFK KiSSS","3.0.0 Beta 1","Isobold")     register_cvar("afkslay_version", "3.0.0 Beta 1", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)     ...     register_clcmd("say afkmenu","showKiSSSMenu")     register_clcmd("afkmenu_2","showKiSSSMenu2")     register_menucmd(register_menuid("afkmenu_1"), Keysmenu_1, "KiSSSMenu")     register_menucmd(register_menuid("afkmenu_2"), Keysmenu_2, "KiSSSMenu2")           ... } ... // Menu //The clcmd function will just give us the player id public showKiSSSMenu(id) {     new menu[192]     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2     format(menu, 191, "Settings^n^n1. Option 1^n2. Option 2^n3. Option 3^n3. Option 4^n3. Option 5^n3. Option 6^n3. Option 7^n3. Option 8^n9. %L^n0. %L",id,"MORE",id,"EXIT")     show_menu(id, keys, menu) } public showKiSSSMenu2(id) {     new menu[192]     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2     format(menu, 191, "Settings2^n^n1. Option 1^n2. Option 2^n3. Option 3^n3. Option 4^n3. Option 5^n3. Option 6^n3. Option 7^n3. Option 8^n9. %L^n0. %L",id,"BACK",id,"EXIT")     show_menu(id, keys, menu) } //Our menu function will get the player id and the key they pressed public KiSSSMenu(id, key) {     switch (key) {         case 0: { // 1              client_print(0, print_chat, "[AFK KiSSS]: Option 1 1")              client_cmd(id,"say afkmenu")         }         case 1: { // 2              client_print(0, print_chat, "[AFK KiSSS]: Option 1 2")              client_cmd(id,"say afkmenu")         }         case 2: { // 3              client_print(0, print_chat, "[AFK KiSSS]: Option 1 3")              client_cmd(id,"say afkmenu")         }         case 3: { // 4              client_print(0, print_chat, "[AFK KiSSS]: Option 1 4")              client_cmd(id,"say afkmenu")         }         case 4: { // 5              client_print(0, print_chat, "[AFK KiSSS]: Option 1 5")              client_cmd(id,"say afkmenu")         }         case 5: { // 6              client_print(0, print_chat, "[AFK KiSSS]: Option 1 6")              client_cmd(id,"say afkmenu")         }         case 6: { // 7              client_print(0, print_chat, "[AFK KiSSS]: Option 1 7")              client_cmd(id,"say afkmenu")         }         case 7: { // 8              client_print(0, print_chat, "[AFK KiSSS]: Option 1 8")              client_cmd(id,"say afkmenu")         }         case 8: { // 9              client_cmd(id,"afkmenu_2")         }         case 9: {}     }     return PLUGIN_HANDLED } //Our menu function will get the player id and the key they pressed public KiSSSMenu2(id, key) {     switch (key) {         case 0: { // 1              client_print(0, print_chat, "[AFK KiSSS]: Option 2 1")              client_cmd(id,"say afkmenu")         }         case 1: { // 2              client_print(0, print_chat, "[AFK KiSSS]: Option 2 2")              client_cmd(id,"say afkmenu")         }         case 2: { // 3              client_print(0, print_chat, "[AFK KiSSS]: Option 2 3")              client_cmd(id,"say afkmenu")         }         case 3: { // 4              client_print(0, print_chat, "[AFK KiSSS]: Option 2 4")              client_cmd(id,"say afkmenu")         }         case 4: { // 5              client_print(0, print_chat, "[AFK KiSSS]: Option 2 5")              client_cmd(id,"say afkmenu")         }         case 5: { // 6              client_print(0, print_chat, "[AFK KiSSS]: Option 2 6")              client_cmd(id,"say afkmenu")         }         case 6: { // 7              client_print(0, print_chat, "[AFK KiSSS]: Option 2 7")              client_cmd(id,"say afkmenu")         }         case 7: { // 8              client_print(0, print_chat, "[AFK KiSSS]: Option 2 8")              client_cmd(id,"say afkmenu")         }         case 8: { // 9              client_cmd(id,"say afkmenu")         }         case 9: {}     }     return PLUGIN_HANDLED }
Isobold is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 07-21-2005 , 13:47  
Reply With Quote #2

the problem is that your registered menuid does not match
the first line of the message of your menu.

Code:
register_menucmd(register_menuid("afkmenu_1"), Keysmenu_1, "KiSSSMenu")

so your menu has to display afkmenu_1 for it
to recognise.


example from one of my plugins:

Code:
register_menucmd(register_menuid("DoD TK Revenge"),(1<<0)|(1<<1)|(1<<2),"tkrevenge_options")

so menu has to inclue DoD TK Revenge:

Code:
format(revenge_menu,1023,"\rDoD TK Revenge\R^n^n\y1.\w Forgive!^n\y2.\w Glow & 1hp!^n\y3.\w Slay!^n^nKiller: %s",tkername)

i think you get what i mean, so in your case it should be:

Code:
register_menucmd(register_menuid("Settings"), Keysmenu_1, "KiSSSMenu")
and
Code:
register_menucmd(register_menuid("Settings2"), Keysmenu_2, "KiSSSMenu2")
FeuerSturm is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 07-21-2005 , 13:53  
Reply With Quote #3

And you should use the keys you defined already..

try something like this:

Code:
#include <amxmodx> #define Keysmenu_1 (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9) #define Keysmenu_2 (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9) public plugin_init() {     register_plugin("AFK KiSSS","3.0.0 Beta 1","Isobold")     register_cvar("afkslay_version", "3.0.0 Beta 1", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)     register_clcmd("say afkmenu","showKiSSSMenu")     register_clcmd("afkmenu_2","showKiSSSMenu2")     register_menucmd(register_menuid("Settings"), Keysmenu_1, "KiSSSMenu")     register_menucmd(register_menuid("Settings2"), Keysmenu_2, "KiSSSMenu2") } // Menu //The clcmd function will just give us the player id public showKiSSSMenu(id) {     new menu[192]     format(menu, 191, "Settings^n^n1. Option 1^n2. Option 2^n3. Option 3^n3. Option 4^n3. Option 5^n3. Option 6^n3. Option 7^n3. Option 8^n9. %L^n0. %L",id,"MORE",id,"EXIT")     show_menu(id, Keysmenu_1, menu) } public showKiSSSMenu2(id) {     new menu[192]     format(menu, 191, "Settings2^n^n1. Option 1^n2. Option 2^n3. Option 3^n3. Option 4^n3. Option 5^n3. Option 6^n3. Option 7^n3. Option 8^n9. %L^n0. %L",id,"BACK",id,"EXIT")     show_menu(id, Keysmenu_2, menu) } //Our menu function will get the player id and the key they pressed public KiSSSMenu(id, key) {     switch (key) {         case 0: { // 1              client_print(0, print_chat, "[AFK KiSSS]: Option 1 1")              client_cmd(id,"say afkmenu")         }         case 1: { // 2              client_print(0, print_chat, "[AFK KiSSS]: Option 1 2")              client_cmd(id,"say afkmenu")         }         case 2: { // 3              client_print(0, print_chat, "[AFK KiSSS]: Option 1 3")              client_cmd(id,"say afkmenu")         }         case 3: { // 4              client_print(0, print_chat, "[AFK KiSSS]: Option 1 4")              client_cmd(id,"say afkmenu")         }         case 4: { // 5              client_print(0, print_chat, "[AFK KiSSS]: Option 1 5")              client_cmd(id,"say afkmenu")         }         case 5: { // 6              client_print(0, print_chat, "[AFK KiSSS]: Option 1 6")              client_cmd(id,"say afkmenu")         }         case 6: { // 7              client_print(0, print_chat, "[AFK KiSSS]: Option 1 7")              client_cmd(id,"say afkmenu")         }         case 7: { // 8              client_print(0, print_chat, "[AFK KiSSS]: Option 1 8")              client_cmd(id,"say afkmenu")         }         case 8: { // 9              client_cmd(id,"afkmenu_2")         }         case 9: {}     }     return PLUGIN_HANDLED } //Our menu function will get the player id and the key they pressed public KiSSSMenu2(id, key) {     switch (key) {         case 0: { // 1              client_print(0, print_chat, "[AFK KiSSS]: Option 2 1")              client_cmd(id,"say afkmenu")         }         case 1: { // 2              client_print(0, print_chat, "[AFK KiSSS]: Option 2 2")              client_cmd(id,"say afkmenu")         }         case 2: { // 3              client_print(0, print_chat, "[AFK KiSSS]: Option 2 3")              client_cmd(id,"say afkmenu")         }         case 3: { // 4              client_print(0, print_chat, "[AFK KiSSS]: Option 2 4")              client_cmd(id,"say afkmenu")         }         case 4: { // 5              client_print(0, print_chat, "[AFK KiSSS]: Option 2 5")              client_cmd(id,"say afkmenu")         }         case 5: { // 6              client_print(0, print_chat, "[AFK KiSSS]: Option 2 6")              client_cmd(id,"say afkmenu")         }         case 6: { // 7              client_print(0, print_chat, "[AFK KiSSS]: Option 2 7")              client_cmd(id,"say afkmenu")         }         case 7: { // 8              client_print(0, print_chat, "[AFK KiSSS]: Option 2 8")              client_cmd(id,"say afkmenu")         }         case 8: { // 9              client_cmd(id,"say afkmenu")         }         case 9: {}     }     return PLUGIN_HANDLED }
xeroblood is offline
Send a message via MSN to xeroblood
Isobold
Veteran Member
Join Date: Mar 2004
Old 07-21-2005 , 13:59  
Reply With Quote #4

thx, how stupid I was about the keys, I mixed up 2 Versions of my code

I did not knew about the menu title. Thx again
Isobold is offline
Isobold
Veteran Member
Join Date: Mar 2004
Old 07-21-2005 , 19:14  
Reply With Quote #5

Tried it out now, but the second menu-part is not working. I always get the menu point of the first menu.
Isobold is offline
WaZZeR++
Veteran Member
Join Date: Mar 2005
Location: Sweden
Old 07-21-2005 , 19:37  
Reply With Quote #6

this is from my aionmenu, i kinda trashed it when xero come with uaio...

it's not tested, but ti will show you how to put 2 menu page under same command...
Code:
#define MENU_SIZE    256 new g_iMenuPosition new g_coloredMenus public plugin_init() {     register_plugin("AINO Menu","1.0","WaZZeR")     register_menucmd(register_menuid("AINO Menu:"),1023,"actionAinoMenu")     register_clcmd("amx_ainomenu","cmdAinoMenu",ADMIN_LEVEL_A,"- displays AINO menu")     g_coloredMenus = colored_menus() } /*----------------------------- Main Menu --------------*/ public cmdAinoMenu( id, lvl, cid ) {     if( cmd_access( id, lvl, cid, 0 ) )                 showAinoMenu( id, g_iMenuPosition = 0 )     return PLUGIN_HANDLED } public showAinoMenu( id, pos ) {     if( pos < 0 ) return             new szMenuBody[MENU_SIZE]     new iLen = format( szMenuBody, MENU_SIZE-1, g_coloredMenus ? "\yAINO Menu:\R%d/%d^n\w^n" : "AINO Menu: %d/2^n^n", pos+1 )     new iKeys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<9)         if ( pos ) {         iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "1. Glow Menu^n2. Bury Menu^n3. Disarm Menu^n4. Uberslap Menu^n5. Slay2 Menu^n6. Fire Menu^n7. Rocket Menu^n\d8. Weapon Menu^n" )     }     else {         iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "1. Heal Menu^n2. Armor Menu^n3. Godmode Menu^n4. Noclip Menu^n5. Give Money Menu^n6. Take Money Menu^n7. Gag Menu^n8. Gravity Menu^n" )     }                 //Cheack poss     if( pos ) {          format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. Back")         iKeys |= (1<<8)     }     else         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. Exit")         show_menu( id, iKeys, szMenuBody, -1 )         return } public actionAinoMenu( id, key ) {     switch( key )     {         case 8: showAinoMenu( id, ++g_iMenuPosition ) // More Option         case 9: showAinoMenu( id, --g_iMenuPosition ) // Back Option                 // Chose a Player         default:         {             new option = (key + (g_iMenuPosition * 8))             switch (option) {                 //page 1                 case 0client_cmd(id,"amx_healmenu"); //key 1                 case 1client_cmd(id,"amx_armormenu"); //key 2                 case 2client_cmd(id,"amx_godmodemenu"); //key 3                 case 3client_cmd(id,"amx_noclipmenu"); //etc....                 case 4client_cmd(id,"amx_givemoneymenu");                 case 5client_cmd(id,"amx_takemoneymenu");                 case 6client_cmd(id,"amx_gagmenu");                 case 7client_cmd(id,"amx_gravitymenu");                 //page 2                 case 8client_cmd(id,"amx_glowmenu"); //key 1                 case 9client_cmd(id,"amx_burymenu"); //key 2                 case 10: client_cmd(id,"amx_disarmmenu"); //etc...                 case 11: client_cmd(id,"amx_uberslapmenu");                 case 12: client_cmd(id,"amx_slaytwomenu");                 case 13: client_cmd(id,"amx_firemenu");                 case 14: client_cmd(id,"amx_rocketmenu");                 case 15: client_cmd(id,"amx_weaponmenu");             }         }     }     return PLUGIN_HANDLED }
WaZZeR++ is offline
Send a message via MSN to WaZZeR++
Isobold
Veteran Member
Join Date: Mar 2004
Old 07-21-2005 , 19:52  
Reply With Quote #7

it's to late for me to figure this out now ;)

I will try to check this out on Saturday, but thx for your help ...

Some karma for you
Isobold is offline
Isobold
Veteran Member
Join Date: Mar 2004
Old 07-25-2005 , 12:57  
Reply With Quote #8

I tried it out:
Code:
#define MENU_SIZE           256 public plugin_init() {     register_plugin("AFK KiSSS","3.0.0 Beta 1","Isobold")     ...     register_menucmd(register_menuid("AFK KiSSS Menu:"),1023,"actionKiSSSMenu")     register_clcmd("say afkmenu","showKiSSSMenu",ADMIN_LEVEL_A,"- displays KiSSS menu")     g_coloredMenus = colored_menus()      ... } ... // Menu public showKiSSSMenu( id, lvl, cid ) {     if( cmd_access( id, lvl, cid, 0 ) )                  KiSSSMenu( id, g_iMenuPosition = 0 )     return PLUGIN_HANDLED } public KiSSSMenu(id, pos) {     if( pos < 0 ) return               new szMenuBody[MENU_SIZE]     new iLen = format( szMenuBody, MENU_SIZE-1, g_coloredMenus ? "\yAFK KiSSS Menu:\R%d/%d^n\w^n" : "AFK KiSSS Menu: %d/2^n^n", pos+1 )     new iKeys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<9)           if ( pos ) {         iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "1. Glow Menu^n2. Bury Menu^n3. Disarm Menu^n4. Uberslap Menu^n5. Slay2 Menu^n6. Fire Menu^n7. Rocket Menu^n\d8. Weapon Menu^n" )     }     else {         iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "1. Heal Menu^n2. Armor Menu^n3. Godmode Menu^n4. Noclip Menu^n5. Give Money Menu^n6. Take Money Menu^n7. Gag Menu^n8. Gravity Menu^n" )     }                   //Cheack poss     if( !pos ) {              format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. Exit")         iKeys |= (1<<8) //key 9 for more options     }     else         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. Back")           show_menu( id, iKeys, szMenuBody, -1 )           return } public actionKiSSSMenu(id, key) {     switch( key )     {         case 8: KiSSSMenu( id, ++g_iMenuPosition ); // More Option         case 9: KiSSSMenu( id, --g_iMenuPosition ); // Back Option                   // Chose a Player         default:         {             new option = (key + (g_iMenuPosition * 8))             KiSSSMenu(id,g_iMenuPosition);             switch (option) {                 //page 1                 case 0: { // 1                  client_print(0, print_chat, "[AFK KiSSS]: Option 2 1");                 }                 case 1: { // 2                  client_print(0, print_chat, "[AFK KiSSS]: Option 2 2");                 }                 case 2: { // 3                  client_print(0, print_chat, "[AFK KiSSS]: Option 2 3");                 }                 case 3: { // 4                  client_print(0, print_chat, "[AFK KiSSS]: Option 2 4");                 }                 case 4: { // 5                  client_print(0, print_chat, "[AFK KiSSS]: Option 2 5");                 }                 case 5: { // 6                  client_print(0, print_chat, "[AFK KiSSS]: Option 2 6");                 }                 case 6: { // 7                  client_print(0, print_chat, "[AFK KiSSS]: Option 2 7");                 }                 case 7: { // 8                  client_print(0, print_chat, "[AFK KiSSS]: Option 2 8");                 }                 //page 2                 case 8: { // 1                  client_print(0, print_chat, "[AFK KiSSS]: Option 3 1");                 }                 case 9: { // 2                  client_print(0, print_chat, "[AFK KiSSS]: Option 3 2");                 }                 case 10: { // 3                  client_print(0, print_chat, "[AFK KiSSS]: Option 3 3");                 }                 case 11: { // 4                  client_print(0, print_chat, "[AFK KiSSS]: Option 3 4");                 }                 case 12: { // 5                  client_print(0, print_chat, "[AFK KiSSS]: Option 3 5");                 }                 case 13: { // 6                  client_print(0, print_chat, "[AFK KiSSS]: Option 3 6");                 }                 case 14: { // 7                  client_print(0, print_chat, "[AFK KiSSS]: Option 3 7");                 }                 case 15: { // 8                  client_print(0, print_chat, "[AFK KiSSS]: Option 3 8");                 }             }         }     }     return PLUGIN_HANDLED }

The first menu page shows up, but there is no Next or Back-Option and the the cases are not executed. Probably it's me, but I can neither figure out, why you wrote it like that (ok, I understand this page thing, but not the hole rest, for example this: format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. Back") ) nor why it does not works here ...
Isobold is offline
WaZZeR++
Veteran Member
Join Date: Mar 2005
Location: Sweden
Old 07-25-2005 , 12:59  
Reply With Quote #9

that was my bad...ill try fix it....

EDIT:
try this
Code:
    //Cheack poss     if( !pos ) {            format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. Exit")         iKeys |= (1<<8) //key 9 for more options     }     else         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. Back")
WaZZeR++ is offline
Send a message via MSN to WaZZeR++
Isobold
Veteran Member
Join Date: Mar 2004
Old 07-25-2005 , 13:19  
Reply With Quote #10

still not works, Next-Button now shows up, but nothing is executing after keypress ...

I have updated the code above ...

Edit: I also made a special debugging version. The plugin never reaches the actionKiSSSMenu-function ...
Isobold is offline
Reply


Thread Tools
Display Modes

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 02:50.


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