Splak.net
http://splak.net/forum/

Custom GUI Menu Tutorial...
http://splak.net/forum/viewtopic.php?f=4&t=924
Page 1 of 1

Author:  VMAN [ Thu Jan 10, 2008 7:01 am ]
Post subject:  Custom GUI Menu Tutorial...

Counter-Strike: Condition Zero has supported this feature for a long time now, I've used it for quite a while, and would like to show you guys too :wink: .

So what exactly does this do? Well, here's a screenshot of what you can do with this feature.
Image
^^ Thats the menu some guy made for himself, I have the code for it, but I'm not just going to let you have it :? .

How to make it:

Well, the first thing that you are going to be wanting to do, is open up a fresh new document in Notepad. (Start -> All Programs -> Accessories -> Notepad).


The basic format that will be used within this file is:

Code:
"Bound Key" "Button Text" "Command To Be Executed"


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 your 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: Start coding! Add your 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:

Code:
 "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:
Image


Step 3: 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:

Code:
"Bound Key" "Button Text" "Command To Be Executed"


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

Code:
 {
   "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:
Image


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:

Code:
 "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:

Code:
 {

      "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:

Code:
"Bound Key" "Button Text" "Command To Be Executed"


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

Code:
 {

     "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:

Code:
  "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 Be Executed".


Step 7: Saving and moving the file to the correct directory.
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

After this file has been saved, move it to you "czero" folder (C:\Program Files\Valve\Steam\steamapps\*username*\condition-zero\czero) and start up Counter-Strike: Condition Zero (restart if already started).


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. To do this, open up your console(~) and type the following:

bind "o" "+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!


Source: http://www.counter-script.net/index.php?id=21


Good coding habits:

•Use your space and TAB keys!!
Always leave good room and space to read through your work easily.


•Take your time.
Coding requires patience, if you rush through a project without even checking through it, you're bound to fall into a problem.


•USE QUOTES!!
Use quotes when defining commands, text, etc.


•Leave comments throughout your work.
Its great to leave comments to define what is going on in what area.

Example:
Code:
// Start visual settings code.
  "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"
      }
  }
// End visual settings code code.


ANYTHING THAT BEGINS WITH '//' IS A COMMENT.



Have fun with this guys, if you figure it out, you have just learned basic CZ Scripting :D .

Author:  $torm [ Thu Jan 10, 2008 10:21 am ]
Post subject: 

I saw this awhile back on a website, but lookkeed wayyyy too confusing for my liking :lol: i stick with the normal stuff.

Author:  Lucky Aura [ Thu Jan 10, 2008 11:46 am ]
Post subject: 

Awesome...

Author:  Mr.orange [ Thu Jan 10, 2008 2:41 pm ]
Post subject: 

already use cshelper :/

Author:  Display [ Thu Jan 10, 2008 2:43 pm ]
Post subject: 

CSHelper and this are pretty useless. I find just typing in the commands in manually in console is much faster

Author:  bob [ Thu Jan 10, 2008 10:21 pm ]
Post subject: 

i'm not going to say useless, there is def. a place for it,


its just your personal preference.

i too prefer to use the "type in the command in console"

Author:  Nevermind [ Fri Jan 11, 2008 1:37 am ]
Post subject: 

I like cshelper for the start of games i.e. key for nade, kev, kit, deg, etc... but I will not code outside of school. Java SUCKS.

Author:  The Wonderguy [ Sat Jan 12, 2008 12:27 am ]
Post subject: 

Nevermind

The stuff you can create with just that is amazing. Just look at Runescape, granted its a boreing game, it a master piece of Javascript.

Author:  PePTo [ Sat Jan 12, 2008 10:08 am ]
Post subject: 

2MT

Page 1 of 1 All times are UTC - 6 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/