AlliedModders

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

Kensai 10-28-2005 23:21

Menu Issues
 
Okay. I've had this problem for quite awhile now. No idea why, but my menu is way screwed up.

Everytime I go to the menu by typing "/ninjamenu" it automatically sets my class to "Strong", and the menu doesn't show.

the second time I type it, it gives me the error that "I'm already a Strong Ninja, pick something else". And shows the menu, but I can't close it using the Exit button. Pretty sure that's just a chuunk of code I left out, but doesn't explain the above errors.

Here's the menu code.

Code:
    register_menucmd(register_menuid("menu_ChooseType"),1023,"DoChooseType");

Code:
public ChooseType(id) {             new menu[192]       format(menu, 191, "Ninja Mod: Choose Ninja Type^n^n1. Strong^n2. Fast^n3. Stealthy^n4. Balanced^n^n0. Exit")       new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)     show_menu(id, keys, menu, 15, "menu_ChooseType")               return PLUGIN_HANDLED }   public DoChooseType(id, key) {             switch(key) {                   case 0: {                             if(PlayerClass[id] == CLASS_STRONG) {                                     client_print(id, print_chat, "[Ninja Mod] You are already a Strong Ninja! Choose something else!")                   ChooseType(id)                             return PLUGIN_HANDLED               }                           PlayerClass[id] = CLASS_STRONG             set_user_maxspeed(id,320.0)             cs_set_user_model(id,"models/player/ninja.mdl")             client_print(id, print_chat, "[Ninja Mod] You are now a Strong Ninja!")                           return PLUGIN_HANDLED         }                   case 1: {                             if(PlayerClass[id] == CLASS_FAST) {                                     client_print(id, print_chat, "[Ninja Mod] You are already a Fast Ninja! Choose something else!")                   ChooseType(id)                   return PLUGIN_HANDLED               }                           PlayerClass[id] = CLASS_FAST               set_user_maxspeed(id,1000.0)             cs_set_user_model(id,"models/player/ninja.mdl")             client_print(id, print_chat, "[Ninja Mod] You are now a Fast Ninja!")                             return PLUGIN_HANDLED         }                     case 2: {                             if(PlayerClass[id] == CLASS_STEALTHY) {                                     client_print(id, print_chat, "[Ninja Mod] You are already a Steatlhy Ninja! Choose something else!")                   ChooseType(id)                   return PLUGIN_HANDLED               }                           PlayerClass[id] = CLASS_STEALTHY               set_user_maxspeed(id,320.0)             cs_set_user_model(id,"models/player/ninja.mdl")             client_print(id, print_chat, "[Ninja Mod] You are now a Stealthy Ninja!")                             return PLUGIN_HANDLED         }                         case 3: {                             if(PlayerClass[id] == CLASS_BALANCED) {                                     client_print(id, print_chat, "[Ninja Mod] You are already a Balanced Ninja! Choose something else!")                   ChooseType(id)                   return PLUGIN_HANDLED               }                           PlayerClass[id] = CLASS_BALANCED               set_user_maxspeed(id,320.0)             cs_set_user_model(id,"models/player/ninja.mdl")             client_print(id, print_chat, "[Ninja Mod] You are now a Balanced Ninja!")                             return PLUGIN_HANDLED         }     }           return PLUGIN_HANDLED   }

Kensai 10-29-2005 18:49

Anyone?

If no one knows, does anyone know a similar way to do this, that works?

Belsebub 10-29-2005 19:09

change
Code:

new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)
to
Code:

new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<9)

Zenith77 10-29-2005 19:19

That really wont do anything, it will just change the keys...

Belsebub 10-29-2005 20:24

yes i know, i changed them so he can exit the menu

Kensai 10-29-2005 20:27

LOL! Duh.

Ok thanks man. But my main problem is the setting of the player class when they enter the menu.

I also want it to pop up for players that first join.

Zenith77 10-29-2005 20:45

Code:
#define TASK_SHOW 854894894 public client_connect(id) {      set_task(10.0, "showMenu", TASK_SHOW+id) } public showMenu(id) {     id-= TASK_SHOW    // Show menu here }

Kensai 10-29-2005 21:04

What's with the define? What does 854894894 do?

Thanks for code.

Zenith77 10-29-2005 21:07

Just defines it to some random number, so if some other function of another plugin uses remove_task() chances are it wont remove that task your plugin uses....

Batman/Gorlag 10-30-2005 01:39

Actually you should use client_putinserver, not client_connect. client_connect is called when a player starts connecting to the server. client_putinserver is called when the user is actually in the game, meaning the user has fully connected, and not still connecting.

My point is use client_putinserver to make the menu pop-up when the player first joins in the game. That way you can also avoid setting a task as well.

So your modified code would look like this:

Code:
public client_putinserver(id) {    //call the menu function to show the menu and do stuff. }

Makes life easier doesn't it? :wink:


All times are GMT -4. The time now is 23:36.

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