AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu + Undermenus not working! (https://forums.alliedmods.net/showthread.php?t=26133)

Timoses 03-27-2006 12:12

Menu + Undermenus not working!
 
Ok I'm trying to make a menu which you can call up at a certain point
of the map.
So far it worked out when I put commands for the first menu.
But now I am trying to make undermenus ("Songs","Sound effects")
and if I want to access songs or sound effects with keynumbers 1 or 2
I end up at the code guessing again (the number 1 or 2 from choosing
songs, soundeffects is already there as the first digit for the code)

Here is what I got:
Code:
public plugin_init() {     register_clcmd("say /login","tv_bar_guess")     register_menucmd(register_menuid("Bar TV"), 1023,"action_bar_guess")     register_menucmd(register_menuid("Bar TV Menu"),1023,"action_bar_menu")     register_menucmd(register_menuid("Bar Music"),1023,"action_bar_music")     register_menucmd(register_menuid("Bar Sound"),1023,"action_bar_sound_effects") } public tv_bar_guess(id) {     new origin[3]     get_user_origin(id,origin)     if(get_distance(origin,bar_tv) <= 25.0)     {         new body[256]         new key = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)         new len = format(body,sizeof(body),"Bar TV^n")         len += format(body[len],sizeof(body)-len,"---------------------------------------^n")         len += format(body[len],sizeof(body)-len,"              .%i.%i.%i.%i.%i.        ^n",bar_guesscode[id][0],bar_guesscode[id][1],bar_guesscode[id][2],bar_guesscode[id][3],bar_guesscode[id][4])         len += format(body[len],sizeof(body)-len,"---------------------------------------^n")         add(body,sizeof(body),"^n0. Exit^n")         show_menu(id,key,body)     }     else     {         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } public action_bar_guess(id,key) {     if(!is_user_alive(id)) return PLUGIN_HANDLED     new origin[3]     get_user_origin(id,origin)     if(get_distance(origin,bar_tv) > 25.0) return PLUGIN_HANDLED     if(key == 9) return PLUGIN_HANDLED         for(new i = 0;i < 5;i++) {  // Search for the specific slot and set value         if(bar_guesscode[id][i] == 0) {         bar_guesscode[id][i] = key+1         break         }     }         if(bar_guesscode[id][4] != 0)   // If last number then show menu     {         if(bar_guesscode[id][0] == bar_rightpass[0] && bar_guesscode[id][1] == bar_rightpass[1] && bar_guesscode[id][2] == bar_rightpass[2] && bar_guesscode[id][3] == bar_rightpass[3] && bar_guesscode[id][4] == bar_rightpass[4]) bar_menu(id)         else {             for(new i = 0;i < 5;i++) {             bar_guesscode[id][i] = 0             }         }         return PLUGIN_HANDLED     }     else                // If NOT last then reshow menu     {         tv_bar_guess(id)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } public bar_menu(id) {     if(!is_user_alive(id)) return PLUGIN_HANDLED     client_print(id,print_chat,"[TV] Correct Code!")     for(new i = 0;i < 5;i++) {         bar_guesscode[id][i] = 0     }         new body[256]     new key = (1<<0)|(1<<1)|(1<<9)     new len = format(body,sizeof(body),"Bar TV Menu^n")         add(body,sizeof(body),"^n1. Songs^n")     add(body,sizeof(body),"2. Sound Effects^n")     add(body,sizeof(body),"^n^n0. Close Menu^n")     show_menu(id,key,body)     return PLUGIN_HANDLED } public action_bar_menu(id,key) {     if(key == 0) bar_music(id)     if(key == 1) bar_sound_effects(id)     if(key == 9) return PLUGIN_HANDLED     return PLUGIN_HANDLED } public bar_music(id) {     if(!is_user_alive(id)) return PLUGIN_HANDLED         new body[1024]     new key         format(body, 1023, "^nMusic Player^n^n1. Song1^n^n0. Close Menu^n")     key = (1<<0)|(1<<9)         show_menu(id,key,body)     return PLUGIN_HANDLED } public action_bar_music(id,key) {     switch(key)     {         case 0:         {             if(playing != 0)             {                 client_print(id,print_chat,"[TV] A song is already being played, wait for it to end!^n")                 return PLUGIN_HANDLED             }             else             {                 new box = create_entity("info_target")                 entity_set_origin( box, porigin)                 emit_sound(box, CHAN_AUTO, "Pimplordz/Music/song1.wav", 1.0, ATTN_IDLE, 0, PITCH_NORM)                 playing = 1                 set_task(300.0, "stop_player")                 client_print(id,print_chat,"[TV] Music is being played!^n")             }         }         case 1:         {             return PLUGIN_HANDLED         }     }     return PLUGIN_HANDLED } public bar_sound_effects(id) {     if(!is_user_alive(id)) return PLUGIN_HANDLED            new body[256]     new key         format(body, 1023, "^nSound Effects^n^n1. E-Bass^n^n0. Close Menu^n")     key = (1<<0)|(1<<9)         show_menu(id,key,body)     return PLUGIN_HANDLED } public action_bar_sound_effects(id,key) {     switch(key)     {         case 0:         {             new box = create_entity("info_target")             entity_set_origin( box, porigin)             emit_sound(box, CHAN_AUTO, "Pimplordz/Sound/Bass001.wav", 1.0, ATTN_STATIC, 0, PITCH_NORM)         }         case 1:         {             return PLUGIN_HANDLED         }     }     return PLUGIN_HANDLED }

Hope you guys can help me :s

Timoses 03-28-2006 08:19

.. Come on.
I already tried a lot of things but the tv_bar_guess keeps coming up if I
wanna access an undermenu :s

... Please? :roll:

Hawk552 03-28-2006 09:09

Code:
show_menu(id,key,body,-1,"action_bar_guess")

Do that for each thing, cept not guess, use whatever it is.

Timoses 03-28-2006 10:11

1 Attachment(s)
Ty.
Now at least the code entry doesn't come up any more ;)

But now if I wanna access songs or sound effects the menu just disappears.

Never thought that it could be that hard to make undermenus :s

Timoses 03-28-2006 14:35

Ok this is very,very and so very weird.
I just removed the undermenus and did it the way I did it before.
And again the code request pops up if I choose an option.
So, wt? What did I do wrong?
Code:
#include <amxmodx> #include <amxmisc> #include <dbi> #include <tsx> #include <engine> #include <engine_stocks> #include <fun> #include <tsxaddon> new bar_tv[3] = { -122, -871, 32 } new bar_rightpass[5] = {5,6,4,3,7} new bar_guesscode[33][5] new Float:porigin[3] = { -306.0, -896.0, 0.0 } new playing public plugin_precache() {     precache_sound("Pimplordz/Music/smellslike.wav")     precache_sound("Pimplordz/Sound/Bass001.wav") } public plugin_init() {     register_plugin("BarTV","0.2","Timoses & Rixorster")         register_clcmd("say /login","tv_bar_guess")         register_menucmd(register_menuid("Bar TV"), 1023,"action_bar_guess")     register_menucmd(register_menuid("Bar TV Menu"),1023,"action_bar_menu") } public tv_bar_guess(id) {     new origin[3]     get_user_origin(id,origin)     if(get_distance(origin,bar_tv) <= 25.0)     {         new body[256]         new key = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)         new len = format(body,sizeof(body),"Bar TV^n")         len += format(body[len],sizeof(body)-len,"---------------------------------------^n")         len += format(body[len],sizeof(body)-len,"              .%i.%i.%i.%i.%i.        ^n",bar_guesscode[id][0],bar_guesscode[id][1],bar_guesscode[id][2],bar_guesscode[id][3],bar_guesscode[id][4])         len += format(body[len],sizeof(body)-len,"---------------------------------------^n")         add(body,sizeof(body),"^n0. Exit^n")         show_menu(id,key,body)     }     else     {         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } public action_bar_guess(id,key) {     if(!is_user_alive(id)) return PLUGIN_HANDLED     new origin[3]     get_user_origin(id,origin)     if(get_distance(origin,bar_tv) > 25.0) return PLUGIN_HANDLED     if(key == 9) return PLUGIN_HANDLED         for(new i = 0;i < 5;i++) {  // Search for the specific slot and set value         if(bar_guesscode[id][i] == 0) {         bar_guesscode[id][i] = key+1         break         }     }         if(bar_guesscode[id][4] != 0)   // If last number then show menu     {         if(bar_guesscode[id][0] == bar_rightpass[0] && bar_guesscode[id][1] == bar_rightpass[1] && bar_guesscode[id][2] == bar_rightpass[2] && bar_guesscode[id][3] == bar_rightpass[3] && bar_guesscode[id][4] == bar_rightpass[4]) bar_menu(id)         else {             for(new i = 0;i < 5;i++) {             bar_guesscode[id][i] = 0             }         }         return PLUGIN_HANDLED     }     else                // If NOT last then reshow menu     {         tv_bar_guess(id)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } public bar_menu(id) {     if(!is_user_alive(id)) return PLUGIN_HANDLED     client_print(id,print_chat,"[TV] Correct Code!")     for(new i = 0;i < 5;i++) {         bar_guesscode[id][i] = 0     }         new body[256]     new key = (1<<0|1<<1|1<<9)     new len = format(body,sizeof(body),"Bar TV Menu^n")         add(body,sizeof(body),"^n1. Nirvana - Smells Like Teen Spirit^n")     add(body,sizeof(body),"2. E-Bass^n")     add(body,sizeof(body),"^n0. Close Menu^n")     show_menu(id,key,body,-1,"action_bar_menu")     return PLUGIN_HANDLED } public action_bar_menu(id,key) {     switch(key)     {         case 0:         {             if(playing != 0)             {                 client_print(id,print_chat,"[TV] A song is already being played, wait for it to end!^n")                 return PLUGIN_HANDLED             }             else             {                 new box = create_entity("info_target")                 entity_set_origin( box, porigin)                 emit_sound(box, CHAN_AUTO, "Pimplordz/Music/smellslike.wav", 1.0, ATTN_IDLE, 0, PITCH_NORM)                 playing = 1                 set_task(300.0, "stop_player")                 client_print(id,print_chat,"[TV] Music is being played!^n")             }         }         case 1:         {             new box = create_entity("info_target")             entity_set_origin( box, porigin)             emit_sound(box, CHAN_AUTO, "Pimplordz/Sound/Bass001.wav", 1.0, ATTN_STATIC, 0, PITCH_NORM)         }         case 2:         {             return PLUGIN_HANDLED         }     }     return PLUGIN_HANDLED   }


All times are GMT -4. The time now is 16:45.

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