安裝 Counter-Strike: Source 伺服器 Installing a Counter-Strike: Source server

Flubber 提供給 Gandi。

I - 下載 HL-Dedicated Server

The server's principle is the same for all mods (at least those officially offered by Valve) conceived with this engine, such as Counter Strike Source, Half Life 2 Deathmatch or Team Fortress 2.

To begin with, you need to download the server and then the files corresponding to the game you're going to install. 首先,您需要下載伺服器軟體並將他解壓縮,等等會進行安裝。

Let's start by creating a directory in which to deploy the installation tool, and then download the file (Source Server, or srcds). 我們先建立一個資料夾並將佈署工具存放在這裡,請下載檔案(資料夾命名為 srcds)。

mkdir srcds
cd srcds
wget http://storefront.steampowered.com/download/hldsupdatetool.bin
chmod +x hldsupdatetool.bin

Now let's launch an update for this tool, and for Steam 下載好後請執行

./hldsupdatetool.bin
./steam


II - 安裝遊戲檔案 Installing the game files

Now let's fetch the files corresponding to Counter-Strike Source. But let's begin by creating a directory for these files: 現在我們來下載並解壓縮檔案到 Counter-Strike Source。先建立一個資料夾來存放這些檔案:

mkdir css
./steam -command update -game "Counter-Strike Source" -dir css

Needless to say that this part of the installation is by far the longest! If you wish to accelerate the download and the treatment of files, you can buy a couple more shares for the time of the installation.

This command is the same you'd use if you wanted to update your server but don't use autoupdate, as we'll see a little lower.

We'll therefore tell Steam to update the installation (-command update) for Counter Strike Source (-game “Counter-Strike Source”) in the current directory (-dir .). In our case it is inexistent: the game will be completely downloaded. 這個指令會告訴 Steam 在目前的資料夾(-dir .),更新(-command update) Counter Strike Source (-game “Counter-Strike Source”) 的安裝。在這個範例中: 遊戲將會完整的下載。

To install other mods, all you need to do is replace “Counter-Strike Source” by the name of a mod, such as “TF” for Team Fortress 2, “hl2mp” for HL2-Deathmatch. 如果您要安裝其他遊戲,您只需要將 “Counter-Strike Source” 更名為新的遊戲名稱,譬如 “TF” 表示 Team Fortress 2,”hl2mp” 表示 HL2-Deathmatch。

Once the download is finished, it's good to check that the files are all in good state. This step is not compulsory, but isn't very time consuming either and ensures the server will work properly. 在下載完成後,最好檢查一下每個檔案的狀態。這不是必要的步驟,但也不是很耗費時間必且可以確保後須伺服器工作正常。

./steam -command update -game Counter-Strike Source -dir css -verify all

The game server is now completely downloaded and ready to be launched. But you need to configure it in order to obtain a customized - and optimized - server. 現在遊戲伺服器已經下載完成並且可以執行。但您需要先調整一下自訂的設定與系統優化。


III - 自訂你的伺服器 Customizing the server

server.cfg

All necessary infos required by the server are in the server.cfg file which is itself in the cfg directory. If it doesn't exist, create it. 所有的設定都在設定檔 server.cfg 內,這個檔案在 cfg 這個資料夾內,如果沒有這個檔案或資料夾,請直接建立它。

These are the basic infos the server will need. There are an enormous amount of variables which are not worth presenting here, but you'll find everything you need easily on the web. It may look a little daunting like this, but it's necessary to know a minimum amount of these variables to manage your server properly. 這裡需要提供伺服器一些必要的資訊。另外這裡會有很多變數,所以請不要設定錯誤,您可以在這個網頁找到相關數值。設定可能不容易了解與閱讀讓您感到困惑,您需要了解您伺服器的極限再來設定這些值。

server.cfg

// Server name - Provide a name for your server here
hostname "Father Flubber's Counter-Strike Server @ Gandi"
 
// rcon Password (this is your server's administration password, do not share it with anyone)
rcon_password "password"
//Server password (here you can provide a password to restrict access to your server, or leave this field empty if you want a public server)
sv_password ""

Server cvars (從這裡開始列出了伺服器的變數清單 here begins the long list of server variables)

大部分的變數設定 :
0 關閉功能
1 開啟功能

Sometimes you'll need to give a value, especially in the case of time variables.
其他有些變數您需要給他額外的值,特別是一些時間相關的變數。

Values marked by // are the most important. 用 // 是最重要的。

// activates friendly fire
mp_friendlyfire 0
mp_footsteps 1
mp_autoteambalance 1
// Automatic kick of players
mp_autokick 0
// Allows flashlights
mp_flashlight 0
//Automatic punishment for team-killing
mp_tkpunish 1
//Blocks camera for dead players
mp_forcecamera 0
//Activates vocal discussion for both teams
sv_alltalk 0
//Allows the server to be paused
sv_pausable 0
//Allows cheating
sv_cheats 0
//Checks integrity of data to ensure the client and server have the same files 
sv_consistency 1
//Allows upload and download (tags or maps you've added for example)
sv_allowupload 1
sv_allowdownload 1
sv_maxspeed 320
mp_limitteams 2
mp_hostagepenalty 5
sv_voiceenable 1
mp_allowspectators 1
//Time limit for each map (in minutes)
mp_timelimit 25
mp_chattime 10
//Time before inactive player is kicked (in seconds)
sv_timeout 65
// round variables
//Time where players are frozen at the beginning of the round (in seconds)
mp_freezetime 6
//Length of a round (in minutes)
mp_roundtime 5
//Amount of money with which players begin round
mp_startmoney 800
//Length of the bomb timer
mp_c4timer 45
//Maximum amount of rounds before changing maps
mp_maxrounds 0
//Maximum amount of team victories before changing maps
mp_winlimit 0
//Player protection time before the beginning of a round (in seconds)
mp_spawnprotectiontime 5

