Sign in to follow this  
Staticiser

How to Setup Crouching/Walking Toggles

4 posts in this topic

How to Setup Crouch/Walking Toggles

 

For those who may be frustrated, or for your information, this topic will be a howto guide on setting up custom key binds which toggle between the states of crouching or walking. This technique can also be used to add some interesting outcomes to role play scenarios which I will cover at the end of the guide, however there are some downsides.

 

Crouching/Walking Toggle

To start, you will need to navigate to your GMod configuration files, and the file autoexec.cfg in particular.

Steam\steamapps\common\GarrysMod\garrysmod\cfg\autoexec.cfg

Using notepad (or similar program), open up autoexec.cfg

You should be presented with an empty document. For starters, select the key you wish to bind to either crouch or walking. In this example I will be using h for a walking toggle. The first Entry you want to make is

bind h "wt1"

Replace h with your chosen key, and you can also name wt1 to anything you please (this is an identifier for the allias's we are about to create.)

On the line below, we will now define the alias known as wt1.

alias wt1 "+walk;bind h "wt2""

To break this down, when we run the alias wt1 through our new bind, we are calling the command +walk, which keeps your character walking without the use of holding down the key. The second part rebinds to the next alias being wt2. You are able to rename this to however you please aswell.

In order to remove our character from constantly walking, we create the next alias wt2

alias wt2 "-walk;bind h "wt1""

To break down this, we must assume we have already toggled our walk to on using h. Having run the first alias, is now bound to run the alias wt2. Pressing will now run alias wt2 which removes you from constantly walking (-crouch) and rebinds h back to wt1. The next time you press will now return you to a state of constantly walking, and will continue to toggle between the two. The final outcome in your autoexec.cfg should now include.


bind h "wt1"

alias wt1 "+walk;bind h "wt2""
alias wt2 "-walk;bind h "wt1""

Things to keep in mind, this will automatically set h to this bind very time you launch GMod. This means if you set h to another function in game, it will reset when you close and relaunch. If you want to change the bind of you will have to remove this code from your autoexec.cfg

For those just interested in copying the code and changing the binds for crouching and walking, I will add both codes below.

bind h "wt1"

alias wt1 "+walk;bind h "wt2""
alias wt2 "-walk;bind h "wt1""

bind j "ct1"

alias ct1 "+duck;bind j "ct2""
alias ct2 "-duck;bind j "ct1""

 

Roleplay Application

For this example, I will be using the RST scenario of telling people to move away from the Sith Temple.

Using the same technique, we are able to chain together more then just two alias to create a "move away" with warnings which automatically chain through 1 - 3. For this code, we wall call out alias ma1, ma2, ma3

First we'll will select the key to bind, I will be using for this example. The first bind will set to ma1

bind l "ma1"

Next we set the alias's for ma1, ma2, ma3 using the same techniques for the crouch toggle

alias ma1 "/say me Signals to move away from the Sith Temple ...First Warning...;act forward;bind l "ma2""
alias ma2 "/say me Signals to move away from the Sith Temple ...Second Warning...;act forward;bind l "ma3""
alias ma3 "/say me Signals to move away from the Sith Temple ...Final Warning!...;act forward;bind l "ma1""

Finally, we want to reset back to ma1 should the person being  warned comply and move away. To do this we bind a new key to reset l. In this example I will be using p.

bind p "bind l "ma1""

You do not need to create an alias to reset back to ma1, because p is only used to reset, it does not change.

The final outcome should look as below.

bind l "ma1"

alias ma1 "/say me Signals to move away from the Sith Temple ...First Warning...;act forward;bind l "ma2""
alias ma2 "/say me Signals to move away from the Sith Temple ...Second Warning...;act forward;bind l "ma3""
alias ma3 "/say me Signals to move away from the Sith Temple ...Final Warning!...;act forward;bind l "ma1""

bind p "bind l "ma1""

Same with the first example, this will set the key to this every time you launch the game, and if you make permanent changes you must modify it through the autoexec.cfg file. You are able to make changes through the console, but they will reset on relaunching the game.

 

Conclusion

There are plenty of more applications to this feature. Whether you want to add some variation to your existing binds, toggle certain features in game, you can use this technique and modify to suite your individual needs and RP. Some of you, or many may already be using this method, but for those who may be new to GMod or a just not aware, this is how you can set up toggles in GMod

 

Regards,

Staticiser

Edited by Staticiser
  • Upvote 3

Share this post


Link to post
Share on other sites

If only we could put this somewhere on the forums so people don’t have to ask for us to make it our selves. Also welldone I will definitely be needing this since I’m going to come back soon on a new account, makes my life easier. Thank you.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this