AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why this menu not working...? (https://forums.alliedmods.net/showthread.php?t=29098)

Rolnaaba 05-29-2006 14:47

Why this menu not working...?
 
Code:
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2     register_menucmd(register_menuid("Silver Weapons Mod"),keys,"giveWeapon")
that is plugin init

Code:
//*****{SHOWS MENU}***** public showWeaponMenu(id)   {       new menu[192]       new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2           format(menu, 191, "Silver Weapons Mod^n^n1. Silver AK47^n2. Silver M4A1^n3. Silver AWP^n")       show_menu(id, keys, menu)       return PLUGIN_HANDLED   } //*****{GETS BUTTON U CHOOSE ON MENU}***** public giveWeapon(id, key)   {       if (key == 0)       {           funcbuyak(id)     }     else if (key == 1)       {           funcbuym4(id)     }     else if (key == 2)     {           funcbuyawp(id)     } }
and that shows the menu and gets key you press but for some reason when you choose the third option is does not execute the third, why lol?

Hawk552 05-29-2006 14:49

show_menu(id,keys,menu,"Silver Weapons Mod")

Rolnaaba 05-29-2006 14:54

but how wil that fix the problem with the third func? if I jsut add "Silver Weapons Mod" to that show_menu code snipette it won't change much will it?

Peli 05-29-2006 15:12

Switch to cases:
Code:
public giveWeapon(id, key)   {      switch(key)    {       case 0:       {          funcbuyak(id) // Don't know what you are trying here, but fix it       }             case 1:       {          funcbuym4(id)       }       case 2:       {          funcbuyawp(id)       } }

Hawk552 05-29-2006 15:12

That will solve it. Peli's comment will not add any functionality but it slightly optimizes the script.

Rolnaaba 05-29-2006 15:49

ahh that fixed it ty very much


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

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