AlliedModders

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

bwgrubbs1 05-30-2007 15:57

Menu Problems
 
Can someone plz show me how to create a menu and read the input from the user and switch the key to go to different menus...i dont know what im doing wrong...well i do, but i dont know how to read what the user hits...here is what i have.

Code:
public plugin_init() {     register_plugin(Plugin, Version, Author);         register_clcmd("say /rewards", "cmdrewardsmenu", ADMIN_ALL, "")     register_clcmd("say_team /rewards", "cmdrewardsmenu", ADMIN_ALL, "")         TeamInfo = get_user_msgid("TeamInfo");     SayText = get_user_msgid("SayText");     MaxSlots = get_maxplayers();     rewardsMenu = menu_create("Which rewards shall you purchase?", "show_rewardsMenu");     menu_additem(rewardsMenu, "Administrative Rewards", "1", 0, -1);     menu_additem(rewardsMenu, "Player Rewards", "2", 0, -1);     menu_additem(rewardsMenu, "Bunny Hop Rewards", "3", 0, -1);     menu_additem(rewardsMenu, "Fun Stuff", "4", 0, -1);         adminMenu = menu_create("Admin Rewards", "rewards_admin");     menu_additem(adminMenu, "FULL Admin Rights     - 10,000 Points", "1", 0, -1);     menu_additem(adminMenu, "Partial Admin Rights  -  5,000 Points", "2", 0, -1);     menu_additem(adminMenu, "Limited Admin Rights  -  1,000 Points", "3", 0, -1);     playerMenu = menu_create("Player Rewards", "rewards_player");     menu_additem(playerMenu, "Custom Player Model  - 2,500 Points", "1", 0, -1);     menu_additem(playerMenu, "Brass Knuckles       -   900 Points", "2", 0, -1);     bunnyhopMenu = menu_create("Bunny Hop Rewards", "rewards_bunnyhop");     menu_additem(bunnyhopMenu, "Auto Bunny Hop     - 250 Points", "1", 0, -1);     funMenu = menu_create("Fun Rewards", "rewards_fun");     menu_additem(funMenu, "Invincible           -   750 Points", "1", 0, -1);     menu_additem(funMenu, "Invisibility         -   750 Points", "2", 0, -1);     menu_additem(funMenu, "Teleport             -   500 Points", "3", 0, -1);     menu_additem(funMenu, "No Clip              -   500 Points", "4", 0, -1);     menu_additem(funMenu, "Hook                 -   500 Points", "5", 0, -1);     menu_additem(funMenu, "Low Gravity          -   250 Points", "4", 0, -1);     menu_additem(funMenu, "Parachute            -   250 Points", "7", 0, -1);     menu_additem(funMenu, "Glow                 -    50 Points", "8", 0, -1);     menu_additem(funMenu, "Trail                -    50 Points", "9", 0, -1); }

Code:
public cmdrewardsmenu(id, level, cid) {     if( !cmd_access(id, level, cid, 1) )     {         return PLUGIN_HANDLED;     }         menu_display(id, rewardsMenu, 0);         return PLUGIN_HANDLED; }

Code:
public show_rewardsMenu(id, menu, item) {     //i dont know what to do here...to read user input     new key;     switch( key )     {             case '-':         {             return PLUGIN_HANDLED;         }         case '1':         {             menu_display(id, adminMenu, 0);         }         case '2':         {             menu_display(id, playerMenu, 0);         }         case '3':         {                 menu_display(id, bunnyhopMenu, 0);         }         case '4':         {                 menu_display(id, funMenu, 0);         }         case '5':         {             show_points(id);         }     }         return PLUGIN_HANDLED; }

bwgrubbs1 05-30-2007 16:56

Re: Menu Problems
 
I get the main menu to come up if i type /rewards

Which rewards shall you purchase?
1. Admin Rewards
2. Player Rewards
3. Bunny Hop Rewards
4. Fun Rewards
5. Exit

But when i hit a key it just exits out of the menu.

Here is one of the Sub menus...not completed yet.

Code:
public rewards_fun(id) {         new key;     switch( key )     {             case '-':         {             return PLUGIN_HANDLED;         }         case '1':         {             //invincible             client_print(id,print_chat,"INVINCIBILITY COMMING SOON")             menu_display(id, rewardsMenu, 0);         }         case '2':         {             //invisible             client_print(id,print_chat,"INVISIBILITY COMMING SOON")             menu_display(id, rewardsMenu, 0);         }         case '3':         {                 //teleport             client_print(id,print_chat,"TELEPORT COMMING SOON")             menu_display(id, rewardsMenu, 0);         }         case '4':         {                 //no clip             client_print(id,print_chat,"NO CLIP COMMING SOON")             menu_display(id, rewardsMenu, 0);         }         case '5':         {             //hook             client_print(id,print_chat,"HOOK COMMING SOON")             menu_display(id, rewardsMenu, 0);         }         case '6':         {             //low grav             client_print(id,print_chat,"LOW GRAVITY COMMING SOON")             menu_display(id, rewardsMenu, 0);         }         case '7':         {             //parachute             client_print(id,print_chat,"PARACHUTE COMMING SOON")             menu_display(id, rewardsMenu, 0);         }         case '8':         {                 //glow             client_print(id,print_chat,"GLOW COMMING SOON")             menu_display(id, rewardsMenu, 0);         }         case '9':         {                 //trail             client_print(id,print_chat,"TRAIL COMMING SOON")             menu_display(id, rewardsMenu, 0);         }     }         return PLUGIN_HANDLED }

slmclarengt 05-30-2007 17:08

Re: Menu Problems
 
Take a look at mapsmenu.sma and look at the function displayVoteMapsMenu as it contains this type of information. There are plenty of plugins that use menus to reference - just look around. Most of them are probably easier to read than mapsmenu :-).

Slmclarengt

v3x 05-30-2007 18:51

Re: Menu Problems
 
Take a look at my Jump Menu plugin: http://forums.alliedmods.net/showthread.php?p=214497

bwgrubbs1 05-30-2007 23:04

Re: Menu Problems
 
ok, well i still don't understand what I am doing wrong. I can get the main menu to show, but when i hit a key to go to a sub menu, it exits the menu...how do i make this go to the next menu?

bwgrubbs1 05-30-2007 23:17

Re: Menu Problems
 
nvm, i got it, did some searching around. thx tho your jump menu helped


All times are GMT -4. The time now is 10:41.

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