Half-Life 2: Deathmatch

Half-Life 2: Deathmatch

Not enough ratings
Source Engine console useage for the creation and destruction of entities.
By Kittos Creator
This guide will teach you how to enable, and use the Source Engine console, for the usage on "cheat servers". I will attempt to describe how to create, use and destroy enities. Nothing on this guide will be "usable", so dont bother looking for free code here.
   
Award
Favorite
Favorited
Unfavorite
The Source Engine developer console
The Source Engine developer console is a powerfull debug and configuration tool. This console (Refered to as the cosnole in this guide) allows for many cvars( Console Variables) to be set and commands to be used.

By defualt, it is disabled. However, in the "Keyboard Options" section of the options menu. Accessed in the main menu, there is a button that reads "Advanced Options". Press it and a box should appear with 2 options, tick the "Enable Developer Console" options, and close the menu.

On a standard "QWERTY" Keyboard, the button to access the console is the "tilde" or `/~ button, to the left of the 1 key. However, should your keyboard not have this button, or it is broken, you can manualy force the console open in a different way.

Opening the console without the ~ key:
Navigate to your steam install directory (Such as C:/Program Files/Steam/) And navigate to "Steamapps/Common/Half-Life 2 Deathmatch/hl2mp/cfg", open the file titled "autoexec.cfg" in a text editor. If it does not exist, create one. However, take note that the extension should always be .cfg

Inside, you may create a new bind. The command is litteraly "bind", with the syntax: bind <Key> <Action>, Set up a bind with the command "toggleconsole", such as: "bind x toggleconsole". This should allow you to open the console with 'x' if ~ is not applicable for you.
Configuration files and "exec"
Configuration files (.cfg), in the context of the Source Engine, are text-based batchs of console commands that are executed at will. This segment of the guide will teach you about creating and using these files.

To create a config file, navigate to your steam directory. Then from there, navigate to: "steamapps/Common/Half-Life 2 Deathmatch/hl2mp/cfg/". Create( Or copy ) a new configuration file and open it in a text editor. Clear out any text that already exists. This file should be named in such a way that there are no " " ( spacebar character ) in its name. Use _ (underscore) in place of spacebar if needed.

Within this file, you may place various commands. In this case, we will look at "echo". Create 5 or so lines of the command echo, with some random message to yourself ingame. such as: echo "Hello world"

Load up HL2DM, open the console and type "exec <yourcfghere>", you should see 5 or so lines appear with your message. Congratulations, you have created your first "command batch", this is known as "scripting" to the rather small community that does it
Entity manipulation
If you are reading this part, you should be able to create a config file. In this section, we will look at using the command console to manipulate entities. Be warned, sv_cheats should be enabled. And I recommend testing on a "singeplayer" game. Simply use the create server button and when the map loads, open the console and type "sv_cheats 1".

Lets look at the 2 major commands in this field: ent_create, and ent_fire.

ent_create: Is capable of creating entities.
ent_fire: Can "fire" entity I/O (Input and Output)

In this case, We will choose a nice easy, but visible, entity to create and manipulate. Lets try env_citadel_energy_core

Create a new config file. And add an ent_create line. ent_create's paramiters are as followed: ent_create <entity>. Now directly underneath it, we will add an ent_fire line. Since we have not yet named this entity, it is best that we look towards naming it first. the ent_fire command should "target" the exact entity name you have just created, so: ent_fire env_citadel_energy_core. We want to set a keyvalue, so the input "addoutput" should be used. addoutput accepts a string( any amount of text ), that is "<key> <value>", so we want to set the key "targetname" (The entities name) to something else.

You should have something along the lines of:
"ent_fire env_citadel_energy_core addoutput "targetname energycore"
Now we want to set its classname, to help prevent any anyone from accedently "stealing" it.
classname is the key, set its value to energycore (Or whatever) as well.

From here, there is only one more Keyvalue to set, in this case, the effects scale, known as "scale", set it to any non-zero positive number.
Now, the final step, add an ent_fire to fire the input "startdischarge", save the cfg, and open hl2dm.
load up a map, and set sv_cheats to 1. Then finaly, exec your new cfg.
You should see a nice pretty energy core infront of you, if you did not, try reading the tutorial again and try to fix your "script".
Cheat servers
Cheat servers are dedicated to allowing people to use these "cfgs", but be careful who you interact with, and always be polite. They usualy run on "gm_flatgrass" or other variations. I will slowly compile a list here:


gottz.de - GZ_Cheats 1. Owned by GottZ
Conclusion
This guide will get you on the way to source engine scripting. The Valve wiki, and hammer, are both exellent resources on entities and thier keyvalues. However, I will warn you that people dont take too kindly to "script sharers". That is, when one persons script is distributed to other people. Or where you "trade" scripts. Be carefull of some of the commands in the source engine, some of them have some pretty bad effects. And be carefull of who you ask, and how you ask for help.

Good luck!
4 Comments
iNVERTED 22 Apr, 2018 @ 7:01am 
I am having some trouble with a code, I'm trying to make a turret explode upon deploying its weapons. It will spawn, but not explode on deploying. Here's the code

ent_create npc_portal_turret_floor
ent_fire "npc_portal_turret_floor addoutput "targetname explodeturret"
ent_fire "npc_portal_turret_floor addoutput "OnDeploy npc_portal_turret_floor:SelfDestruct:1:0:0"
GσттZ 9 May, 2015 @ 2:42am 
small update about gz_cheats: it will be available again this month. for updates just take a look at gottz.de
GσттZ 22 Apr, 2015 @ 6:00am 
its GottZ not Gottz dang it.. xD
by the way.. starting tomorrow 5.104.107.234 will be gone. i will continue hosting the gameserver on a different host / ip. you can connect to it by simply typing this into your console: connect gottz.de
xBio 14 Sep, 2014 @ 4:33pm 
good tut creator :D