Home > Games > Team Fortress 2 – Dedicated Server

Team Fortress 2 – Dedicated Server

October 18th, 2007 Leave a comment Go to comments

Ok, in this short tutorial I will show you how to set up a TF2 dedicated server on a windows machine.

  1. Download the HLDS Update Tool from the Steam site.
  2. Run the tool to get it installed.
  3. Create a directory for steam, the game files will be created in this directory.
  4. Run the hldsupdatetool executable: (I ran a windows installation, but linux will be similar)

    Windows command:

        -command update 
        -game tf 
        -dir <directory name created in step 3, surround with quotes if spaces are in it>

    Linux command:

        -command update 
        -game tf 
        -dir <directory name created in step 3, surround with quotes if spaces are in it>

    You can use the same command when you need to update your server to the latest version.

  5. This will take some time, grab a beer, a cup of coffee, or something else that will help you relax.
  6. Don’t relax too much! You might get some ‘Connection reset by peer’ exceptions. Don’t worry, just rerun the same command again and again and again and again until finally you have received all files.
  7. Create a server.cfg file in the orangebox/tf/cfg directory.
  8. Fill it with some basic info. See a small example below.
  9. // The name of your server shown in the server browser
    hostname "TF2 Server"
    // Server e-mail contact
    sv_contact youremail@here.com
    // Password used for remote console access
    rcon_password "asillypassword"
    // If you are having trouble connecting with rcon try enabling the rcon_address line.
    // Also make sure your ports are forwarded (tcp: 27000-27020)
    // rcon_address "your_ip_address"
    // 1 for private LAN, 0 for internet play
    sv_lan 1
    // Region that the server is located in
    // U.S. East - sv_region 0
    // U.S. West - sv_region 1
    // South America - sv_region 2
    // Europe - sv_region 3
    // Asia - sv_region 4
    // Australia - sv_region 5
    // Middle East - sv_region 6
    // Africa - sv_region 7
    // Rest of the World - sv_region 255
    sv_region 3
    // Network settings
    sv_mincmdrate 30
    sv_minupdaterate 20
    sv_maxcmdrate 100
    sv_maxupdaterate 100
    sv_maxrate 100000
    sv_minrate 1000
    //sv_unlag 1 Unknown Command
    // Enforces fair and optimal settings
    sv_client_predict 1
    sv_client_interpolate 1
    sv_client_min_interp_ratio 1.0
    sv_client_max_interp_ratio 2.0
    sv_client_cmdrate_difference 30
    // External download server
    // sv_downloadurl "http://yoursite.com/cstrike"
    // Max download size of 100 MB
    net_maxfilesize 100
    // mp_capstyle (Sets the style of capture points used. 0 = Fixed players required to cap. 1 = More players cap faster, but longer cap times)
    // mp_respawnwavetime (Time between respawn waves)
    // mp_capdeteriorate_time 90.0 (Time it takes for a full capture point to deteriorate)
    // mp_teams_unbalance_limit (Teams are unbalanced when one team has this many more players than the other team. (0 disables check))
    // mp_bonusroundtime (Time after round win until round restarts)
    // mp_winlimit (Max number of rounds one team can win before server changes maps)
    // mp_stalemate_timelimit (Timelimit (in seconds) of the stalemate round.)
    // mp_switchteams (Switch teams and restart the game)
    // mp_scrambleteams (Scramble the teams and restart the game)
    // mp_forcerespawnplayers (Force all players to respawn.)
    // mp_disable_respawn_times (Disable respawn timer)
    // mp_timelimit (Set timelimit for map)
    // mp_maxrounds (Set number of rounds before reset. Mutually exclusive with mp_timelimit. So if this is enabled disable the mp_timelimit)
    // mp_tournament (Enable or Disable tournament mode)
    // tf_weapon_criticals (Enable or disable weapon crits)
    // tf_flag_caps_per_round (Number of flag caps before round ends)
  10. Create a shortcut to the srcds.exe executable in the /orangebox directory
  11. Edit the shortcut and change the startup command to look like something like this
  12. "C:\Program Files\Valve\HLServer\orangebox\srcds.exe" -game tf -console +exec server.cfg +maxplayers 24 +map ctf_2fort

    This will make the server run the TF2 game, with console enabled and it will execute the server.cfg file we created. Next to that it will set the player limit to 24 and load the map ctf_2fort at startup.

  13. Start the server by running the shortcut

Please note that you can also create custom map cfg files which will run automatically when a mapchange occurs. Eg: If you have the map cp_dustbowl you could create a custom cp_dustbowl.cfg file and place it in the cfg directory and it will be auto-executed when the level is loaded. This will enable you to use settings that are map specific.

The next part in this tutorial will describe how to install MetaMod:Source and SourceMod on your (TF2) dedicated server.

MetaMod and SourceMod are plugin API’s/frameworks that will allow you to run custom administration/game plugins on your server.
Visit this link to see what mods are available for SourceMod.

  1. Visit this page and follow the directives there. Be sure to download the a version >= 1.6 of MetaMod:Source.
  2. Go to the SourceMod site and download the latest release. Then follow the directives found here.

