Write your own command menu!


Pinhead
05-23-2003, 05:50 PM
Since it seems like people really liked a command menu they could choose different dod options with and the like i thought I'd write a little tutorial about how you can customize your own command menu to suit your needs. I'll do my best anyway. :)


Well, the first you should do is to open your day of defeat folder and open the commandmenu.txt file in your trusty notepad. The notepad program can be easily accessed by clicking Start and choosing Run. Just type "notepad" without the " 's and hit enter or OK. This file is useful too look at as a sort of refrance while your writing your own. Now open another notepad window and create a new file. Lets call it commandmenu2.txt, or something like that.
Now that you have this tutorial open, the default dod command menu and your little newly saved commandmenu2.txt open we are ready to begin.


Console commands:


Now, most of you at least know one or two HL commands. That is, the commands you type in your console to change HL specs. Most of you know, for example the "name" command. If you wanted to change your nick in HL/DOD all you have to do is drop down your console and type:
name (your new nick, without the ()'s)

So if i wanted to change my name to Pinhead I'd type:
name Pinhead

Instantly my name will change to Pinhead. Or you could try another command, like say, the net_graph command. There are multiple net graphs you can use in HL to find out what your choke is, or loss, ping or FPS. Net_graph has three settings. These three settings decides how the net_graph will look. Net graph 1 and 2 will have info and different graphs, while net_graph 3 will only have info in pure text displayed in the corner of your screen. If you wanted to have a netgraph showing in the corner of your screen use the net_graph command. Pull your console down and type:
net_graph 1.

Hm... the text is useful, but I'm not quite sure if I like that anoying graph bobbing up and down on my screen. It's very anoying! So i think I'll remove the graph itself and have pure text. Yank your console down and type:
net_graph 3

Yeah, thats better. Now all settings like name, net_graph, cl_fog (dod fog effect), cl_dynamic_xhair (dynamic crosshair in dod). All this stuff is saved in the config.cfg file that lays in your dod folder. When you use a command like "name" or "net_graph" the setting is saved in this folder. So every time you change a setting in dod, it is recorded in this little file. It's fairly easy to read. Each line is one specific setting. The console can also be used to execute voice commands and the likes. When you press the C button you get a voice command menu. This voice menu is simply text in a file that has a line for each number you press on your keyboard, next to it saying that, for example; "If you press 1 then I'll run the voice_yessir command". This voice command is programed to play the sound file and show the text in the corner of the screen.

The command menu is simply a series of shortcuts to different HL commands you can type in your console. Instead of having to type it you can just press a button and choose the execute the command by clicking on the appropriate button in the manu.

Now that we've got that out of the way let's get to the command menu creation already! :rolleyes:


Creating a command menu:


Start by typing, in your commandmenu2.txt file:

"1" "New name: Jack" "name jack"

If you want you can take a backup of your original command menu file and rename commandmenu2.txt to commandmenu.txt and run dod to have a look at your new command menu. Sure it's small, but thats how you start out. You gotta learn to crawl before you learn to walk, right? :) If you run dod now and hit the command menu button you should get a fairly simple command menu showing up. Just one button called "New name: Jack". If you press it your name changes! Isn't that neat? Now let me explain the line in the commandmenu file you wrote.

"1"
The "1" Just gives your button a number. This number isn't important, but theres no reason for leaving it out. The number lets you use the numbers on your keyboard to push the button instead of using your mouse. Press the button to make you command menu appear and then press "1" on your keyboard. The command is executed without needing to click the button with your mouse.

"New name: Jack"
This segment of the line defines what the button in the VGUI should say. If you typed "I really like pie!" instead, thats what the button would say! It's important to use short texts because the number of letters viewable on the button is limited. You can't call call you button "Hello, my name is jim and I like to go to the Zoo. I think the zebra is a cool animal." Well, you could, but you wouldn't be able to see the entire text. You better do some experimenting to find out what is possible.

"name Jack"
Now that we've gonne through two of the three parts of the line you should be able to figure out what this part means. Thats right! It tells dod what command should the executed when you hit the button. In this case it tell dod to execute "name Jack". Which is the same command i briefly explained previously.


Now that you have written your first line it's time to get a little bit more advanced. Don't worry, not too advanced. Under the first line in your command menu type three new lines.

"2" "Net Graph 1" "net_graph 1"
"3" "Net Graph 2" "net_graph 2"
"4" "Net Graph 3" "net_graph 3"

Now your entire file should read:
"1" "New name: Jack" "name jack"
"2" "Net Graph 1" "net_graph 1"
"3" "Net Graph 2" "net_graph 2"
"4" "Net Graph 3" "net_graph 3"

I Really don't think i need to get too deep when it comes to explaining these lines either if you understood the first line.
"2" "Net Graph 1" "net_graph 1" tells dod to make the second command menu button to read "Net Graph 1" and execute the command "net_graph 1". The third line tells the command menus third button to read "Net Graph 2" and execute the command "net_graph 2" and so on...

Now if you look at the command menu in-game you will notice that we are starting to run out of space very quickly! Have no fear! Brackets are here! The great thing about the VGUI is that you can cram a whole buttload of commands in there by using sub-menus. Like, if you hold your mouse pointer over an unclickable button a new menu appears next to it. You can even create a menu inside that menu again. All in all you can have over 100 commands in a single VGUI! Theoretically you could have much more but there is a button limit. Let's use this ablity to sort these current commands and save some space! Modify your commandmenu.txt to look like this(or copy paste my text):

"1" "New name: Jack" "name jack"
"2" "Net Graphs" {
"1" "Net Graph 1" "net_graph 1"
"2" "Net Graph 2" "net_graph 2"
"3" "Net Graph 3" "net_graph 3"
}

Now, this is starting to look like a command menu!

If you save that and look at it in dod you'll see that the three "Net Graph #" buttons have been replaced by a single, unclickable button, reading "Net Graphs". But if you hold your mouse pointer over it the three "Net Graph #" buttons appear next to the main menu. These buttons act just like other command menu buttons.

Now lets look at the "code":
"2" "Net Graphs" {
}
This creates a button given the number 2 and labeled "Net Graphs". The {} brackets tell dod thich buttons are supposed to be in the sub-menu, under this button.

"1" "Net Graph 1" "net_graph 1"
"2" "Net Graph 2" "net_graph 2"
"3" "Net Graph 3" "net_graph 3"

These are the buttons which lay in the sub-menu. These buttons work lake the command menu of its own. So if you were to add a menu INSIDE the sub-menu that would work just fine! Like:

"1" "Options" {
"1" "Net Graphs" {
"1" "Net Graph 1" "net_graph 1"
"2" "Net Graph 2" "net_graph 2"
"3" "Net Graph 3" "net_graph 3"
}
"2" "Nicks" {
"1" "Jack" "name jack"
"2" "1337" "name 1337_dude"
"3" "dodfan" name dodfannr1"
}
}

Woah! This is starting to get complicated! Remember to use the TAB button ALOT to show which buttons belong where. Also keep controll of your brackets. Too few or two many, misplaced or whatever leads to strange looking command menus.

Lets look at the code:
"1" "Options" {
}

The first, unclickable, sub-menu opener.
"1" "Net Graphs" {
}
"2" "Nicks" {
}

These are the two sub-menus. Frmo here you can move to two sub-sub-menus. Either the ones controlling net_graph under the "Net Graphs" button, or the name-changing menu under the "Nicks" button.

"1" "Net Graph 1" "net_graph 1"
"2" "Net Graph 2" "net_graph 2"
"3" "Net Graph 3" "net_graph 3"

"1" "Jack" "name jack"
"2" "1337" "name 1337_dude"
"3" "dodfan" name dodfannr1"

These lie en their own menus. Each button executes a command. This way you can just pile together a whole bunch of commands using clever sub-menus.

Right now you should be able to make the simplest buttons in the command menu. But I'll explain one more thing. Make a new line under your "Options" button. Remeber that this means that you have to put the button UNDER the closing bracket for the "Options" button! Like:

"Options" {
(sub menus and stuff)
}
Here you can put the button that is going to be under the options button.

Ok, under your options button type:

"2" "Lots of stuff" "name DodFanNr1; say HEY EVERYONE I LOVE DOD!!!"

Hm... That command section of the line looks alot longer does't it? Yes, thats because i made the button execute two commands instead of just one. First the button will change your name to "DodFanNr1". And after that it will tell the people in the server that you love dod. The say command is the command you run when you press your "y" button and write stuff.


Well, thats it for now. I might add more stuff if i remember something.


GOOD LUCK!


It's now very late so i'll have to stop. I'm leaving you with this fith button i added to the original command menu. I kept the voice command and hand signals and added a fith button that executes admin mod commands. Examine it and see if you can make anything out of it!

EDIT: Did some spell checking and added about multiple commands for one button.

"5" "Administrator"
{
"1" "Messages" {
"1" "Friendly Fire" "admin_csay Remember, Friendly fire is on!"
"2" "TKing and TWing" "admin_csay Teamkilling and Teamwounding will not be tollerated"
"3" "Use !forgivetk" "admin_csay Use !forgivetk to forgive your teamkiller"
"4" "Admins Present" "admin_csay Remember, admins are present! Behave!"
"5" "Spawncamping" "admin_csay Do not spawncamp!"
"6" "Kick warn or ban" "admin_csay If you can't behave yourself you will be kicked or banned"
"7" "Leave Request" "admin_csay Clan activity requires you to leave the server"
"8" "Balance teams" "admin_csay Keep the teams balanced"
"9" "Snipers and MGs" "admin_csay Keep the sniper and MG count to a reasonable level"
}
"2" "Settings" {
"1" "Server password" {
"1" "Set as '123'" "admin_pass blahblah"
"2" "Clear password" "admin_nopass"
}
"2" "Tk Penalty" {
"1" "Disable" "admin_tkpenalty -1"
"2" "3" "admin_tkpenalty 3"
"3" "4" "admin_tkpenalty 4"
"4" "5" "admin_tkpenalty 5"
"5" "7" "admin_tkpenalty 7"
"6" "10" "admin_tkpenalty 10"
}
"3" "Death messages" {
"1" "Enable" "admin_deathmsg 1"
"2" "Disable" "admin_deathmsg 0"
}
}
"3" "Map controll" {
"1" "Start mapvote 1" {
"1" "Anzio" "admin_vote_map dod_anzio"
"2" "Avalanche" "admin_vote_map dod_avalanche"
"3" "Caen" "admin_vote_map dod_caen"
"4" "Charlie" "admin_vote_map dod_charlie"
"5" "Chemille" "admin_vote_map dod_chemille"
"6" "Donner" "admin_vote_map dod_donner"
"7" "Flash" "admin_vote_map dod_flash"
"8" "Forest" "admin_vote_map dod_forest"
"9" "Glider" "admin_vote_map dod_glider"
}
"2" "Start mapvote 2" {
"1" "Jagd" "admin_vote_map dod_jagd"
"2" "Kalt" "admin_vote_map dod_kalt"
"3" "Kraftstoff" "admin_vote_map dod_kraftstoff"
"4" "Merderet" "admin_vote_map dod_merderet"
"5" "Vincenza" "admin_vote_map dod_vincenza"
"6" "Zalec" "admin_vote_map dod_zalec"
}
"3" "Change map to: 1" {
"1" "Anzio" "admin_map dod_anzio"
"2" "Avalanche" "admin_map dod_avalanche"
"3" "Caen" "admin_map dod_caen"
"4" "Charlie" "admin_map dod_charlie"
"5" "Chemille" "admin_map dod_chemille"
"6" "Donner" "admin_map dod_donner"
"7" "Flash" "admin_map dod_flash"
"8" "Forest" "admin_map dod_forest"
"9" "Glider" "admin_map dod_glider"
}
"4" "Change map to: 2" {
"1" "Jagd" "admin_map dod_jagd"
"2" "Kalt" "admin_map dod_kalt"
"3" "Kraftstoff" "admin_map dod_kraftstoff"
"6" "Zalec" "admin_map dod_zalec"
}
"5" "Mapvote" {
"1" "Start mapvote" "admin_startvote"
"2" "Cancel mapvote" "admin_cancelvote"
}
"6" "List Maps" "admin_listmaps"
}
"4" "Miscellaneous" {
"1" "Slay Team" {
"1" "Slay Allies" "admin_slayteam 1"
"2" "Slay Axis" "admin_slayteam 2"
}
"2" "Userlist" "admin_userlist"
}
}

Wren
05-23-2003, 05:58 PM
Hot damn. Still reading it. But looks quite informative. Thanks(I think, ;D)

=DD=Wolf Kahler
05-23-2003, 10:20 PM
...This deserves a sticky. I've never seen a tutorial for this before [not that that's saying much, mind you], but it's needed. Thanks, Pinhead.

05-23-2003, 10:21 PM
Sticky!

Pinhead
05-24-2003, 02:21 AM
Bump

Did i slave over this computer for over an hour in the middle of the night for 3 replies? :eek:

DAM(M)
05-24-2003, 02:39 AM
Thnx for it!

I can use that well!

05-24-2003, 03:02 AM
OOOOOOLD :o

Pinhead
05-24-2003, 04:28 AM
Old? Huh? Whats old?

Lt. Firmalo
05-24-2003, 04:41 AM
Uwesome :)

Day of Defeat Forum Archive created by Neil Jedrzejewski.

This in an partial archive of the old Day of Defeat forums orignally hosted by Valve Software LLC.
Material has been archived for the purpose of creating a knowledge base from messages posted between 2003 and 2008.