安装 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/06/08 08:47 (外部编辑)