Team Fortress 2

Team Fortress 2

143 ratings
TF2 Dedicated Server Setup Guide (Detailed)
By Knappy
A detailed guide on the process of setting up a Team Fortress 2 Dedicated Server. Will add more details soon.
2
   
Award
Favorite
Favorited
Unfavorite
Obtaining Server Files
This process is the same for all source engine games. If you already have the server files or have installed a SRCDS (SouRCe Dedicated Server) via SteamCMD before and know how to download server files, you can skip this.

Steam now uses SteamCMD (formerly HLDSUpdateTool) to download server files.

Download SteamCMD for your respective Operating System:
Windows
Linux

After you have downloaded SteamCMD, extract the steamcmd.exe to a folder on your server drive.

Note: In this guide the directory will be the root of the Hard Drive: E:\

Note: You can paste text to the CMD prompt:


Run the steamcmd.exe to install the tool's files, the dialog will appear installing files:


Note: Do not install server files within the SteamCMD folder.

While SteamCMD is downloading the tool, go ahead and setup your server directory. For the sake of this guide and ease of cd changes in the tool, I use the root of my drive: E:\TF2DS

You can make a folder anywhere except within the SteamCMD folder!

Once SteamCMD has completed downloading it's files, the dialog box will resemble:


Fun Time!

Team Fortress 2 Dedicated server does not require you to own the game in order to download the server files, so you can login anonymously in SteamCMD:
login anonymous


Should you choose to login with your Steam Account, you can do so by sending the following command:
login yourusername

If you are attempting to login from a remote computer, you will need to verify with the SteamGuard code which will be emailed to you. You will only need to do this once as SteamCMD will cache your credentials:[/h1]


Note: It is not required to login with your Steam account, this is just a reference for those who may intend on setting up future servers that do require a login (i.e. Contagion)
You may simply login anonymously to download TF2 Server files.

Assuming you have already created your server folder (E:\TF2DS) send the following:
force_install_dir E:\TF2DS ENTER app_update 232250 validate ENTER


Note: Use your server directory!

Note: Here is a list of all Steam Application ID's for reference to installing other server games.

This may take some time to download all the necessary files, when complete it will resemble:


Note: The appid in the above picture is from a HL2:DM server install, your SteamCMD should read 232250, I didn't want to re-download an entire server just for a screenshot...

When the download is complete and the command reads Steam> enter the quit command:
quit

This concludes obtaining the server files!
Port Forwarding
There are many resources out there for Port Forwarding. This guide is aimed at servers that are hosting on a provider or system other than the game client (also known as a Listen Server). If you are hosting your server on a game server provider, you don't need to worry about this as they will have already forwarded your ports.

Ports required for Steam

Port Foward[www.portforward.com]

Open Port Check Tool[www.canyouseeme.org]
TF2 Cvars
For a complete list of the Team Fortress 2 Cvar's see this

For a text file of all TF2 Cvar's see this[www.dropbox.com]
Server Configuration (server.cfg)
There are multiple resources out there to aid you in configuring your server.
TF2 Config Maker[tf2cfg.info]
Dodbits Cfg Maker[www.dodbits.com]

Core Server.Cfg Settings
hostname "Your_Servers_Name" //The Name of your Server that players will see sv_password "" //Leave empty if you do not want a password rcon_password "Your_Rcon_Password" //Password to enable rcon access from the console mp_timelimit 30 //Round Timelimit mp_maxrounds 10 //Maximum Rounds Playable before map change sv_allowupload 1 // Allow clients to upload customization files (Optional Line, Used for Sprays) sv_allowdownload 1 // Allow clients to download files (Optional Line, Used for Sprays) net_maxfilesize 15 // Maximum allowed file size for uploading in MB (Optional)

