User:Beporter/Server Rewrite

Requirements

 * Windows operating system. (The dedicated server does not run under any other OS such as linux.)
 * Microsoft .NET Framework 4 Client Redistributable




 * The Microsoft XNA Framework Redistributable 4.0. (The dedicated server will crash on launch with the error below if this framework is not already installed.)

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass embly 'Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKey Token=842cf8be1de50553' or one of its dependencies. The system cannot find the f	ile specified. at Terraria.ProgramServer.Main(String[] args)

Installation

 * If you have Terraria installed already, then you already have the dedicated server in the game folder. (Usually something like .)
 * If you want to host a server without running Steam on your computer, you can download the standalone dedicated server from the Terraria homepage.


 * Make sure you have installed the Microsoft .NET Framework 4 Client Redistributable and the Microsoft XNA Framework Redistributable 4.0 from above.


 * If you have a router or firewall, you must configure it to forward/allow traffic on port  (default) to your server.
 * Read more about port forwarding: here and here.

Configuration
To configure your server, you must edit the contents of the  file with the appropriate settings. Use the Config File Options section for reference.

Running the Server

 * Use the included  script to start the server.
 * If you don't have an existing world, a new one will be randomly generated and stored in the folder you specified with the  setting in.
 * The default number of max players is 8.
 * You can set a password to protect your game server.
 * Share your IP address, the port number, and your server's Terraria password with your friends!
 * Players can join your server from the "Multiplayer" menu in Terraria.

Auto-restart
If you use the  script to launch your server, the script will attempt to restart the server any time   quits or dies unexpectedly. This is usually a good thing since it means your server will come back up automatically, but can cause problems when you want to legitimately quit the server, such as when you type  in the server's console.

To remedy this, it is possible to configure TerrariaServer.exe to run as a system Service in the background using the sc.exe or srvany.exe tools. The disadvantage to this is that you will lose access to the TerrariaServer console to monitor the game state and issue commands. There are commercial options like AlwaysUp, Mean Server Loader and FireDaemon (commercial!) that can help work around some of these issues.

Backups

 * You should take care to back up your  folder and your   file periodically.
 * Unless you specify another path in, your worlds are stored in
 * %USERPROFILE% usually resolves to  in Windows XP or   in Windows Vista and 7.

Reference
Below are sections taken from the default serverconfig.txt file for easy reference.

Config File Options
Taken from the default :

maxplayers=8
 * 1) Sets the max number of players allowed on a server. Value must be between 1 and 255

world=C:\Users\Defaults\My Documents\My Games\Terraria\Worlds\world1.wld
 * 1) Load a world and automatically start the server.

port=7777
 * 1) Set the port number

password=p@55w0rD
 * 1) Set the server password

motd=Please dont cut the purple trees!
 * 1) Set the message of the day

worldpath=C:\Users\Defaults\My Documents\My Games\Terraria\Worlds\
 * 1) Sets the folder where world files will be stored

autocreate=3
 * 1) Creates a new world if none is found. World size is specified by: 1(small), 2(medium), and 3(large).

worldname=World
 * 1) Sets the name of the world when using autocreate

banlist=banlist.txt
 * 1) The location of the banlist. Defaults to "banlist.txt" in the working directory.

secure=1
 * 1) Adds addition cheat protection.

Command Line Options
The  can take most of the same options as what is available in the config file, although it's usually easier to use the config file and only specify   on the command line. Here is the complete list.

Taken from the default :

-config 			Specifies the configuration file to use. -port 				Specifies the port to listen on. -maxplayers 			Sets the max number of players. -players 				Alias for -maxplayers. -password 			Sets the server password. -pass 				Alias for -password. -world 				Load a world and automatically start the server. -autocreate <#>					Creates a world if none is found in the path specified by -world. World size is specified by: 1(small), 2(medium), and 3(large). -banlist 					Specifies the location of the banlist. Defaults to "banlist.txt" in the working directory. -worldname 			Sets the name of the world when using -autocreate. -secure							Adds addition cheat protection to the server.