Jump to content

[Tutorial]CommandMenu Script


Grim.

Recommended Posts

This tutorial will guide you through the process of creating a Commandmenu script. These scripts are fairly common now and have been around since the adoption of the Commandmenu in CS 1.3 (circa September of 2001). This type of script allows you to choose various commands or change settings in a GUI-type menu instead of using the console window to modify them.

 

Now we need to establish the basic information that is needed to get a Commandmenu script working properly. First, there is the commandmenu.txt file located in your cstrike directory.

 

 

 

You can open this file using Notepad and take a look. It should look similar to this:

 

 

 

The basic format within the commandmenu.txt is:

 

"Bound Key" "Button Text" "Command sent to server"

 

You will see that again later.

 

You can have a maximum of 40 menus, and a maximum of 100 buttons per menu. These limits give you more than enough options for any CS command you could ever want in a GUI menu.

 

For this tutorial I will be creating a simple Settings Commandmenu script that does not need any other files to work properly.

 

Step #1: Identify Commands

Identify what commands you want to use in the GUI menu. Pick out some settings that you will be using in your script and that you think would be beneficial to have in a GUI menu.

 

For this tutorial I will use the "volume" command and the "net_graph" command for the examples.

 

Step #2: Edit Commandmenu.txt (Add Main Menus)

Each Main menu should be laid out in numerical order. Here we will add a menu for our first setting from Step #1 "volume". Since it is our first Main Menu, we will set the "Bound key" to "1" and label the Button Text as "Volume Adjuster".

 

At this time, open up a blank file with Notepad and insert the following text:

 

"1" "Volume Adjuster"

{

 

}

 

Notice the brackets below the text. These must start and end your submenus like bookends. A left bracket is the starting bracket and the right bracket is the ending bracket. If you used this Menu in the game at this point, it would look like this:

 

 

 

Step #3: Edit Commandmenu.txt (Add Settings)

Now that we have added our first main menu "Volume Adjuster", we will add settings for this menu. Here we will input the text within the brackets and remember the standard format:

 

  "Bound Key" "Button Text" "Command sent to server"

 

Now type (cut & paste) the following settings to your file:

 

{

  "1" "Volume Off" "volume 0.0; dev1; echo Volume Muted; dev0"

  "2" "Volume 10%" "volume 0.1; dev1; echo 10% Volume; dev0"

  "3" "Volume 20%" "volume 0.2; dev1; echo 20% Volume; dev0"

  "4" "Volume 30%" "volume 0.3; dev1; echo 30% Volume; dev0"

  "5" "Volume 40%" "volume 0.4; dev1; echo 40% Volume; dev0"

  "6" "Volume 50%" "volume 0.5; dev1; echo 50% Volume; dev0"

  "7" "Volume 60%" "volume 0.6; dev1; echo 60% Volume; dev0"

  "8" "Volume 70%" "volume 0.7; dev1; echo 70% Volume; dev0"

  "9" "Volume 80%" "volume 0.8; dev1; echo 80% Volume; dev0"

  "0" "Volume 90%" "volume 0.9; dev1; echo 90% Volume; dev0"

  "-" "Volume Max" "volume 1.0; dev1; echo Max Volume; dev0"

}

 

Notice that everything is contained in quotes and that each line starts with the "Bound Key", then the text that will be displayed on the button "Button Text", and finally the command that will be executed. Also, note that we inputted the settings within the original brackets. The in-game menu would now look like this:

 

 

 

Step #4: Add Another Main Menu

At this time we will add another Main Menu to our file below the last bracket of the Volume Adjuster menu. This time we will use "2" for the bound key, since "1" is already used, and we will label this menu "Visual Settings". Type the following into your file:

 

"2" "Visual Settings"

{

 

}

 

Step #5: Add a Submenu

 

Now for the first time we will add a menu below the Main menu before adding settings. This would be used if you wanted to organize your main menus into various submenus for ease of use. For example, you might have Main Menu labels for Buys, Settings, and Demos, and then have submenus in each of those that correspond with the main menu.

 