Example Server.cfg (Text Example Here[www.dropbox.com]):
// General Settings // // Hostname for server. hostname yourserver.com TF2 Server // Overrides the max players reported to prospective clients sv_visiblemaxplayers 24 // Maximum number of rounds to play before server changes maps mp_maxrounds 5 // Set to lock per-frame time elapse host_framerate 0 // Set the pause state of the server setpause 0 // Control where the client gets content from // 0 = anywhere, 1 = anywhere listed in white list, 2 = steam official content only sv_pure 0 // Is the server pausable sv_pausable 0 // Type of server 0=internet 1=lan sv_lan 0 // Collect CPU usage stats sv_stats 1 // Execute Banned Users // exec banned_user.cfg exec banned_ip.cfg writeid writeip // Contact & Region // // Contact email for server sysop sv_contact emailaddy@google.com // The region of the world to report this server in. // -1 is the world, 0 is USA east coast, 1 is USA west coast // 2 south america, 3 europe, 4 asia, 5 australia, 6 middle east, 7 africa sv_region 0 // Rcon Settings // // Password for rcon authentication rcon_password yourpw // Number of minutes to ban users who fail rcon authentication sv_rcon_banpenalty 1440 // Max number of times a user can fail rcon authentication before being banned sv_rcon_maxfailures 5 // Log Settings // // Enables logging to file, console, and udp < on | off >. log on // Log server information to only one file. sv_log_onefile 0 // Log server information in the log file. sv_logfile 1 // Log server bans in the server logs. sv_logbans 1 // Echo log information to the console. sv_logecho 1 // Rate Settings // // Frame rate limiter fps_max 600 // Min bandwidth rate allowed on server, 0 == unlimited sv_minrate 0 // Max bandwidth rate allowed on server, 0 == unlimited sv_maxrate 20000 // Minimum updates per second that the server will allow sv_minupdaterate 10 // Maximum updates per second that the server will allow sv_maxupdaterate 66 // Download Settings // // Allow clients to upload customizations files sv_allowupload 1 // Allow clients to download files sv_allowdownload 1 // Maximum allowed file size for uploading in MB net_maxfilesize 15 // Team Balancing // // Enable team balancing mp_autoteambalance 1 // Time after the teams become unbalanced to attempt to switch players. mp_autoteambalance_delay 60 // Time after the teams become unbalanced to print a balance warning mp_autoteambalance_warning_delay 30 // Teams are unbalanced when one team has this many more players than the other team. (0 disables check) mp_teams_unbalance_limit 1 // Round and Game Times // // Enable timers to wait between rounds. WARNING: Setting this to 0 has been known to cause a bug with setup times lasting 5:20 (5 minutes 20 seconds) on some servers! mp_enableroundwaittime 1 // Time after round win until round restarts mp_bonusroundtime 8 // If non-zero, the current round will restart in the specified number of seconds mp_restartround 0 //Enable sudden death mp_stalemate_enable 1 // Timelimit (in seconds) of the stalemate round. mp_stalemate_timelimit 300 // game time per map in minutes mp_timelimit 35 // Client CVARS // // Restricts spectator modes for dead players mp_forcecamera 0 // toggles whether the server allows spectator mode or not mp_allowspectators 1 // toggles footstep sounds mp_footsteps 1 // toggles game cheats sv_cheats 0 // After this many seconds without a message from a client, the client is dropped sv_timeout 900 // Maximum time a player is allowed to be idle (in minutes), made this and sv_timeout equal same time? mp_idlemaxtime 15 // Deals with idle players 1=send to spectator 2=kick mp_idledealmethod 2 // time (seconds) between decal sprays decalfrequency 30 // Communications // // enable voice communications sv_voiceenable 1 // Players can hear all other players, no team restrictions 0=off 1=on sv_alltalk 0 // amount of time players can chat after the game is over mp_chattime 10 // enable party mode // tf_birthday 1
Launching the Server
Now you can choose to launch your server via either the srcds.exe shortcut or .bat file. To use the srcds.exe you will need to create a shortcut of the .srcds.exe with launch parameters for your dedicated server with the required parameters.

See this for more information on Command Line Options


Using the srcds.exe Shortcut to Launch