If you got SourceMod running you can install any plugins you like. Have fun!

  1. gianakhs
    June 6th, 2009 at 18:53 | #1

    I have a dynamic ip is it a posibility of connecting without paying for a static because in my isp it costs about 20 euros ebery month 🙁

  2. June 6th, 2009 at 19:42 | #2

    You need something like DynDNS which will allow you to have a dns name which will follow your ip through an update mechanism.

    You can register several names for free. You might be interested in something like:
    gianakhs.game-host.org or gianakhs.game-server.cc or something like that.

    Have a look at http://www.dyndns.com/services/dns/dyndns/ for more information.

  3. gianakhs
    June 6th, 2009 at 23:29 | #3

    I did all the tutorial forwarded my ports 27000-27020 tcp/udb and i made a hostname and also I installed an update client but with sv_lan=1 i can connect with sv_lan=0 i cannot connect neither from lan nor from internet.
    Any suggestions?

  4. gianakhs
    June 7th, 2009 at 14:55 | #4

    I finaly made it! thx to your awesome tutorial and your quick help.Thank you a lot!!

  5. RokkerXD
    July 2nd, 2009 at 01:39 | #5

    Well, I installed the HLDS Update tool, but I don’t get the rest.

    Once I also updated it to “version 35” it went fast, but do I put the commands when I open the HLDSupdatetool again? Or is it else where?

  6. Wytze
    July 2nd, 2009 at 08:17 | #6

    What commands are you referring to? The HLDS Update Tool is only used for installing/updating the files on your machine. The tool will install the necessary game files and the binaries required to run the server. On windows this will be srcds.exe. You will have to add the parameters by starting the executable from the command line or you can make a shortcut and add the parameters there. You could even make a batch file and fill it with the path of the srcds.exe executable and the required parameters. Something like:
    start “c:\Program Files\SRCDS\srcds.exe” +exec server.cfg …etc
    for example.

  7. phudabulah
    July 14th, 2009 at 20:42 | #7

    Cool, can’t wait to try this

  8. Tf2 server
    July 26th, 2009 at 02:00 | #8

    Hi I cant get past step 4. Where do you want me to put the ./steam command???

  9. Wytze
    July 26th, 2009 at 16:30 | #9

    You have to run it in the directory where the hldsupdatetool.bin extracted the files.
    Or you can give in the full path like /home/wytze/steam to run it.

  10. bmd
    August 31st, 2009 at 19:52 | #10

    Wytze you said “Have you tried adding/connecting the server with your internet-ip?
    According to your image everything is working fine. So it is strange it doesn’t show in the list. I don’t know if icmp requests need to be enabled on the server so it might show up on the list. It is something I will have a look at.”

    how do you add your server through ip or whatever, i seem to be having the same problem as inf. cheers and plz respond! :]

  11. Wytze
    September 1st, 2009 at 22:21 | #11

    You will first need to retrieve your internet ip. (Use something like whatismyip.com)

    You can then add the server by using the “Servers” screen in your steam account. After adding it and you configured your server and firewall/port forwarding ok it should show. You should be able to connect.

    You could also try to use the connect command in the developer console. You need to enable this in the tf2 settings menu within the game. (settings->advanced->developer console) Once enabled you can press the ~ key to bring up the console. Type connect ‘serverip’ to check if the connection to your server is working ok.

    Note: Remember that a server will never display directly in the server list as it might take some time to send the heartbeat signal to the master server. A heartbeat signal is sent once every five minutes to let the master server know that the server is still up and running.

  12. rip
    October 15th, 2009 at 11:24 | #12

    i got a question ,, i want to create a lan game on a small network but i dont got steam …how can other players from the network connect ? pls answer , i need steam to see a god damn lan server?

  13. October 15th, 2009 at 11:58 | #13

    If you know the ip and port the easiest way is to enable the console, press ~ and type connect <ip>:<port>.

  14. rip
    October 15th, 2009 at 17:17 | #14

    sorry .. the console doesnt work .. how do i fix this ?

  15. rip
    October 15th, 2009 at 19:52 | #15

    I fixed the console, now the lan works , but when somebody try to connect to me my game is shuting down and gives me a windows error , why ?

  16. October 21st, 2009 at 09:52 | #16

    Hard to say without any error report I guess. Make sure all your software is up-to-date and install some stable drivers is the best advice I can give at this point.

  17. March 22nd, 2010 at 18:40 | #17

    I always heard about problems with the steam account. Some account get even hijacked? Do you still think it is wise to get a steam account, I am usually to lazy to get a game in a store, so I would prefere to download them. Or are there any other options.

  18. hl2.exe
    January 10th, 2011 at 18:50 | #18

    Hi all. I’ve a problem: while i was setting the dedicated server I , as suggested by the tutorial, set sv_lan to 0(which means internet game) to let other people to join. But if i write in the console sv_lan it says that it is set to 0 but the server is a lan server.

Comment pages
1 2 24
  1. No trackbacks yet.

Time limit is exhausted. Please reload CAPTCHA.