Raised This Month: $ Target: $400
 0% 

[Solved] Menu Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-21-2005 , 12:30   [Solved] Menu Problem
Reply With Quote #1

Hey All. I decided it was time to sit down to right a menu, so you can change Alliances and Occupation ("Races" and "Classes") in the mod i'm working on. I cannot get the menu to work though. I can see it, it looks fine; it just doesn't DO anything. Not sure what's wrong, I've looked at a few examples and it looks ok to me.

Code:
//regsiter menu in plugin_init register_menucmd(register_menuid("Select an Alliance"), 1023, "SetAlliance") register_clcmd("AllianceMenu", "ShowAllianceMenu") //menu vars in the vars.inc file new Menu[1024] new MKeys3 = (1<<0|1<<1|1<<2|1<<9) //show the menu in the menus.inc file public ShowAllianceMenu(id) { format(Menu, 1023, "Select Alliance:^n^n1. Zionists^n2. Machines^n3. Exiles^n^n0. Cancel")     show_menu(id, MKeys3, Menu)     return PLUGIN_HANDLED }   //handle the menu events in the menus.inc file //allow user to set alliance public SetAlliance(id, key) {     //Debug     client_print(0, print_chat, "Applying Menu Code!")         //display current alliance to user     new CurrentAlliance[8]         if(PlayerAlliance[id] == 0)         format(CurrentAlliance, 8, "Bluepill")     if(PlayerAlliance[id] == 1)         format(CurrentAlliance, 8, "Zionists")     if(PlayerAlliance[id] == 2)         format(CurrentAlliance, 8, "Machines")     if(PlayerAlliance[id] == 0)         format(CurrentAlliance, 8, "Exiles")             //Debug     client_print (id, print_chat, "You are currently allied with the %s", CurrentAlliance)         //key will start at zero     if (key == 0)     {          return PLUGIN_HANDLED     } else if (key == 1) {          PlayerAlliance[id] = 1          client_print(id, print_chat, "You will now train for the Zionists!")     } else if (key == 2) {          PlayerAlliance[id] = 2          client_print(id, print_chat, "You will now train for the Machines!")     } else if (key == 3) {         PlayerAlliance[id] = 3         client_print(id, print_chat, "You will now train for the Exiles!")     }     SaveAlliance(id)     return PLUGIN_HANDLED }

Now, when I type AllianceMenu in the console, the menu comes up. I hit a key and it goes away, but I don't see any of the debug messages. Also, I created a GetAlliance procedure that tells me a user's alliance. By this check, the alliancevar for that player is never changed.

Also, I want this menu to show when a new player logs in for the fisrt time. I added a call to the procedure (ShowAllianceMenu(id)), but it doesn't show when I delete my vault.ini file and log in. Also, I don't see any of the debug messages there. I think it's because the code is run BEFORE you get into the server. Is there a way to catch an event for say, when they join a team?

If somebody could answer all that i'd be really grateful Thanx
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 04-21-2005 , 15:18  
Reply With Quote #2

Quote:
I can see it, it looks fine; it just doesn't DO anything.
All I had to do was read that to know your problem, you probably made one of the most n00b mistakes is all, don't worry. ;-)

Code:
register_menuid("Select an Alliance")
Code:
format(Menu, 1023, "Select Alliance:

Stare at those two lines until you figure it out.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-21-2005 , 20:45  
Reply With Quote #3

lol, i am a nub.. never done menus before. Now i'm going to assume that the name you register the menu with has to be the same as the beginning of the menu. Correct? I don't get how that would work though, is it everything until the first ^n? Well, I'll give that a try, hope it works.
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-21-2005 , 20:57  
Reply With Quote #4

Basically, AMXX searches for a menu whos text starts with the same substring you registered the menu with..
The longer the substring you use to register the menu, the more unique it will be, so it won't collide with other registered menus..
xeroblood is offline
Send a message via MSN to xeroblood
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-21-2005 , 21:28  
Reply With Quote #5

OK, thanx
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 04-21-2005 , 21:44  
Reply With Quote #6

Although, one thing that hardly anyone does because they probably neglect to look at the native definition is to assign a menu a title instead of using its starting text.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX 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 10:02.


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