Navigate to your dedicated server folder and locate the file called "srcds.exe" and right click on it, choose Create Shortcut, then right click on the created shortcut and choose Properties:




In the shortcut tab you should have a Target bar, leave a space first then add the following parameters:

-console -game tf2 -ip 192.168.1.3 +ip YOURDEDIIP +clientport 27005 +hostport 27015 +maxplayers 8 +exec server.cfg +map cp_dustbowl




Use an Auto-Restart.bat to Launch

This will launch your TF2 server and automatically restart it should it crash. Open notepad and copy the code below, using your IP and settings and save the file as "Start.bat"

:srcds echo (%time%) srcds started. start /wait srcds.exe -console -game tf2 -ip 192.168.1.3 +ip YOURDEDIIP +clientport 27005 +hostport 27015 +maxplayers 2 +exec server.cfg +map cp_dustbowl echo (%time%) WARNING: srcds closed or crashed, restarting. goto srcds

Note: Be sure to Save As with the .bat file extension!

Command Line Options


See this for more information on command line options.

Some other common command-line options for TF2 are:
+ip 1.2.3.4 - Bind to a specific IP. By default, listens on all network interfaces -port 27015 - Bind to a different port (27015 is the default) -strictportbind - If a server is already running on the specified port, stop the server from running +randommap - Use instead of +map to select a map at random +servercfgfile - Which tf\cfg\ file to execute on map change, defaults to server.cfg +mapcyclefile - Which tf\cfg\ file contains this server's mapcycle, defaults to mapcycle.txt. Will also look in tf\ -replay - Executes replay.cfg and adds an additonal slot for the replay bot, but removes it from the player count.

Steam Guardian

See this[pastebin.com]
SourceMod & MetaMod
Download the latest SourceMod and MetaMod Releases:
SourceMod[www.sourcemod.net]
MetaMod[www.sourcemm.net]

The Basics

For the love of all things...read the plugin author's release post. It will detail the config cvars and other necessary files you may need to include!

See the HL2:DM Plugins[www.sourcemod.net] that you can install on your server.
[/b]

Adding Admins
Edit the admins_simple.ini file, which is located in:
\addons\sourcemod\configs\admins_simple.ini


You can use your Steam Name, however keep in mind that anyone can change their name to yours and connect to your server with admin flags.

I suggest using your SteamID[steamidfinder.com]. You can type status in the console which will return all connected players SteamID's


//////////////////////////////// // Examples: (do not put // in front of real lines, as // means 'comment') // // "STEAM_0:1:16" "bce" //generic, kick, unban for this steam ID, no immunity // "!127.0.0.1" "99:z" //all permissions for this ip, immunity value is 99 // "BAILOPAN" "abc" "Gab3n" //name BAILOPAN, password "Gab3n": gets reservation, generic, kick // //////////////////////////////// "STEAM_1:1:16622384" "99:z"


That is MY SteamID for example purposes, just replace it with your ID.

After you edit that, just upload the addons & cfg folders to your server where the existing addons & cfg folders are. Failure to copy these files to te right location will result in SourceMod failing to load.


After you have uploaded the files, restart the server and send this command:
sm plugins list
If Unknown Command sm is returned, then the files were not installed properly:



Server Console

You've just installed sourcemod and made sure that it's working. For that you did the instructions in the Checking the Install chapter and issued some first commands in the server console.

Get more familiar with the console, either directly or preferably via rcon (e.g. by using HLSW).

Try at least these commands:
sm sm version sm plugins sm plugins list sm plugins reload 1 sm plugins refresh sm plugins unload funvotes sm plugins load funvotes sm exts list

/gamedata
If an extension or a plugin is using functionality provided by the game engine, e.g. Respawn a player or equipping a player with a weapon, sourcemod needs to know a few "facts" (to be precise: offsets and signatures) about the function. These can change after valve releases an update. At this point you don't need to know more about this, because sourcemod has an integrated updater, which automatically fetches the new gamedata files for you.

