Install and Configure a Source Dedicated Server
WARNING: This is outdated. There is a new method that should be used, explained on the Valve Developer Wiki SteamCMD page.
Author: Doktor haus
Installation
Start off by downloading the Half-Life Dedicated Server Update Tool. Click the blue "from the Valve webserver" link on that page to download it. Run the application and go through the installation process. I recommend keeping the default installation directory, and when you reach the region page, choose your region. If you're in the Eastern United States for example, choose US east coast.
Now, create a new text document. You can paste this information inside:
"C:\Program Files (x86)\Valve\HLServer\HldsUpdateTool" -command update -game "left4dead2" -dir "c:\srcds" -verify_all -retry
pause
The first quoted text is the file path to the HLDSUpdateTool you just installed. The second quoted text is going to be the directory for your new Source Dedicated Server installation. With the -game paramater, instead of left4dead2 you can choose to update other games. Some of the more popular games are:
cstrike (Counter-Strike: Source)
tf (Team Fortress 2)
garrysmod (Garry's Mod)
"Pause" is on its own line so that command prompt doesn't disappear automatically.
Choose file > save as... and under the file type, select "all types". Name it whatever you want, just make sure there's a ".bat" at the end. You should see a new .bat (batch) file now.
Double-click it to start downloading your server files to c:\srcds. This will take a very long time for most people, as you're essentially downloading a second copy of the game. When it's done, you'll see 99%, 100%, then "installation up to date".
Once it's finished, open c:\srcds and you'll see a lot of new stuff there. In the case of L4D2, go into the left4dead2 folder and make a shortcut to srcds.exe. Right-click the new shortcut, choose properties and you can paste this into the target field.
C:\srcds\left4dead2\srcds.exe -console -game left4dead2 -hostport 27015 -clientport 27016 -insecure +map c2m1_highway +exec sm.cfg
Once again, "-game" tells the server which game to run. "+map MapName_Here" will start the server on that specified map. "+exec sm.cfg" is not necessary, but it runs the configuration file sm.cfg after each map is loaded.
Now, whenever you want to run your server, double-click that shortcut. A command prompt window will appear, and yes, this is your entire server interface. A lot of text will scroll by, and when you see "VAC secure mode" enabled or disabled, that's how you know the map is fully loaded.
Configuration
You probably want to configure your server, so navigate to srcds/left4dead2/left4dead2/cfg. You should see server.cfg. You can edit this with most text editors (preferably Notepad++ ) to configure your server. I'll just go over some basic things here. Remember that anything with "//" before is a comment and will be ignored.
// Information
hostname "The Reptile House" // What name your server should use.
motdfile "motdtrh.txt" // Makes your server use a custom message of the day and banner file.
hostfile "hosttrh.txt" // The default ones tend to get overwritten when updating, so this is a good idea.
sv_lan 0
sv_region 0
rcon_password "password" // In game, you can type "rcon_password password" in the console to access your server console from in-game.
// These settings make your server private and allow you to start a game regularly from the main menu.
sv_steamgroup "123456" // Very important! See this
sv_steamgroup_exclusive 0
sv_allow_lobby_connect_only 0
// Preferences
sv_gametypes "coop,realism,survival,versus,scavenge" // The gametypes that can be played on your server.
maxplayers "8"
sv_maxplayers "8"
sv_visiblemaxplayers "-1"
sv_removehumanlimit "1"
sv_force_unreserved "1"
sv_alltalk 1
// These settings make sure players can use their mods.
sv_pure 0
sv_purekickclients_0
sv_consistency 0
// Disable autokick - These settings will prevent players from being kicked for being idle.
mp_disable_autokick 1
sm_cvar director_afk_timeout 9999999
sm_cvar mp_allowspectators 1
sv_spectatoridletime 999999999
// Performance
setmaster add 188.40.40.201:27011
setmaster add 68.142.72.250:27011
setmaster add 72.165.61.151:27013
setmaster add 72.165.61.189:27011
sv_forcepreload 1 // Forces components to preload before player is in-game, helping with stuttering and slowdowns.
heartbeat // Should make your server appear in the list faster. In theory, at least.
Playing
With this configuration, you should be able to start a game from L4D2's main menu. Click "play campaign". From here, you can choose "Steam group server" to join the game in-progress. If you want to start a lobby however, choose play with friends > create new campaign lobby. Under the server type, make sure it's "steam group server". Start the lobby and you should be able to invite friends, change the level and whatever else. If you've set sv_steamgroup up like I explained earlier, when you start the game you should connect to your new server.