We will add a submenu in the same fashion as we added the main menu,

 

except that we will add this menu within the brackets of the main menu. Here we will label the bound key as "1", since it is the first sub-menu in the "Visual Settings" main menu. We will give this menu a label of "Net Graph Settings". Now you can type the following (in bold) into your file:

 

{

 

      "1" "Net Graph Settings"

      {

 

      }

 

}

 

Notice that I indented the file to keep everything organized and in some sort of tabular format.

 

This is not required, but is a good idea.

 

Step #6: Add Settings

 

Now that we have added our first sub menu "Net Graph Settings" we will add settings

 

for this menu. Here we will input the text within the brackets and remember the standard format:

 

"Bound Key" "Button Text" "Command sent to server"

 

Now type (cut & paste) the following settings (in bold) to your file:

 

{

 

    "1" "Net Graph Off" "net_graph 0"

    "2" "Net Graph 1 On" "net_graph 1"

    "3" "Net Graph 2 On" "net_graph 2"

    "4" "Net Graph 3 On" "net_graph 3"

    "5" "Cancel "slot10"

 

}

 

Notice that I added a cancel option with this menu to close the screen and cancel your choices.

 

At this point your file should look like this:

 

  "1" "Volume Adjuster"

  {

"1" "Volume Off" "volume 0.0; dev1; echo Volume Muted; dev0"

"2" "Volume 10%" "volume 0.1; dev1; echo 10% Volume; dev0"

"3" "Volume 20%" "volume 0.2; dev1; echo 20% Volume; dev0"

"4" "Volume 30%" "volume 0.3; dev1; echo 30% Volume; dev0"

"5" "Volume 40%" "volume 0.4; dev1; echo 40% Volume; dev0"

"6" "Volume 50%" "volume 0.5; dev1; echo 50% Volume; dev0"

"7" "Volume 60%" "volume 0.6; dev1; echo 60% Volume; dev0"

"8" "Volume 70%" "volume 0.7; dev1; echo 70% Volume; dev0"

"9" "Volume 80%" "volume 0.8; dev1; echo 80% Volume; dev0"

"0" "Volume 90%" "volume 0.9; dev1; echo 90% Volume; dev0"

"-" "Volume Max" "volume 1.0; dev1; echo Max Volume; dev0"

  }

  "2" "Visual Settings"

  {

"1" "Net Graph Settings"

{

"1" "Net Graph Off" "net_graph 0"

"2" "Net Graph 1 On" "net_graph 1"

"3" "Net Graph 2 On" "net_graph 2"

"4" "Net Graph 3 On" "net_graph 3"

"5" "Cancel" "slot10"

}

  }

 

 

 

Each menu has a starting and ending bracket to include the submenus. Also, each menu has a "Bound Key" and "Button Text", while the actual settings include a "Bound Key", "Button Text", and the "Command to Server".

 

Step #7: Saving & Moving File

At this time our Commandmenu script is almost complete. Now that you have verified yours is correct, we will save the file. Since the file is a standard txt file, all you have to do is verify your spelling and save the file as:

 

commandmenu.txt

 

Once the file is saved you will want to rename your original commandmenu.txt file that is in your cstrike directory. Once you have renamed it to something like commandmenubak.txt, you can move your newly made one into the cstrike folder.

 

Step #8: Binding the Commandmenu

The final step in creating a Commandmenu script is to bind a key to the command: +commandmenu. This is the command that will open up your Commandmenu script. You have a few options at this time. The first one is to go to your in-game controls menu and bind a key to the "Activate in-game GUI" command. Your other option is to add a bind to your config.cfg or other cfg file like the following:

 

&nbspbind "b" '+commandmenu"

 

That's it! You are ready to go out and try your new Commandmenu Script. Also, you can add more menus and settings as you please to create your own custom Commandmenu Script. Good Luck!

Write comment (0 Comments)

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...