No announcement yet.

[SCRIPTING] Custom Menus (Advanced)

  • Filter
  • Time
  • Show
Clear All
new posts

  • [SCRIPTING] Custom Menus (Advanced)

    WARNINGS: This is NOT for beginners, unless you understand coding well. I recommend not attempting this unless you know what you are doing. Also, when you run the menu in-game, it erases everything in Console, so be forewarned. New information will show up, but the history will be gone.

    This isn't a difficult task, but if you don't know much about coding you may be at a loss. I will try to make this tutorial as simple as I can, and I'll be glad to answer any follow-up questions any of you may have. I am running on the assumption you know how to create .cfg files (if not, click here).

    Step One
    Create a new directory in your /cstrike/cfg/ folder. For simplicity's sake, name it something related to what you are trying to achieve with this menu. In this demonstration, we will be creating a basic comm menu (they will be repeats of what exists in the existing radio comms, but this is purely for the sake of demonstration. Once you get the template down, you'll be able to mod all this easily enough). For this example, our folder is called comms.

    Step Two
    Now we create our main file, which contains all our aliases, binds, and all the code. Call it something simple, like comm_main.cfg. Now this is where we get into the coding.

    Step Three
    First we will set our necessary aliases for this to work. Unless you know what you are doing, do NOT modify anything here. The bolded information is things that you can change, and you will see where it references to in a moment. Also, notice "comm_menu.cfg". We will be creating that shortly. The "comms_new" part is what you alias to a key to bring up the menu/
    alias comms_new "exec comms\comm_menu.cfg; bind 1 c1; bind 2 c2; bind 3 c3; bind 4 c4; bind 5 c5; bind 6 c6; bind 7 c7; bind 8 c8; bind 9 c9; bind 0 clr_menu"
    alias reset_all "bind 0 slot10; bind 1 slot1; bind 2 slot2; bind 3 slot3; bind 4 slot4; bind 5 slot5; bind 6 slot6; bind 7 slot7; bind 8 slot8; bind 9 slot9; clear; cls"
    alias dev1 "developer 1"
    alias dev0 "developer 0"
    alias dev_1 "developer -1"
    alias dv1con "dev1; con_notifytime 28"
    alias dv0con "dev_1; con_notifytime 0"
    alias clr_menu "reset_all; contimes 16; dev0"
    alias pre "clear; dv1con; contimes 48; reset_all"
    Basically this all allows you to display the menu.

    Step Four
    Now we must set what each key does. This is simple enough. Again, change only the bolded sections. The piece in quotes is what gets inputted into the console.
    alias c1 "say_team Enemy spotted; clr_menu"
    alias c2 "say_team Need Backup; clr_menu"
    alias c3 "say_team Sector Clear; clr_menu"
    alias c4 "say_team Affirmative; clr_menu"
    alias c5 "say_team Negative; clr_menu"
    alias c6 "say_team Go go go!; clr_menu"
    alias c7 "say_team Fall Back; clr_menu"
    alias c8 "say_team Enemy Down; clr_menu"
    alias c9 "say_team I'm In Position; clr_menu"
    Note the c1-9's, and how they refer back up the keys we set in Step 3. We are done with this file now though, so save and close. (You can set these to commands as well, not just say_team's. It is just a simple example).

    Step Five
    Time to create the actual menu. Create a new file called comm_menu.cfg (note where this refers to... back at the beginning of Step Three). This will be our menu. Now if you want it to display best, include all the blank spots shown here.

    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo "    -Custom Comm Menu-"
    echo "    1. Enemy Spotted" 
    echo "    2. Need Backup"
    echo "    3. Sector Clear" 
    echo "    4. Affirmative"
    echo "    5. Negative"
    echo "    6. Go go go!"
    echo "    7. Fall Back"
    echo "    8. Enemy down"
    echo "    9. I'm In Position"
    echo "    0. CANCEL" 
    It's a good idea to keep the above format, so it stays nice and readable. Notice how the bolded sections are related to the parts we set in Step Four. Really, you can set this to anything, but it's best to make it something so you know what you're doing :) Now, we're done with this file. Save and close.

    Step Six
    Explore back to your /cstrike/cfg directory, and notice a file named valve.rc. If you have file extensions hidden, you might see only "valve" as the filename. Open it with notepad (or another program if you have it. Personally, I'm partial to EditPlus). The code should look like this (or make sure it has all the lines this has...I can't remember what the original looks like):
    // load the base configuration
    //exec default.cfg
    r_decal_cullsize 1
    // Setup custom controller
    exec joystick.cfg
    // run a user script file if present
    exec autoexec.cfg
    // stuff command line statements
    con_enable 1
    exec userconfig.cfg
    Now add the following line to the end of the file:
    exec comms\comm_main.cfg
    Save, and close.

    Step Seven
    Add a line in your autoexec.cfg file to bind "comms_new" to a key. Now, when you boot up Counter-Strike: Source, you can press that key to bring up your new menu.

    For those aspiring menu-coders out there...if you wish to create multiple pages within one menu, set the button you want to go to the "NEXT" set to something similar to the first line of the comm_main.cfg, where we exec'ed a menu and set the keys to bind.

    Now enjoy your new, custom menu! As always, any questions/comments/etc are welcome.

  • #2
    Re: [SCRIPTING] Custom Menus (Advanced)

    hmmm... Is this what you use for the admin messages? This all looks greek to me. Would it work the same if you just pm'ed me the code you use for it?

    | |




    TeamSpeak 3 Server


    Twitter Feed