Raised This Month: $ Target: $400
 0% 

Menu Issues


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kensai
Veteran Member
Join Date: Aug 2005
Location: San Diego, California
Old 10-28-2005 , 23:21   Menu Issues
Reply With Quote #1

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 is offline
Send a message via AIM to Kensai Send a message via MSN to Kensai
Kensai
Veteran Member
Join Date: Aug 2005
Location: San Diego, California
Old 10-29-2005 , 18:49  
Reply With Quote #2

Anyone?

If no one knows, does anyone know a similar way to do this, that works?
Kensai is offline
Send a message via AIM to Kensai Send a message via MSN to Kensai
Belsebub
Senior Member
Join Date: Feb 2005
Location: Sweden
Old 10-29-2005 , 19:09  
Reply With Quote #3

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)
Belsebub is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-29-2005 , 19:19  
Reply With Quote #4

That really wont do anything, it will just change the keys...
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Belsebub
Senior Member
Join Date: Feb 2005
Location: Sweden
Old 10-29-2005 , 20:24  
Reply With Quote #5

yes i know, i changed them so he can exit the menu
Belsebub is offline
Kensai
Veteran Member
Join Date: Aug 2005
Location: San Diego, California
Old 10-29-2005 , 20:27  
Reply With Quote #6

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.
Kensai is offline
Send a message via AIM to Kensai Send a message via MSN to Kensai
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-29-2005 , 20:45  
Reply With Quote #7

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 }
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Kensai
Veteran Member
Join Date: Aug 2005
Location: San Diego, California
Old 10-29-2005 , 21:04  
Reply With Quote #8

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

Thanks for code.
Kensai is offline
Send a message via AIM to Kensai Send a message via MSN to Kensai
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-29-2005 , 21:07  
Reply With Quote #9

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....
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Batman/Gorlag
Senior Member
Join Date: Aug 2005
Old 10-30-2005 , 01:39  
Reply With Quote #10

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?
__________________
GRR If only the amxmod programming were in Java.....
Java and C used to be two different languages, now Java is turning into another C. My logevent plugin
Batman/Gorlag is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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