AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] Menu Problem (https://forums.alliedmods.net/showthread.php?t=12680)

BioHazardousWaste 04-21-2005 12:30

[Solved] Menu Problem
 
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

XxAvalanchexX 04-21-2005 15:18

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.

BioHazardousWaste 04-21-2005 20:45

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.

xeroblood 04-21-2005 20:57

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..

BioHazardousWaste 04-21-2005 21:28

OK, thanx :)

XxAvalanchexX 04-21-2005 21:44

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.


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

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