Server configuration

Материал из Metrostroi
Перейти к: навигация, поиск
Available languages: Русский · English



Important:Turbostroi is only supported on Windows. Servers hosted on other platforms will perform poorly.

Installing SteamCMD

SteamCMD is a command line tool that makes setting up servers for Garry's Mod (and most other Source engine based games) very easy. You can download it for Windows and Linux from the Valve Developer Wiki.

Installing the Server (Windows)

To download and install your server enter the following script into command prompt or save it as a batch file (paste it into notepad, click "Save As..", set the "Save as type" to "All Files (*.*)" and append ".bat" or ".cmd" to the filename).

"PATH_TO_STEAMCMD\steamcmd.exe" +login anonymous +force_install_dir "PATH_FOR_SERVER" +app_update 4020 validate +quit
pause

Running the batch file will start to download a Garry's Mod to the "PATH_FOR_SERVER" directory you specified. This process may take some time depending on the speed of your internet connection.

Creating a Collection

The most straightforward way to add mods to your server is to create a steam workshop collection. You can do this by navigating to the Garry's Mod Steam Workshop "Collections" section and clicking "Create Collection". When you've named and branded your collection head over to the Workshop pages for any of the mods you want to add and click "Add to Collection" then choose the name of your server collection. To install Metrostroi you add the following mods to your collection:

Installing Mods

Using command line arguments you can configure your server to automatically install/ update all of the items in a collection. Save the following script as a batch file in the same path as your Garry's Mod server is installed.

srcds.exe +maxplayers 20 -console +host_workshop_collection YOUR_COLLECTION_ID +gamemode sandbox +map NAME_OF_THE_MAP_YOU_WANT

You can find the names of most metrostroi maps here to replace "NAME_OF_THE_MAP_YOU_WANT".
Please note that the "gm_metrostroi_b50" has a lighting issue that may cause your server fail when starting up due to a "Engine hunk overflow!". To fix this add " +r_hunkalloclightmaps 0" to the end of your command line arguments.
If you have followed the above steps correctly you should now have a fully functional Metrostroi server. If you don't, for whatever reason, the Garry's Mod wiki has a more general (but more detailed guide) on how to set one up here.

Turbostroi

You can download the "Turbostroi" binary from here. Without it, your server will perform quite poorly. Unzip the downloaded file and then place the ".dll" file into your "garrysmod\lua\bin" directory as the README directs. Make sure to do this for your game client as well if you haven't already.


Turbostroi Convars

Turbostroi offers even better performance when configured correctly. It offers 2 primary convars available to change:

turbostroi_main_cores: SRCDS thread allocation. Turbostroi changes the SRCDS thread to the specified thread.

turbostroi_train_cores: Train thread allocation. Most, if not all, Metrostroi systems will register in Turbostroi and will receive the benefit of multithreading. This is the main benefit of Turbostroi being installed.

The value for each of these convars is converted into a binary, or bitwise, value. A simple process is described below.

  1. First, figure out how many cores your processor has. We will assume our processor has 4 cores.
  2. Represent each core with a binary digit. Our processor will be represented as such: 0000
  3. Which cores do you want dedicated to train threads? I will use the first 3 cores, which means I "turn them on" and represent them as follows: 1110
  4. Any remaining core(s) may be used for the SRCDS thread. This will be represented as 0001
  5. Now, you must convert those bitwise values into decimal values. It is recommended to use the built-in Windows calculator in the "Programmer" mode. When doing this, you may enter the bitwise values by clicking on "BIN" and type in the bitwise values for each convar. For example, I will type in 1110, which results in the decimal value 14. I will then type in 0001, which results in the decimal value 1.
  6. Next, take your decimal values and input them into the console for your desired convar. I wanted to use the first 3 cores for trains, so I will type in the console "turbostroi_train_cores 14". The same procedure follows with the other convar.

After this is all done, you should restart the server. If Turbostroi starts outputting a bunch of errors about affinity and whatnot, you have configured the convars incorrectly.

Connecting to the Server

You should be able to connect to your server using the "LAN" tab in your Garry's Mod server browser or by using the "LAN" tab in the steam "Servers" window. If you use any form of firewall or your router has a built in firewall other players probably won't be able to connect to your server. To solve this you need to tell your firewall to allow certain network traffic though to your game server.
Do not complete the following steps unless you know what you are doing- adding firewall exceptions can make your computer and network less secure.
The exact process of adding "exceptions" to your networks firewalls depends heavily on what hardware/ software you are using. You are probably best looking up a guide of how to "Port Forward" on your specific router and how to add firewall exceptions to your antivirus. By default Garry's Mod will use the ports 27005 and 27015 (UDP and TCP) however if you choose to run more than one server at the same time you will need to unblock two ports for each server (eg 27006 and 27016)

Tips

Server.cfg

You can set the name, password, wagon limit and other important things by editing the "server.cfg" in "garrysmod\cfg". Below are some useful lines to put in this file:

  • hostname "SERVER_NAME_HERE"
  • metrostroi_maxwagons "WAGON_LIMIT_HERE"
  • metrostroi_maxtrains "TRAIN_LIMIT_HERE"
  • metrostroi_maxtrains_onplayer "MAX_TRAINS_PER_PLAYER_HERE"

A more extensive list of console commands here.

ULX

ULX is an admin tool that will make dealing with players and changing maps much easier.

WUMA

WUMA allows server administrators to restrict entities and loadouts to particular usergroups or players.

Garry's Mod Wiki

Check out the "Server Owners" section on the Garry's Mod Wiki. It has some helpful tutorials on setting a loading screen and other more advanced topics not covered here.