AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu Problem (https://forums.alliedmods.net/showthread.php?t=54713)

pRED* 05-02-2007 03:32

Menu Problem
 
Can someone please help me figure out why this doesn't work
The register_menucmd's are in plugin init.. and all the client print's are to help find where the error is..

Code:
    register_menucmd(register_menuid("menu_bf2badge"),1023,"MenuBadge_ChooseOption");     register_menucmd(register_menuid("menu_bf2badgelevel"),1023,"MenuBadgeLevel_ChooseOption"); public badgemenu(id) {     if (!get_pcvar_num(g_bf2_active))         return PLUGIN_CONTINUE     if (!(get_user_flags(id) & ADMIN_LEVEL))     {         client_print(id,print_chat,"You do not have access to this menu")         console_print(id,"You do not have access to this menu")         return PLUGIN_CONTINUE     }         new menu[] = "BFHQ: Select Badge^n^n1. Knife Combat^n2. Pistol Combat^n3. Assault Combat^n4. Sniper Combat^n5. Support Combat^n6. Explosives Ordinance^n7. Shotgun Combat^n8. SMG Combat^n^n0. Exit"     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8             show_menu(id, keys, menu, -1, "menu_bf2badge")     return PLUGIN_CONTINUE       } public badgelevelmenu(id) {     if (!get_pcvar_num(g_bf2_active))         return PLUGIN_CONTINUE     if (!(get_user_flags(id) & ADMIN_LEVEL))     {         client_print(id,print_chat,"You do not have access to this menu")         console_print(id,"You do not have access to this menu")         return PLUGIN_CONTINUE     }         new menu[] = "BFHQ: Select Level^n^n1. None^n2. Basic^n3. Veteran^n4. Expert^n^n0. Exit"     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4             show_menu(id, keys, menu, -1, "menu_bf2badgelevel")     return PLUGIN_CONTINUE       } public MenuBadge_ChooseOption(id, pclass:key) {     menuselected[id][0]=0     switch (key)     {     case 0: {             menuselected[id][1]=0             badgelevelmenu(id);             client_print(id,print_chat,"B:You selected 1, saved as.. %i",menuselected[id][1])         }     case 1: {             menuselected[id][1]=1             badgelevelmenu(id);             client_print(id,print_chat,"B:You selected 2, saved as.. %i",menuselected[id][1])         }     case 2: {             menuselected[id][1]=2             badgelevelmenu(id);             client_print(id,print_chat,"B:You selected 3, saved as.. %i",menuselected[id][1])         }     case 3:    {             menuselected[id][1]=3             badgelevelmenu(id);             client_print(id,print_chat,"B:You selected 4, saved as.. %i",menuselected[id][1])         }     case 4:    {             menuselected[id][1]=4             badgelevelmenu(id);             client_print(id,print_chat,"B:You selected 5, saved as.. %i",menuselected[id][1])         }     case 5:    {             menuselected[id][1]=5             badgelevelmenu(id);             client_print(id,print_chat,"B:You selected 6, saved as.. %i",menuselected[id][1])         }     case 6:    {             menuselected[id][1]=6             badgelevelmenu(id);             client_print(id,print_chat,"B:You selected 7, saved as.. %i",menuselected[id][1])         }     case 7:    {             menuselected[id][1]=7             badgelevelmenu(id);             client_print(id,print_chat,"B:You selected 8, saved as.. %i",menuselected[id][1])         }     }     return PLUGIN_HANDLED } public MenuBadgeLevel_ChooseOption(id, pclass:key) {     switch (key)     {     case 0: {             menuselected[id][2]=0             client_print(id,print_chat,"L:You selected 1, saved as.. %i",menuselected[id][2])             client_cmd(id,"messagemode PlayerName")         }     case 1: {             menuselected[id][2]=1             client_print(id,print_chat,"L:You selected 2, saved as.. %i",menuselected[id][2])             client_cmd(id,"messagemode PlayerName")         }     case 2: {             menuselected[id][2]=2             client_print(id,print_chat,"L:You selected 3, saved as.. %i",menuselected[id][2])             client_cmd(id,"messagemode PlayerName")         }     case 3:    {             menuselected[id][2]=3             client_print(id,print_chat,"L:You selected 4, saved as.. %i",menuselected[id][2])             client_cmd(id,"messagemode PlayerName")         }     }     return PLUGIN_CONTINUE } public PlayerName( id )  //Entered Player Name {     new message[192]     // Get message and remove quotes     read_args(message, 191)     remove_quotes(message)     client_print(id,print_chat,"Player name entered, raw data.. %s, %i, %i",message,menuselected[id][1],menuselected[id][2])     if (menuselected[id][0]==0) //User selected a badge     {         client_cmd(id,"bf2_addbadge ^"%s^" %i %i",message,menuselected[id][1],menuselected[id][2])     }     else //Kills     {         client_cmd(id,"bf2_addkills ^"%s^" %i",message,menuselected[id][1])     }     return PLUGIN_HANDLED }

When I try use this menu i get to the second menu but the messagemode never comes up.

Code:

B:You selected 7, saved as.. 6
B:You selected 2, saved as.. 1

Is what appears on screen. So it appears that when I select an option in the second menu it is handled by the first handler.

Changing the plugin_handled to plugin_continue on the first menu handler gives this result instead.. (the messagemode does come up but the second menu option gets handled by both menu handlers... w.t.f..)

Code:

B:You selected 6, saved as.. 5
Unknown command: PlayerName
B:You selected 3, saved as.. 2
L:You selected 3, saved as.. 2
Player name entered, raw data.. pRED*,2,2


Blue One 05-02-2007 03:58

Re: Menu Problem
 
Hey you,

i ask me everytime why everybody use the Old - Menusystem. because the new one is Easyer and require less sourcecode so your Plugin is not so big

maybe you can explain me what u want beacuse of i cant understand what u in this Thread want

pRED* 05-02-2007 05:04

Re: Menu Problem
 
The old menu system is the only one is know how to do. Seems easier than learning another way.

The idea is that a menu comes up with a choice of 8 badges, you select one and a new menu comes up with 4 level choices.
After choosing the level a messagemode prompt is displayed so you can enter a player name and then a client cmd is called that gives that player the badge and level specified (part of the bf2 rank mod admin menu)

But it doesn't work.
Either the second menu is handled by the first menu handler and the messagemode never comes up
Or the second menu gets handled by both and overwrites your original choice of badge..

stupok 05-02-2007 17:42

Re: Menu Problem
 
After a quick glance, I don't understand why you did this:

Code:

public MenuBadge_ChooseOption(id, pclass:key)
public MenuBadgeLevel_ChooseOption(id, pclass:key)

Why do you have pclass: before key? I think it will work if you remove pclass:.

pRED* 05-02-2007 19:29

Re: Menu Problem
 
PM used them in his fixed version of the xp mod tutorial...

http://forums.alliedmods.net/showthread.php?t=12518

All my other menus work btw but I'll give it a go to see if it helps :up:

pRED* 05-02-2007 21:55

Re: Menu Problem
 
Lol you were kinda right. Definately shouldn't have had pclass there.

Didn't fix the problem though. Changed to new menu system fixed it.. Thanks


All times are GMT -4. The time now is 06:46.

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