Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

Complete Guide for Creating Custom Commands

A Tutorial for Half-Life 2

No ads for members. Membership is 100% free. Sign up!

Updates

menu
hotfix 17d
  • BugFix fixed typos in the code blocks
  • BugFix fixed the last section

Rundown of everything.

1. Introduction

Welcome to the complete guide for creating custom commands in Source Engine.
This tutorial will completely cover the use of the alias command.

2. The Basics

2.1. Structure

alias customcommandname "command ; command ; command"
You put your custom command name instead of customcommandname and use the cvars you need instead of command,while separating them with a ; .

2.2. Uses

Creating timed screenshots,quickly changing lots of cvars,binds and much much more. This thing is overall the magic fix for bind like quick grenade.because it requires execution of many commands at once. Everyone who wrote scripts for HL2 can't deny it's one of the most useful commands there.

2.3.  The rules

Let's quickly give you a rundown of what is possible and what is not.

Impossible
alias command 0 "command ; command"
This will result in the engine interpreting the 0 as the command you're trying to execute.
alias command "alias command2 "command ; command""
This will utterly break the engine as it can't  comprehed double and onwards "

Possible
alias command_bluh "command ; command"
This will be interpreted by the engine just fine - this is replacing the spaces in the commands.

From the previous sentence you probably figured a way to create 0 and 1 commands.
alias command_0 "command ; command"
alias command_1 "command ; command"
This will be interpeted completely correctly by the engine.

3. Fancy Techniques

3.1. "Hold Commands"

Interesting mechanic. The movement is realised with it.

Let's break it down:
W - +forward
But how does it stops when you're not pressing W? Simple - there is a -forward command. The engine will assing + &- to eachother if the command names are the same.
So to use it simply create a +command and -command and bind them to a key afterwards. The game will do the other work for you,just press the assigned key.

3.2. Double Alias Workaround

So there is somewhat a workaround for double aliases. What you need to do is simple - just create another .cfg file with alias in it and include the exec 2alias.cfg command into the alias.
alias command "command ; exec 2alias.cfg ; command"

4. Final Words

Thanks for joining me on this little journey. Hope you understood it all - please give it a like if you enjoyed it and consider subscribing for more content!
Sign up to access this!

No comments yet

Embed

menu
Share banner
Image URL
HTML embed code
BB embed code
Markdown embed code

Announcement

Credits

Key Authors
kizuati
Everything

Submitter

kizuati avatar
kizuati username pic Joined 2mo ago
Sleeping
271 points Ranked 52133rd
10 medals 2 rare
  • 10 submissions featured Medal icon
  • Returned 1000 times Medal icon
  • Submission featured Medal icon
  • Returned 100 times Medal icon
  • Became a Studio Leader Medal icon
  • Received thanks 5 times Medal icon
kizuati avatar
kizuati

Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

Details

Difficulty Level
Intermediate

Attributes

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • 1
  • 171
  • 18d
  • 17d
  • 17d

More from Submitter

menu

WiPs by Submitter

menu

More Scripting Tutorials