Server configuration: различия между версиями

Материал из Metrostroi
Перейти к: навигация, поиск
 
(не показано 11 промежуточных версий 3 участников)
Строка 5: Строка 5:
 
| en = Server configuration
 
| en = Server configuration
 
}}
 
}}
 +
For the best Metrostroi experience you should set up a dedicated server using Source Dedicated Server (srcds). This page contains instructions on how to set up a server, populate it with Metrostroi content and play on it.
  
{{Important|Turbostroi is only supported on Windows. Servers hosted on other platforms will perform poorly.}}
+
{{Important|The machine on which you intend to run this server should be running Windows or a Windows virtual machine. This is because it is highly recommended to install Turbostroi, a Windows-only binary that allows far greater performance. Servers hosted on other operating systems will perform poorly without Turbostroi.}}
= 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 [https://developer.valvesoftware.com/wiki/SteamCMD#Downloading_SteamCMD Valve Developer Wiki].  
+
=Setting up a basic server =
= Installing the Server (Windows) =
+
Follow [https://wiki.facepunch.com/gmod/Downloading_a_Dedicated_Server this guide] to install a basic Garry's Mod server. This server will have no extra content other than the base game. There are lots of high-quality server setup and maintenance guides available on Google/Bing/Yandex/etc.
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).
+
{{Important|You must set the server tickrate to 33 or Metrostroi may be unstable. Add this to the server launch command-line: <pre>-tickrate 33</pre>}}
<pre>
+
 
"PATH_TO_STEAMCMD\steamcmd.exe" +login anonymous +force_install_dir "PATH_FOR_SERVER" +app_update 4020 validate +quit
+
=Installing Metrostroi=
pause
+
The easiest way to install addons on a dedicated sever is to connect the server to a Steam Workshop collection.  
</pre>
+
 
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.
+
If you will only be playing Metrostroi on this server, the [https://steamcommunity.com/sharedfiles/filedetails/?id=1660685783 default Metrostroi collection] (ID 1660685783) will be adequate.
= 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 [http://steamcommunity.com/workshop/browse/?section=collections&appid=4000 Garry's Mod Steam Workshop "Collections" section] and clicking [http://steamcommunity.com/workshop/editcollection/?appid=4000 "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:
+
Alternatively, you can add more content, even content not related to Metrostroi, by making your own collection. You can can do this [https://steamcommunity.com/workshop/editcollection/?appid=4000 here]. (Make sure you are signed in to Steam on your browser before clicking this link or it will redirect you somewhere else) This collection should contain at an absolute minimum:
 
* [http://steamcommunity.com/workshop/filedetails/?id=261801217 Metrostroi (Subway Simulator)]
 
* [http://steamcommunity.com/workshop/filedetails/?id=261801217 Metrostroi (Subway Simulator)]
* Metrostroi Subway Simulator - Content Pack part (1 to 6)
+
* Metrostroi Subway Simulator - Content Packs:
 +
** [https://steamcommunity.com/workshop/filedetails/?id=1095094174 Part 1]
 +
** [https://steamcommunity.com/workshop/filedetails/?id=1095098251 Part 2]
 +
** [https://steamcommunity.com/workshop/filedetails/?id=1095100683 Part 3]
 +
** [https://steamcommunity.com/workshop/filedetails/?id=1095105863 Part 4]
 +
** [https://steamcommunity.com/workshop/filedetails/?id=1095109617 Part 5]
 +
** [https://steamcommunity.com/workshop/filedetails/?id=1095111608 Part 6]
 
* [https://steamcommunity.com/workshop/filedetails/?id=1095130789 Metrostroi Subway Simulator -  Scripts]
 
* [https://steamcommunity.com/workshop/filedetails/?id=1095130789 Metrostroi Subway Simulator -  Scripts]
* A Metrostroi map you want to use (mostly listed [https://wiki.metrostroi.net/wiki/%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_%D0%BA%D0%B0%D1%80%D1%82 here])
+
* Any of the Metrostroi maps from [https://wiki.metrostroi.net/wiki/List_of_maps here] or [https://steamcommunity.com/workshop/browse/?appid=4000&searchtext=Metrostroi&childpublishedfileid=0&browsesort=textsearch&section=items&requiredtags%5B%5D=Map here].
= 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.
+
You must then append the server startup command-line with the following:
<pre>
+
<pre>+host_workshop_collection WORKSHOPID</pre>
srcds.exe +maxplayers 20 -console +host_workshop_collection YOUR_COLLECTION_ID +gamemode sandbox +map NAME_OF_THE_MAP_YOU_WANT
+
{{Important|'''Replace WORKSHOPID with either 1660685783 (the default collection) or your own collection ID.''' A collection's ID is found at the end of the collection's URL.}}
</pre>
+
 
You can find the names of most metrostroi maps [https://wiki.metrostroi.net/wiki/%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_%D0%BA%D0%B0%D1%80%D1%82 here] to replace "NAME_OF_THE_MAP_YOU_WANT".<br>
+
==Configuration==
'''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.'''<br>
+
A list of available convars is available [https://wiki.metrostroi.net/wiki/Console_Commands#Server-side_Commands here].
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 [https://wiki.garrysmod.com/page/Category:Server_Owners here].
+
 
 +
As a server administrator you can enable the use of Metrostroi trains on non-Metrostroi maps by unchecking the box "Require third rail" in the spawn menu (hold Q) under Utilities, Metrostroi, Admin. Many trains will still expect an ARS signal and may not work well without it.
 +
 
 +
The [https://steamcommunity.com/sharedfiles/filedetails/?id=1838480881 Metrostroi Advanced] addon provides additional facilities for server administrators, as well as quality-of-life enhancements for players such as station teleports and an automatic train re-railer. It requires [https://steamcommunity.com/workshop/filedetails/?id ULX], which in turn requires [https://steamcommunity.com/workshop/filedetails/?id=557962238 ULib].
 +
 
 +
=Installing Turbostroi=
 +
Turbostroi speeds up the Metrostroi simulations by allowing the simulations to use multiple CPU threads, improving performance. A dedicated server with Turbostroi installed is often over 5x as fast as playing Metrostroi in the built-in Singleplayer mode in Garry's Mod.
 +
 
 +
{{Important|'''Turbostroi is only compatible with the Windows version of the Garry's Mod server. It is not compatible with Garry's Mod servers on other operating systems or the game itself.'''}}
 +
 
 +
Download the Turbostroi binary from [https://metrostroi.net/turbostroi here] and place it into the "/garrysmod/lua/bin/" folder in your server. Create the "bin" folder if it isn't already present.
 +
 
 +
{{Important|Because it is a DLL file, some web browsers may mark the Turbostroi file as harmful. This is a false positive and can be safely ignored. VirusTotal results for Turbostroi can be viewed [https://www.virustotal.com/gui/file/fca58b3700d2753db783bb1d9cdec399ce5e3a8cb92eae6f47555093954982f0/detection here].}}
 +
 
 +
==Configuration==
 +
'''It is recommended to disable hyper-threading if possible.'''
  
= Turbostroi =
+
You can set what threads Turbostroi should use to get even better perfomance:
You can download the "Turbostroi" binary from [http://metrostroi.net/turbostroi 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. Make sure to do this for your game client as well if you haven't already.
 
  
 +
This command sets the SRCDS main thread to x, where x is a binary or bitwise value.
 +
<pre>turbostroi_main_cores x</pre>
  
== Turbostroi Convars ==
+
This command sets the Metrostroi train threads to x, where x is a binary or bitwise value.
Turbostroi offers even better performance when configured correctly. It offers 2 primary convars available to change:
+
<pre>turbostroi_train_cores x</pre>
  
'''turbostroi_main_cores''': SRCDS thread allocation. Turbostroi changes the SRCDS thread to the specified thread.
+
For example, on a 4-core system you should set turbostroi_main_cores and turbostroi_train_cores to 8 and 7 respectively, or 128 and 127 respectively with hyperthreading enabled. This setup will run the main SRCDS thread on the last CPU thread, leaving the rest for Metrostroi.
  
'''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.
+
=Connecting to the server=
 +
The method for connecting to the Metrostroi server varies depending on your circumstances.
  
The value for each of these convars is converted into a binary, or bitwise, value. A simple process is described below.
+
==Localhost LAN==
 +
If you are playing by yourself and hosting the server on the same computer you are playing on, the game server should appear in the LAN section of the server browser in Garry's Mod. Alternatively, you can run this in the Garry's Mod developer console: <pre>connect localhost</pre>
  
#First, figure out how many cores your processor has. We will assume our processor has '''4''' cores.
+
==LAN==
#Represent each core with a binary digit. Our processor will be represented as such: 0000
+
If you are playing by yourself and hosting the server on a different computer to the one you are playing on, the game server should appear in the LAN section of the server browser in Garry's Mod. Alternatively, if you know the other computer's local IP address (normally starting with 192) you can connect to it by running this in the Garry's Mod developer console: <pre>connect IPADDRESS</pre> (where IPADDRESS is replaced with the other computer's local IP)
#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
 
#Any remaining core(s) may be used for the SRCDS thread. This will be represented as 0001
 
#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.
 
#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.
+
You can find a computer's local IP address by running the [https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/ipconfig ipconfig] command in Command Prompt on Windows.
  
= Connecting to the Server =
+
==WAN==
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. <br>
+
If you are hosting the server on a computer on a different network to the computer on which you will be playing, or you wish to make your server open for multiplayer, you will need to forward ports 27005 and 27015 on the router for both TCP and UDP. The exact process for this varies between routers; [https://portforward.com/ portforward.com] hosts comprehensive guides for thousands of routers.
'''Do not complete the following steps unless you know what you are doing- adding firewall exceptions can make your computer and network less secure.'''<br>
 
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 =
+
Once you have forwarded ports 27005 and 27015, you can connect to the server with its public IP address. You can find its public IP by opening [https://www.whatismyip.com/ this link] on the server computer. Run this command in the Garry's Mod developer console to connect:
== Server.cfg ==
+
<pre>connect IPADDRESS</pre>
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:
+
(where IPADDRESS is replaced with the server's public IP). The server should also automatically appear in the server browser.
* 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 [[Console_Commands|here]].
 
  
== ULX ==
+
You can password protect your server to prevent strangers from joining by adding the following to the /garrysmod/cfg/server.cfg file in the server: <pre>sv_password "PASSWORD"</pre> where PASSWORD is replaced with a password of your choice.
[http://steamcommunity.com/sharedfiles/filedetails/?id=557962280 ULX] is an admin tool that will make dealing with players and changing maps much easier.
 
== WUMA ==
 
[http://steamcommunity.com/sharedfiles/filedetails/?id=1117436840 WUMA] allows server administrators to restrict entities and loadouts to particular usergroups or players.
 
== Garry's Mod Wiki ==
 
Check out the [https://wiki.garrysmod.com/page/Category:Server_Owners "Server Owners" section on the Garry's Mod Wiki]. It has some helpful tutorials on [https://wiki.garrysmod.com/page/Loading_URL setting a loading screen] and other more advanced topics not covered here.
 

Текущая версия на 04:16, 24 апреля 2021

Available languages: Русский · English


For the best Metrostroi experience you should set up a dedicated server using Source Dedicated Server (srcds). This page contains instructions on how to set up a server, populate it with Metrostroi content and play on it.

Important:The machine on which you intend to run this server should be running Windows or a Windows virtual machine. This is because it is highly recommended to install Turbostroi, a Windows-only binary that allows far greater performance. Servers hosted on other operating systems will perform poorly without Turbostroi.


Setting up a basic server

Follow this guide to install a basic Garry's Mod server. This server will have no extra content other than the base game. There are lots of high-quality server setup and maintenance guides available on Google/Bing/Yandex/etc.

Important:You must set the server tickrate to 33 or Metrostroi may be unstable. Add this to the server launch command-line:
-tickrate 33


Installing Metrostroi

The easiest way to install addons on a dedicated sever is to connect the server to a Steam Workshop collection.

If you will only be playing Metrostroi on this server, the default Metrostroi collection (ID 1660685783) will be adequate.

Alternatively, you can add more content, even content not related to Metrostroi, by making your own collection. You can can do this here. (Make sure you are signed in to Steam on your browser before clicking this link or it will redirect you somewhere else) This collection should contain at an absolute minimum:

You must then append the server startup command-line with the following:

+host_workshop_collection WORKSHOPID
Important:Replace WORKSHOPID with either 1660685783 (the default collection) or your own collection ID. A collection's ID is found at the end of the collection's URL.


Configuration

A list of available convars is available here.

As a server administrator you can enable the use of Metrostroi trains on non-Metrostroi maps by unchecking the box "Require third rail" in the spawn menu (hold Q) under Utilities, Metrostroi, Admin. Many trains will still expect an ARS signal and may not work well without it.

The Metrostroi Advanced addon provides additional facilities for server administrators, as well as quality-of-life enhancements for players such as station teleports and an automatic train re-railer. It requires ULX, which in turn requires ULib.

Installing Turbostroi

Turbostroi speeds up the Metrostroi simulations by allowing the simulations to use multiple CPU threads, improving performance. A dedicated server with Turbostroi installed is often over 5x as fast as playing Metrostroi in the built-in Singleplayer mode in Garry's Mod.

Important:Turbostroi is only compatible with the Windows version of the Garry's Mod server. It is not compatible with Garry's Mod servers on other operating systems or the game itself.


Download the Turbostroi binary from here and place it into the "/garrysmod/lua/bin/" folder in your server. Create the "bin" folder if it isn't already present.

Important:Because it is a DLL file, some web browsers may mark the Turbostroi file as harmful. This is a false positive and can be safely ignored. VirusTotal results for Turbostroi can be viewed here.


Configuration

It is recommended to disable hyper-threading if possible.

You can set what threads Turbostroi should use to get even better perfomance:

This command sets the SRCDS main thread to x, where x is a binary or bitwise value.

turbostroi_main_cores x

This command sets the Metrostroi train threads to x, where x is a binary or bitwise value.

turbostroi_train_cores x

For example, on a 4-core system you should set turbostroi_main_cores and turbostroi_train_cores to 8 and 7 respectively, or 128 and 127 respectively with hyperthreading enabled. This setup will run the main SRCDS thread on the last CPU thread, leaving the rest for Metrostroi.

Connecting to the server

The method for connecting to the Metrostroi server varies depending on your circumstances.

Localhost LAN

If you are playing by yourself and hosting the server on the same computer you are playing on, the game server should appear in the LAN section of the server browser in Garry's Mod. Alternatively, you can run this in the Garry's Mod developer console:

connect localhost

LAN

If you are playing by yourself and hosting the server on a different computer to the one you are playing on, the game server should appear in the LAN section of the server browser in Garry's Mod. Alternatively, if you know the other computer's local IP address (normally starting with 192) you can connect to it by running this in the Garry's Mod developer console:

connect IPADDRESS

(where IPADDRESS is replaced with the other computer's local IP)

You can find a computer's local IP address by running the ipconfig command in Command Prompt on Windows.

WAN

If you are hosting the server on a computer on a different network to the computer on which you will be playing, or you wish to make your server open for multiplayer, you will need to forward ports 27005 and 27015 on the router for both TCP and UDP. The exact process for this varies between routers; portforward.com hosts comprehensive guides for thousands of routers.

Once you have forwarded ports 27005 and 27015, you can connect to the server with its public IP address. You can find its public IP by opening this link on the server computer. Run this command in the Garry's Mod developer console to connect:

connect IPADDRESS

(where IPADDRESS is replaced with the server's public IP). The server should also automatically appear in the server browser.

You can password protect your server to prevent strangers from joining by adding the following to the /garrysmod/cfg/server.cfg file in the server:

sv_password "PASSWORD"

where PASSWORD is replaced with a password of your choice.