Garry's Mod
คะแนนไม่เพียงพอ
The Ultimate Toggle Config: Toggle Sprint, Crouch, Walk, and Leaning
โดย Shampooh
Use fancy pants alias binds to toggle sprinting, crouching, and more with behavior matching modern shooters' controls.
   
รางวัล
ชื่นชอบ
ชื่นชอบแล้ว
เลิกชื่นชอบ
Demonstration
Intro
Toggling crouch is nothing new, but I haven't seen anyone share a good config for a toggled sprint that behaves like most people would be used to. The main stickler is that the sprint should be toggled off if you stop moving and then start again; this is a bit difficult to perfectly recreate, but by having sprint immediately toggled off when a movement key is pressed, I've pretty much accomplished it. And then some. No, I have no mental conditions, why do you ask?

These binds (in their relevant permutations):
  • Stop sprinting when the forward or backward buttons are released
  • Transition straight from one state to another without keeping the old button held down, for example you can transition straight for walking or crouching to sprinting, and will remain standing or running when you stop sprinting
  • Sprint key is released when right clicking, to prevent being stuck in a "hold breath" state on relevant weapons; to disable this if it interferes with anything else for some reason, remove the line beginning with "bind mouse 2"
  • Stop sprinting when leaning and vice versa

Notable caveats:
  • If you die with a button "held", you're gonna spawn accordingly unless you press another button that "releases" it; this shouldn't be a problem with sprinting which is stopped by movement keys, but may be a small pain for walking and crouching
  • Starting a sprint while strafing, stopping, and then starting again with no other inputs will resume sprinting; no way around this so long as I allow strafe movement while sprinting, and ♥♥♥♥ any game that doesn't allow it
  • In order to facilitate sliding mods, sprint state is kept active when going to a crouch; to change that, simply add "; sprintOff; -speed" to the end of the first "alias crouchOn" line
  • If you try to start sprinting while still aiming (holding mouse2), your sprint will be interrupted when mouse2 is released. If that's frustrating enough, and you can't get over the fact that you're pushing buttons in the wrong order, remove the line beginning with "bind mouse2"
  • Because datae's "Simple Leaning" which this is built for does not have any accountance for pressing one lean button while another is already held, pressing one lean button while the other is toggled will simply do nothing rather than toggling anything; in fact, the other lean button is completely unbound while one is active to ensure states don't get mixed up, preventing messy situations where a button seems unresponsive because it was already held down despite doing nothing

Use the following as console commands to try them out, and save as a config file/add to autoconfig if you like it. Note that I have crouch bound to C, you may of course want to change that and any of the other binds to control ("ctrl") or whatever else you want. Maybe you use IJKL like a freak, I dunno.
Full Config
This is designed for datae's Simple Leaning; if you use a different leaning mod, replace "leanleft" and "leanright" with your relevant commands and it should maybe probably just work.

alias crouchOn "+duck; alias toggleCrouch crouchOff" alias crouchOff "-duck; alias toggleCrouch crouchOn" crouchOff bind "c" toggleCrouch alias sprintOn "+speed; alias toggleSprint sprintOff; walkOff; -walk; crouchOff; -duck; alias toggleRight rightOn; alias toggleLeft leftOn; -leanright; -leanleft; bind e toggleRight; bind q toggleLeft" alias sprintOff "-speed; alias toggleSprint sprintOn" sprintOff bind "shift" toggleSprint alias walkOn "+walk; alias toggleWalk walkOff; sprintOff; -speed" alias walkOff "-walk; alias toggleWalk walkOn" walkOff bind "alt" toggleWalk alias sprintForward "-speed; sprintOff" bind "mouse2" "+attack2; sprintForward" bind "w" "+forward; sprintForward" bind "s" "+back; sprintForward" alias rightOn "+leanright; alias toggleRight rightOff; unbind q; -speed; sprintOff" alias rightOff "-leanright; alias toggleRight rightOn; bind q toggleLeft" rightOff bind "e" toggleRight alias leftOn "+leanleft; alias toggleLeft leftOff; unbind e; -speed; sprintOff" alias leftOff "-leanleft; alias toggleLeft leftOn; bind e toggleRight" leftOff bind "q" toggleLeft
No Leaning Config
Take your tactical shooter without lean? Or just prefer holding buttons? Here's the same config with all the leaning-related behavior removed. This is also what you'd use in other Source games, if you want to give this a whirl in Half Life or something.

alias crouchOn "+duck; alias toggleCrouch crouchOff" alias crouchOff "-duck; alias toggleCrouch crouchOn" crouchOff bind "c" toggleCrouch alias sprintOn "+speed; alias toggleSprint sprintOff; walkOff; -walk; crouchOff; -duck" alias sprintOff "-speed; alias toggleSprint sprintOn" sprintOff bind "shift" toggleSprint alias walkOn "+walk; alias toggleWalk walkOff; sprintOff; -speed" alias walkOff "-walk; alias toggleWalk walkOn" walkOff bind "alt" toggleWalk alias sprintForward "-speed; sprintOff" bind "mouse2" "+attack2; sprintForward" bind "w" "+forward; sprintForward" bind "s" "+back; sprintForward"