/logs
The holy grail of debugging your actions. Everything will be logged here. If someone asks you what the logfiles are saying or whether you get any errors: reproduce your problem, then take a look at the logfiles and just copy&paste the messages. Don't try to be smart here and post what you think the given errors are saying, just post the lines. Or fix the problem yourself if you understand the error.

/plugins
All plugins (.smx files) in this directory will be loaded automatically when sourcemod starts. Plugins will also be reloaded on mapchange if their file has changed.

/plugins/disabled
Plugins in this sub-folder won't be loaded. Move plugins from the parent directory to this one to disable a plugin and vice-a-versa. You will find some official alliedmods plugins in this directory you might want to install (e.g. rockthevote) and some others you want to disable by moving them here (e.g. funvotes).

/scripting
You can find the sourcecode to plugins in this directory, at least the original alliedmods ones. You don't need to place any files here to install a plugin, but it is highly recommended to not only install the smx files, but also their corresponding sp file.

/translations
Not much to say about this folder, it contains translations for many languages. Plugins are encouraged to provide translation files, so you might need to copy some files in here when installing a plugin.
Binding Commands
You will find it very convenient to bind sm_admin to a keyboard shortcut rather than type the command in console every time you wish to bring up the sm_admin menu

Binding commands in the console is the same for all cvar/console commands:

bind <KEY> <COMMAND>

sm_admin
bind i sm_admin

For commands/names with spaces and variables:

bind - "sm_givepoints Knappy 999"

Chat commands such as !buy, !repeatbuy, !machine, !mapvote, !drop etc etc are used in the following manner:

!BUY = SM_BUY

The ! replaces SM_ in the console so players can enter the command in chat rather than console. This however will quickly fill your chat box with !commands. Simply replace the ! with sm_ in the console.
Server Administration
Some basic console commands. You will more than likely use sm_admin (SourceMod) for your admin controls:

addip <minutes> <IP>
Bans a player by IP address for a specified number of minutes. Entering 0 for minutes is a permanent ban.

banid <minutes> <SteamID>
Bans a player by SteamID for a specified number of minutes. Entering 0 for minutes is a permanent ban.

banid <minutes> <SteamID>
kick Bans a player by SteamID for a specified number of minutes and kicks them from the server. Entering 0 for minutes is a permanent ban.

changelevel <map>
Changes the server to the specified map. For a full list of maps, type: maps * in the console.

dropclient <UserID>
Kicks a client by their UserID. To find a full list of UserID’s on the server, type: users in the console.

heartbeat
Manually sends a heartbeat to the master server.

info <SteamID>
Displays user information about the requested client based on SteamID.

kick <Player> or <UserID>
Kicks a user by Player name, or UserID. To find a full list of UserID’s on the server, type: users in the console.

listid
Lists all SteamIDs in your server ban list.

listip
Lists all IP addresses in your server ban list.

maps <partial name>
Lists all maps containing a partial name, for example: maps de_ would list all maps with de_ in their name.
71 Comments
Moeles 2 Apr @ 7:07am 
ПОЖАЛУЙСТА
Moeles 2 Apr @ 7:07am 
ДЛЯ ТИМ ФОРТРЕСА
Moeles 2 Apr @ 7:06am 
СЕРВЕР
Moeles 2 Apr @ 7:06am 
Помогите пожалуйста
Moeles 2 Apr @ 7:06am 
Сервер для тим фортреса
Glorified Toaster with Legs 30 Aug, 2024 @ 4:40pm 
so i got pretty annoyed with those [SM] toggle XXXXXX any help on disabling them?
techno 16 Aug, 2024 @ 2:38am 
How do I host it on a loopback address? Cheers
esyal 12 Aug, 2024 @ 1:10pm 
me too
the fall guy 19 Feb, 2024 @ 6:03am 
i'm an idiot
iceman_twitch 22 Jan, 2024 @ 4:35am 
the game just dont work. keep saying out of memory. Not even used 100 MB. What is going on? SRCDS?