Dedicated Servers
Downloading and Launching
You can use SteamCMD to download the s&box dedicated server.
Once you have that, in a command line, or by making a .bat file in the same directory as steamcmd.exe, run the following:
Alternatively, you can use the default sbox-server.exe
in your Steam sbox directory.
Once downloaded, to launch the server, you would typically do something like this in some kind of .bat file (see the next section for more information on how to configure your server):
Dealing With Updates
You will have to re-run steamcmd every time s&box updates in order to update the server to the latest version; players will not be able to join if they are running on a different version of the game to your server.
This poses a problem since currently s&box updates many times each day. One way around this is to use a .bat script that restarts and re-updates the server at regular intervals:
This script will restart the server every 3600 seconds (every hour).
The downside of this is that it will forcefully close your server. For most games, this probably doesn't matter. But, if your server was doing I/O operations at the time like saving to file, this could lead to data corruption. The only guaranteed way to prevent this is to make sure your gamemode is not doing any I/O at the time the process is killed. Since you know your server is going to be restarting every hour or so, you could do this by implementing a TimeSince
that stops I/O operations during the last minute.
Shutting Down Gracefully
You can shut down your server gracefully at any time by typing quit
into the console.
Troubleshooting
Occasionally, the dedicated server might crash unexpectedly. You might want to check the following:
- Make sure the server is up to date following the steps above.
- Check
/logs/Log.log
for clues. - Update the s&box editor and re-upload the gamemode to asset.party. Sometimes updates to s&box require the gamemode to be rebuilt.
If all else fails, file a bug report, preferably with logs.
Launch Configuration
As with any Source dedicated server, when launching you can use convars to customize your server settings. To load a game and a map, specify its organization and identifier - you can find them by browsing sbox.game
This is a list of some of the more useful convars.
convar | Behaviour | Example |
---|---|---|
+game | Sets the game and map. | +game facepunch.walker facepunch.flatgrass |
+hostname | Sets the name of the server. | +hostname "My Epic Server" |
+net_game_server_token | Allows you to set a token for your server that ensures that you will always have the SteamID. Visit Visit https://steamcommunity.com/dev/managegameservers to generate a token associated with your Steam Account. | +net_game_server_token <token> |
Connecting
To connect to a server from in game, you may use the console command connect <ip>:27015
, where <ip>
is your server's public IP address.
If you're connecting from the same machine that is hosting the dedicated server, you may use the loopback address like connect 127.0.0.1:27015
.
Hosting Unreleased Content
It seems to be the case that you can host dedicated servers for gamemodes that are not public on sbox.game. This is useful because it means you can host your gamemode whilst stopping it from showing up in the games list. The downside to this is that it presumably means that other people can host your unreleased content with a dedicated server too. Although, in practice, no one is likely to care enough to do this.