# How to setup a dedicated TF2 Server and install mods.



## Nipun (Jan 21, 2012)

Hello people!

I just wanted to show you how to setup a dedicated tf2 server, configure it as you like and install mods too.

*Downloading and installing:*
Download this dedicated server file:
*www.steampowered.com/download/hldsupdatetool.exe

This file will be used to update and install the server.
Save the file to an easy to access location, like C:\Server or D:\TF2\ .

Now you need to download the files that will make the server run(what you currently have is an installer, not files). To do this, in Win7/Vista open install directory(C:\Server) and press Shift + Right mouse button. Select "Open command window here" from the menu. A command window will pop up. Type the following in command prompt:

```
hldsupdatetool -command update -game tf -dir c:\Server
```

Change c:\Server with whatever directory you want the installation to be in.

If you are in WinXP, just type the following in notepad, save it as .bat and execute it:

```
c:\Server\hldsupdatetool -command update -game tf -dir c:\Server
```

It will start installing the server, but will also show you the following:
"No installation found in C:\Server"
Just ignore it, as its not an error but an information for you to tell you "You told me to update, but there isn't any installation. Wait, I will download all missing files". 

In a few minutes the download will start and it will display you the percentage completed. The download is about 4GB and installer may exit randomly for no reason. Just launch it again and it will continue. Once you have all the files, you need to configure the server.

*Customizing/Configuring Server*
There is no default server configuration file and you will need to make one. To do this, open notepad and copy following in it(Dont forget to edit it as you want to):


Spoiler






> // Server Name
> hostname "Team Fortress 2"
> 
> // Rcon Cvars
> ...






The main things you need to change in above configuration are:
-hostname -This is the server's name displayed to everyone who connects to it. Plce the name in inverted commas(" ").
-sv_password -Use it if you want to enable a password on your server. Only people who enter password can play on your server.
-sv_lan -Is set to 1, only the people on your LAN will be able to play on server.

You can edit other variables[aka cvar] too, but you dont need to do that right now. You can do that once you get server running.

Save it as server.cfg in C:\Server\Orangebox\tf\cfg\ . Remember, save it as .cfg not .txt!

*Launching the server.*

There are 2 ways to run the server. First is to run from .bat file:


```
c:\server\orangebox\srcds.exe -console -game tf -hostport 27015 +maxplayers 24 +map cp_dustbowl
```

The other way is to create shortcut of srcds.exe in orangebox folder. After making shortcut, go to its properties and add following after destination path:

```
-console -game tf -hostport 27015 +maxplayers 24 +map cp_dustbowl
```

Just run these files whenever you need to run the server.
In above codes, -game tells what game to run(tf means team fortress 2), hostport is the port to use, +maxplayers is number of players allowed on server and +map is the map to start with.

Incase you see something like:
"27005 port unavailable, bound to 277002"-or something similar, you need to open ports on your router. Doing this on most routers is easy, go to your router page(192.168.1.1) and enter password. Go to Access Management >> NAT >> Virtual Server. There, open the ports from 27005 to 27021. Make a google search to see how to open ports on your router.
If you have already opened the ports and are still getting error, most probably server or the game is already running and using one of the port. Close the game and restart server.

To connect to your own server, start TF2 and go to browse server. Then from LAN tab, select your server and click connect! Call your friends to join to make sure it works on internet too.

*Giving commands while server is running & Some more customization.*

When the server is running, any changes made in server.cfg will not take effect unless server is restarted. *To change cvars* or give other commands without turning server off, go to server console and type the name of cvar with value to change it. For example, if you want to enable cheats on your server, type:
sv_cheats 1
or to change map
changelevel plr_hightower

You can change anything from the console, and can also kick/ban players using kick/ban commands (kick <username>).
Note that any changes made from console will not be saved in server.cfg!

If you want to* enable instant respawn* on the server, just add this variable to server.cfg:
mp_disable_respawn_times 1

Now if you want to *change the map cycle* on your server or want just one map to run all the time, this can be done by editing mapcycle.txt in \orangebox\tf\
Just enter the name of maps you want to run in cycle and save. An example is this:



Spoiler





```
cp_mountainlab
pl_upward
koth_nucleus
ctf_2fort
cp_degrootkeep
```




You may also want to *edit the welcome page* shown to players. This can be done by editing motd.txt in \orangebox\tf\ .
Just type in what you want to display to users and exact text file will be shown on welcome page.

*Updating Server*

If a new TF2 update has been released, you will need to update your server too, otherwise players won't be allowed to join your server. To update the server, you just need to run the update command we used above to install server and it will update. Everything else will go same as installing of server, except the file size 

*SourceMod*
SourceMod is a very useful plugin for a tf2 server. It allows you to specify admins, and make decisions directly from the game. You can also install many useful mods if you have this plugin installed. Some of the great features I like are:

changing cvars directly from the game.
kicking/muting/banning players directly.
Show messages to users in center, top or bottom of screen(useful for ads).
Call votes from game.
Change map rotation/map cycle from game.

There are many more useful functions of SourceMod, you can find them on their site: SourceMod: Half-Life 2 Scripting

*Installing SourceMod*
Installing SourceMod is really very very easy. Just download the following files before starting:
Metamod:Source - News MetaMod, Download link is in top left.
SourceMod Downloads SourceMod
Metamod:Source - Make a VDF File VDF File, to make MetaMod run. Select TF2 as game and click generate.

Unzip contents of MetaMod to \orangebox\tf\ . After successful extraction you will see an Addon folder there.
Copy the vdf file you generated from above link to this addon folder.
Unzip contents of SourceMod to\orangebox\tf\ . You will see a message asking to overwrite. Select yes, as only folder is common and not the files.

Restart the server and type following in console:
meta version
sm version

If in any of commands console says "Unknown command", then mods aren't installed properly. Try following detailed guide here: Installing SourceMod - AlliedModders Wiki

*Defining Admins*
Admins in sourcemod can have different functions. Suppose there are 2 admins, A & B. You can allow A to kick and ban players while you can grant B the permissions to reserve a slot and change maps! To give these, SourceMod uses 'flags'. The full list of flags can be found here: *wiki.alliedmods.net/Adding_Admins_(SourceMod)

To grant permissions to admind, open \tf\addons\sourcemod\configs\admin_simple.ini . The information about usage is given there, but it can be confusing sometimes. Here's what you need to do first time(you can figure out advanced methods yourself once you get this). Start TF2, press '`' or '~' button on keyboard. In developer console, type status and press enter. It will give you a *unique* steam ID, which will look like Steam_0:0:001001010.

Copy this ID and close TF2. In the file admin_simple.ini, type " "STEAM_0:0:XXXXXXXX"	"99:z" "[without first "s], with XXXXXXXX as your ID. The first argument is the steam ID of person you want to grant admin permissions to. The second (ie 99) is immunity level, and third are flags. The greater the immunity level of an admin, the more powerful he is. An admin with lower immunity cannot kick/ban/burn(...) an admin with higher immunity. Flags are to be placed after an ':' after the immunity. Flag in above example, z, is the most powerful flag and can grant access to *all* flags. If you want an admin to have admin access, have reserved slot and ability to kick players, you need to write this in flags: "YY:abc", with YY the immunity.

To test if you're an admin or not, type '/sm_admin' in chatbox and if a menu pops up, everything is done right. If not, well...
Another way to check admin rights are type sm_who in console. It will display you information about all users conencted to server. If access has "none" in front of you name, you dont have admin access.


*Using admin commands*
A complete list of admin commands is available here: *wiki.alliedmods.net/Admin_Commands_(SourceMod)

To use these, just type !<command> to show your action in chatbox and execute or /<command> to execute the command without showing it in chatbox. Some commands you must know are:
sm_admin - Displays admin console
sm_kick <name> <reason(optional)> - Useful if there are some idiots using cheats/abusing.
sm_vote "vote question" "option 1" "option 2" "..." - Have votes on your server. Adding options is optional. If no option is added, Yes/No will be displayed.
sm_map <map> -Changes map to <map>
sm_cvar <cvar> <value> -Can display values of cvars. If <value> is given, cvar's value is set to it.
sm_csay <message> - Displays a centered message to all players. Instead of sm_csay, you can also write '@@@'

Note: The commands work from chatbox, thats the fun of SourceMod, you dont have to minimize game and access server console


----------



## SlashDK (Jan 21, 2012)

Thanks for sharing how you made your server nipun


----------



## Nipun (Jan 21, 2012)

Updated adding admins and using commands


----------



## Zangetsu (Jan 21, 2012)

Good Job Nipun...nice explained


----------



## Alok (Jan 21, 2012)

Nice job..


----------



## ico (Jan 21, 2012)

Nice tutorial. 

You started a TF2 server? Enough bandwidth or not?


----------



## Nipun (Jan 21, 2012)

ico said:


> Nice tutorial.
> 
> You started a TF2 server? Enough bandwidth or not?


2mbps upto 20GB. 512 after that  

Its Running smooth even with 8 people + 2 bots on server


----------



## ico (Jan 21, 2012)

Nipun said:


> 2mbps upto 20GB. 512 after that
> 
> Its Running smooth even with 8 people + 2 bots on server


That's the download. What's your upload speed?


----------



## Nipun (Jan 21, 2012)

ico said:


> That's the download. What's your upload speed?


512kbps 

but its still smooth so


----------

