AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   2 menus crashes. need some help. (https://forums.alliedmods.net/showthread.php?t=11135)

XunTric 03-10-2005 15:44

2 menus crashes. need some help.
 
Hey! Im working on a new xp based plugin with 2 menus. But they are crashing together...

The first menu is to choose class. This menu works fine.

The second menu is a help menu. This menu shows up fine, but when you click a menu option, it takes the button from the choose class menu!

The first help menu option is "What is RuneScape Mod?" and the first choose class menu option is "Warrior".
And when i click "What is RuneScape Mod?" on the help menu, it changes class to warrior!
So its something fuck with the buttons... :P

Here it is. Hope somebody can help.
(I dont post whole script. Just the menu functions)
Code:
// ============================================================================================================= // Choose Class Menu // This Menu Works Fine // ============================================================================================================= stock ChangeClass(id) {     new menu[192]     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3     format(menu, 191, "RuneScape Mod: Choose Class^n^n1. Warrior^n2. Ranger^n3. Mage^n^n0. Exit")     show_menu(id, keys, menu)           return PLUGIN_CONTINUE } public setclass(id,key) {     if (key == 0)     {          if (g_playerClass[id] == C_WARRIOR)          {              client_print(id,print_chat,"RuneScape Mod: You are allready a warrior. Pick something else!")              ChangeClass(id)              return PLUGIN_HANDLED          }          g_playerClass[id] = C_WARRIOR          client_print(id, print_chat, "RuneScape Mod: You are now a warrior")     } else if (key == 1) {          if (g_playerClass[id] == C_RANGER)          {              client_print(id,print_chat,"RuneScape Mod: You are allready a ranger. Pick something else!")              ChangeClass(id)              return PLUGIN_HANDLED          }          g_playerClass[id] = C_RANGER          client_print(id, print_chat, "RuneScape Mod: You are now a ranger")     } else if (key == 2) {          if (g_playerClass[id] == C_MAGE)          {              client_print(id,print_chat,"RuneScape Mod: You are allready a mage. Pick something else!")              ChangeClass(id)              return PLUGIN_HANDLED          }          g_playerClass[id] = C_MAGE          client_print(id, print_chat, "RuneScape Mod: You are now a mage")     } else     {         // Exit Option Chosen         return PLUGIN_HANDLED     }     //Show HUD message to show level and xp     runescapehud(id)     return PLUGIN_HANDLED } // ============================================================================================================= // Help Menu // This Menu Crashes With The Choose Class Menu // ============================================================================================================= stock showhelpmenu(id) {     new menu2[192]     new keys2 = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5         format(menu2, 191, "RuneScape Mod: Help Menu^n^n1. What is RuneScape Mod?^n2. Class Skills ^n3. Commands ^n4. FAQ ^n5. Credits ^n6. Want this mod on your server?^n^n0. Exit")     show_menu(id, keys2, menu2)     return } public helpmenu(id, key2, menu2) {     if (key2 == 0) {          show_motd(id, "addons/amxmodx/configs/RuneScape Mod/Help Menu/What is RuneScape Mod.txt", "What is RuneScape Mod?")     }     if (key2 == 1) {          show_motd(id, "addons/amxmodx/configs/RuneScape Mod/Help Menu/Class Skills.txt", "Class Skills")     }     if (key2 == 2) {          show_motd(id, "addons/amxmodx/configs/RuneScape Mod/Help Menu/Commands.txt", "Commands")     }     if (key2 == 3) {          show_motd(id, "addons/amxmodx/configs/RuneScape Mod/Help Menu/FAQ.txt", "FAQ")     }     if (key2 == 4) {          show_motd(id, "addons/amxmodx/configs/RuneScape Mod/Help Menu/Credits.txt", "Credits")     }     if (key2 == 5) {          show_motd(id, "addons/amxmodx/configs/RuneScape Mod/Help Menu/I want this mod on my server.txt", "Want this mod?")     }     else {          //Exit Menu          return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } // ============================================================================================================= // Register Menus // ============================================================================================================= public plugin_init() {     //Change Class Menu     register_menucmd(register_menuid("RuneScape Mod:"), 1023, "setclass")     //Help Menu     register_menucmd(register_menuid("RuneScape Mod:"), 2023, "helpmenu") }

XxAvalanchexX 03-10-2005 22:07

Both menus start as "RuneScape Mod:". Then you register a menu that starts with "RuneScape Mod:", so it finds the first one and picks that. Then you try to register the second one, but you register it with the same text that the first one starts with.

You can use menu titles (the last optional parameter in show_menu), or just specify more of the string when registering the menu.

XunTric 03-11-2005 10:19

Lol, im so stupid.

It works, thanks!


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

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