[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
howtos:software:halflife_dedicated_server [2013/03/09 16:09 (UTC)] – created alienbobhowtos:software:halflife_dedicated_server [2013/03/09 16:42 (UTC)] – Add section about custom maps. alienbob
Line 1: Line 1:
 ====== Installing a Half-Life Dedicated Server ====== ====== Installing a Half-Life Dedicated Server ======
  
-This article will guide you through the installation and configuration of a Half-Life Dedicated Server (HLDS). Half-life was [[http://valvesoftware.com/|Valve Software's]] first game. Even though it was released in 1998, it is still very popular among on-line gamers. \\+This article will guide you through the installation and configuration of a Half-Life Dedicated Server (HLDS). [[http://store.steampowered.com/app/70/|Half-Life]] was [[http://valvesoftware.com/|Valve Software's]] first game. Even though it was released in 1998, it is still very popular among on-line gamers. \\
 Running a Half-Life server is fun for you and your friends. The Half-Life game is resource-friendly and fast -even on not-too-new hardware. Running a Half-Life server allows you to choose the list of maps which will be rotated on your server or other forms of customization (like password-protecting the server so that //you// determine who can join the games). Running a Half-Life server is fun for you and your friends. The Half-Life game is resource-friendly and fast -even on not-too-new hardware. Running a Half-Life server allows you to choose the list of maps which will be rotated on your server or other forms of customization (like password-protecting the server so that //you// determine who can join the games).
  
Line 51: Line 51:
 $ ./steamcmd.sh  $ ./steamcmd.sh 
 </code> The program will automatically update and enter you in to a **Steam%%>%%** prompt. Type "''help''" for more information. </code> The program will automatically update and enter you in to a **Steam%%>%%** prompt. Type "''help''" for more information.
-  * To download the Half-Life game server files, you login to your Steam server account: </code>+  * To download the Half-Life game server files, you login to your Steam server account: <code>
 Steam> login <username> Steam> login <username>
 </code> </code>
   * Enter your password. Then check your e-mail for your Steam Guard access code and enter it (you will only need to do this once per computer). \\ You should see a message stating that you have successfully logged in with your account.    * Enter your password. Then check your e-mail for your Steam Guard access code and enter it (you will only need to do this once per computer). \\ You should see a message stating that you have successfully logged in with your account. 
-  * Set your server install directory. In this article, we will use a subdirectory "//hlds_l//" in the directory where ''steamcmd'' is located: <code> +  * Set your server install directory. In this article, we will use a subdirectory "//hlds_l//" in the server's "working" directory, not a subdirectory of the directory where ''steamcmd'' is located - we need to enter a full path: <code> 
-Steam> force_install_dir ./hlds_l/+Steam> force_install_dir /home/steam/server/hlds_l/
 </code> </code>
   * Install or update the HLDS game server files. Every Steam application has its own "//app_id//" or "Steam Application ID" which will be one of the parameters.  You can find the //AppId// for the game(s) you want to download here: https://developer.valvesoftware.com/wiki/Steam_Application_IDs . <code>   * Install or update the HLDS game server files. Every Steam application has its own "//app_id//" or "Steam Application ID" which will be one of the parameters.  You can find the //AppId// for the game(s) you want to download here: https://developer.valvesoftware.com/wiki/Steam_Application_IDs . <code>
Line 67: Line 67:
 </code> </code>
  
-This will have populated the "hlds_l" directory (it is of course an arbitrary name, pick any name you like) with the Half-Life Dedicated Server binaries (hlds*) as well as full game content for Half-Life in its sub-directory "valve". A total of around 410 MB.+This will have populated the "''~steam/server/hlds_l''" directory (it is of course an arbitrary name, pick any name you like) with the Half-Life Dedicated Server binaries (''hlds*'') as well as full game content for Half-Life in its sub-directory "''valve''". A total of around 410 MB.
  
  
 ==== Starting the Game Server ==== ==== Starting the Game Server ====
  
-The //SteamCMD// utility will have installed the hlds linux binaries in the subdirectory you specified with the "''force_install_dir''" parameter, in our example case, that directory is "''./hlds_l''". The Half-Life game files will have been downlloaded to the "''valve''" subdirectory below that (other games such as Counter Strike all get their own subdirectory).+The //SteamCMD// utility will have installed the hlds linux binaries in the subdirectory you specified with the "''force_install_dir''" parameter, in our example case, that directory is "''~steam/server/hlds_l''". The Half-Life game files will have been downlloaded to the "''valve''" subdirectory below that (other games such as Counter Strike all get their own separate subdirectory).
  
 You can start the Half-Life game server directly using the following commands: <code> You can start the Half-Life game server directly using the following commands: <code>
 $ cd ~/server/hlds_l $ cd ~/server/hlds_l
-$ ./hlds_run -game valve +maxplayers 4 +map CObase +exec server.cfg+$ ./hlds_run -game valve +maxplayers 4 +map crossfire +exec server.cfg
 </code> </code>
 If your server is multi-homed (i.e. it has multiple IP addresses) or you want to run the server on a non-standard port, then you may be required to add commandlin parameters like "''+ip 192.168.1.1 +port 27015''". If your server is multi-homed (i.e. it has multiple IP addresses) or you want to run the server on a non-standard port, then you may be required to add commandlin parameters like "''+ip 192.168.1.1 +port 27015''".
 +
 +Check out the file "''server.cfg''" in the "''hlds_l/valve''" directory, it determines how your HLDS behaves. Some important "''sv_''" variables which you definitely should configure are: <code>
 +// Show my contact email:
 +sv_contact "alien@slackware.com"
 +
 +// We report ourselves as an European server:
 +sv_region 3
 +
 +// default server name. Change to "Bob's Server", etc.
 +// hostname "Half-Life"
 +hostname "Alien BOB's server"
 +
 +// Allow clients to download maps
 +sv_allowdownload 1
 +
 +// Allow clients to upload decals
 +sv_allowupload 1
 +
 +// LAN only play
 +//sv_lan 1
 +
 +// Use this if clients need a password to join:
 +//sv_password "sesame"
 +</code>
  
 Because this is a game server, you do not want to be forced to keep a terminal opened all the time while the server is running. Therefore it is much more convenient to run the server in a "''screen''" session, using a start script like this one which also configures your ''screen'' session to log all output to a file: <code> Because this is a game server, you do not want to be forced to keep a terminal opened all the time while the server is running. Therefore it is much more convenient to run the server in a "''screen''" session, using a start script like this one which also configures your ''screen'' session to log all output to a file: <code>
Line 84: Line 108:
 #!/bin/bash #!/bin/bash
 cd server/hlds_l cd server/hlds_l
-screen -A -mdLS hlds_valve -c /home/steam/.screenrc ./hlds_run -console -game valve -pingboost 2 +sys_ticrate 1000 +sv_maxupdaterate 100 +ip 192.168.1.1 +port 27015 +maxplayers 4 +map crossfire -pidfile hlds.pid +cpu 1+screen -A -mdLS hlds_valve -c /home/steam/.screenrc 
 + ./hlds_run -console -game valve -pingboost 2 -pidfile hlds.pid \ 
 + +sys_ticrate 1000 +sv_maxupdaterate 100 +ip 192.168.1.1 +port 27015 +maxplayers 4 +map crossfire +cpu 1
 EOT EOT
 $ chmod +x /home/steam/server/start_hlds.sh $ chmod +x /home/steam/server/start_hlds.sh
 $ cat << EOT > /home/steam/.screenrc $ cat << EOT > /home/steam/.screenrc
 log on log on
-logfile /home/steam/server/hlds_screen.log+logfile /home/steam/server/logs/hlds_screen.log
 EOT EOT
 </code> </code>
Line 104: Line 130:
 It is good practice to let the Steam components update themselves. You can use a cron job to run an update once a day. It is good practice to let the Steam components update themselves. You can use a cron job to run an update once a day.
  
-Create a wrapper script which updates the game(s) automatically. \\ Save the following lines to a new file "''~/server/steamwrapper.sh''" : <code>+Create a wrapper script which updates the game(s) automatically. \\ Create a new file "''~/server/steamwrapper.sh''" as follows: <code>
 $ cat <<EOT > ~/server/steamwrapper.sh $ cat <<EOT > ~/server/steamwrapper.sh
 #!/bin/sh #!/bin/sh
Line 116: Line 142:
 app_update 90 validate app_update 90 validate
 exit exit
-</code> And then configure the steam user's cron table to call the script like: <code>+</code> And then configure the steam user's cron table to call the script once a day. Run this command to start the crontab editor: <code> 
 +crontab -e -u steam 
 +</code> and then add this line which will schedule the update at ''03:55'' every day: <code>
 55 3 * * *     /home/steam/server/steamwrapper.sh 2>&1 | tee -a /home/steam/server/logs/cron.log 55 3 * * *     /home/steam/server/steamwrapper.sh 2>&1 | tee -a /home/steam/server/logs/cron.log
 </code> </code>
 +
 +Enjoy the game!
 +
 +
 +====== Custom server maps for small servers ======
 +
 +If you enjoy close-combat games with your friends, some relatively small (less than 8 players) and enjoyable maps can be found here: http://alienbase.nl/half-life/ . \\ Make sure that the friends who join your server, have downloaded your server's custom map pack before they join. This will prevent long in-game loading times. Downloading a map "in-game" may take as long as the actual cycle time of the map! \\ Custom maps go into the server's (and client's) "''maps''" subdirectory of the "''valve''" game directory.
  
  
 howtos:software:halflife_dedicated_server ()