網路設定 Network settings
These settings allow you to force player machines to transmit info at the same time for fairness' sake, regardless of their connexion speed 這些設定是讓每一個玩家都能同時傳送網路資料,這樣比較公平,不管他們的網路速度為何。

sv_minrate 4000
sv_maxrate 8000
decalfrequency 60
sv_maxupdaterate 100
sv_minupdaterate 60
// Server logs
//Activates server logging (variables: on/off)
log on
//Log banned players
sv_logbans 1
sv_logecho 1
sv_logfile 1
sv_log_onefile 0
//Miscellaneous
//Defines if server is local or online (always leave this variable on 0)
sv_lan 0
//Defines the server's region (For Europe, put 3)
sv_region 3
//Disables Valve's dynamic pricing system (very few servers use it)
mp_dynamicpricing 0
// execute ban files
//Server will read list of banned users
exec banned_user.cfg
//Server will read list of banned IPs
exec banned_ip.cfg

If you don't want to write your server.cfg file yourself, you can use online automatic generators to set your variables.
For example: http://www.cstrike-planet.com/cfgmaker?cfg=srcds 如果您不想自己動手設定 server.cfg 檔,您可以透過線上自動產生的方式設定。
位置在: http://www.cstrike-planet.com/cfgmaker?cfg=srcds

B - 增加地圖 Adding maps

Few servers run with the original maps today. Many players have indeed played them countless times.
到今天還有一些伺服器只有原裝地圖。許多玩家也玩過無數次了。

Servers usually host a selection of maps which correspond to a certain “tone”, and to your clan members' and visitors' wants.

One can't really give you advice on the maps you should be installing. I can only recommend a site that I consider to be a reference: fpsbanana.com, which lists almost every map created and a ranking of the most downloaded.

Maps must be copied into the “maps” folder which is in your installation's root directory.

Once they have been copied, you need to add them to the mapcycle. To do so, nothing simpler: edit the mapcycle.txt file which is also at the root of your server, add the name of the recently installed map and save it.

It will be taken into account as soon as the server changes to the next map being played, without even needing to restart.

The Half-Life 2 engine includes a bzip decompresser. This greatly accelerates the map download speed by connected clients because they fetch the compressed version of the map rather than the full version.

All files needing to be compressed can be compressed. This is the way to go about it:

cd maps
bzip2 newmap.bsp

You'll then obtain a file, newmap.bsp.bz2, which will take half as much space as the original map, thus dividing the download time for players by two.

Any file can be compressed, not only the .bsp files for maps, but also the accompanying text files and the sound files you may have wanted to add.

:!: It's possible to create a download mirror in order to avoid the game server being overloaded when a player doesn't have the map. It is imperative to keep the same architecture on this server as you do on the game server.

For instance, suppose my mirror is on "http://www.cssmirror.com". I should therefore create a css folder in which I will create a maps folder, where all the new maps in .bz2 format will go (it's necessary to put both). Once the mirror is set up, you must add the following to the server.cfg file:

// Maximum file size allowed for downloadable files (Original value is 15Mo) 
net_maxfilesize 60
//Provide mirror URL
sv_downloadurl "http://www.cssmirror.com/css/"

Once the mirror is set up, nothing will be downloaded on the game server: the mirror will be the exclusive source of files for players. If you install a map on your game server and forget to put it on the mirror, the players will not be able to download it.


IV - Launching the server

After this long but necessary configuration phase, let's launch our brand new CS:S server.

Go to the /srcds/ folder and launch the Source Dedicated Server in the following way:

In our example, the server will have 24 player spots, a tickrate of 100 and will start with the de_dust2 map.

cd srv/srcds/
./srcds_run -console -game cstrike +map de_dust2 -maxplayers 24 -autoupdate -tickrate 100

Tickrate info enables you to define the frequency in the update of client information. It can range from 40 (default) to 100. The higher it is set, the less there will be a lag between client information and servers.

A high tickrate enables you, for example, to avoid having a player who has just run for cover being killed because of a lag in his positioning to other players, who wrongly see him as being still in the clear.

Put simply, the higher the tickrate, the higher the information about player positions will be precise, and you'll receive fewer player complaints :)

Of course, it is completely possible to launch the CS:S server in a screen, so as to keep an access to your machine. To do so, all you need to do is launch the server like so:

screen -A -m -d -S css-server ./srcds_run -console -game cstrike +map de_dust2 -maxplayers 24 -autoupdate -tickrate 100

A css-server screen will be created. To access it, type:

screen-x css-server

There you go, have fun, and don't be afraid to ask any question to the Gandi community!


上一次變更: 2016/05/31 10:23 (外部編輯)