Setting up CS 1.6 server in 2024 with AMXX and Match Deluxe

So, you have thought of organising some fun gaming sessions to remember the nostalgia. However, the game and the server software is immensely outdated, including plugins for AMXX. What do?

Setting up the server manually or with LinuxGSM?

Overall, both choices are valid. I went with LinuxGSM due to ease of setup – you can setup several configs, run them simultaneously, which greatly reduces the time needed to setup each server. LinuxGSM configs are easy to alter.

If you go with LinuxGSM, what you need to do:

The base commands that you will need to run after installing Debian:

adduser <username> // Add a user with a desired name
su <username> // Login as the new user
curl -Lo linuxgsm.sh https://linuxgsm.sh && chmod +x linuxgsm.sh && bash linuxgsm.sh csserver // Get the script for setting up the server
./csserver install // Install the server

These are the base commands to start with. The setup will guide you through the process. Once you are done, you may run ./csserver start.

WARNING: If you intend to use ReHLDS in the future, better alter the LinuxGSM config sooner than later and reinstall the server to continue the setup. Instructions at the end.

Prerequisites for installing AMXX, Metamod, etc.

This is the hard part (sort-of). You can use the command ./csserver mods to install AMXX, Metamod, which are required to install custom plugins, modules, etc. However, before I knew that, I went to do it manually, and I think it is the better way to understand how it all works, especially getting accustomed to the file structure and whatnot.

If you decide to go manual or not, you have two options as to how to install things:

  • Do it all from the terminal;
  • Use SFTP to alter, download, upload files.

I went with the second option because I am much more used to the way SFTP works, I was researching all of my plugins, modules, scripts on a Windows PC, which meant I had all the files on the PC. That was simply easier for me, especially since you’ll need to alter configs a lot. For that, we use WinSCP.

How to setup AMXX and Metamod?

Now, this is my personal experience where I tested many, many versions to find out which one actually worked for my case. Overall, most of them work, but I advise you to use these as the baseline:

For setting up, the main steps would be very simple:

  • Login via SFTP and open up serverfiles/cstrike
  • Create a folder called addons, then create folders amxmodx and metamod
  • Extract the files from the archives in the respective folders:
    • You want metamod folder to have metamod.so.
    • You will have to create plugins.ini file.
    • In plugins.ini, you will have to enter this line:
      linux addons/amxmodx/dlls/amxmodx_mm_i386.so

Go back to cstrike folder, edit liblist.gam to reflect the following changes:

  • In the line where you have gamedll linux, you will have to alter it so it points to the Metamod files:
    gamedll_linux "addons/metamod/metamod.so"

To verify, after these changes, you may start the server and see whether the console shows you that Metamod and AMX Mod X were loaded at startup using ./csserver console.

Once you have confirmed that it works, you now have a fully working installation of a CS 1.6 server, AMXX and Metamod.

How to set up plugins?

For this part, what you need to understand is that it is best to compile the plugins yourself. That is because that most of them were made using old AMXX versions and may be either incompatible or may need altering. This is useful because the compile script tells you what is wrong with the compile process, so you can alter the source code of the plugin. It isn’t very difficult most of the time, sometimes all you need is to remove an include because newer AMXX versions come with that include in the base package, for instance.

For installing plugins, each plugin will have some readme to guide you. The process typically is this:

  • Get the plugin files and extract them in the respective folders. Usually, plugins / sub-plugins come with some resources, configs, scripting files (source code .sma file and includes), etc. Those can be altered as needed.
  • For compiling, go to serverfiles/cstrike/addons/amxmodx/scripting:
    • In this folder, you have a bash script, called compile.sh.
    • In order to use it, you go to the scripting folder, and execute the ./compile.sh command. This will initiate the compiling process in the terminal.
    • Once you are done, in scripting/compiled you will have the plugins compiled file in .amxx format.
    • Move the compiled .amxx file to amxmodx/plugins folder.
    • Edit the amxmodx/configs/plugins.ini file to add the following line at the end: <pluginfilename>.amxx
    • Edit any config files if needed for the plugin to run.
  • Reload AMXX or the server itself with one of the following methods:
    • In the server console, type restart
    • In the server console, type amx_reload
    • In the VM / CT terminal, type ./csserver restart

This is the main process of how to set up a generic plugin. Of course, each plugin is different, so if you need to set up SQL, or you are adding a complex plugin like Zombie Plague, you may need to edit their respective config files to reflect the changes that you need.

SQL or not SQL?

Overall, this is purely your choice, but if you want to be future-proof and have the stats available externally, it is advised to have a MySQL database. You can have it on the same machine which would be ideal. That way, if any plugin requires MySQL and you want to set up some kind of website to show stats and whatnot, it will be much easier to do that.

To give you an example, I was setting up a competition server with AMX Match Deluxe. The plugin is heavily outdated as it uses PHP4 or 5 (difficult to say) and MySQL 4 or something along the lines. Due to these limitations, it is more or less incapable of displaying stats on the web as well as access and alter MySQL DBs due to syntax differences, knowing that the current MySQL ver. is 8.x and PHP is at the moment of writing is 7.4-8.3.

There are two options to mitigate this:

  • Set up a container/VM that would be outdated and use MySQL 4 and old PHP versions. However, there is a chance the OS version you may pick will not have support anymore or even the packages to begin with. It is also a massive security breach.
  • Update the plugin code to reflect the needed changes.

Naturally, I went with the second option.

How to update AMX Match Deluxe to work on Debian 11?

The procedure isn’t as difficult as it sounds. What you need to do is this:

  • Alter the .sma file to reflect changes from MySQL 4 to MySQL 8.
  • Alter the .php files to reflect changes from MySQL 4 to MySQL 8 and PHP 4 to PHP 7.4/8.3.
  • Update the mysql_connect.php file.

The changes that are mostly in question are syntax and function changes:

  • Function changes, like mysql_ to mysqli_, MYSQL_BOTH to MYSQLI_BOTH, TYPE=MyISAM to ENGINE=MyISAM, etc.;
  • Function parameter order changes, like in mysqli_query, where $sql (query string) used to be the first parameter, but in newer MySQL versions, $link (connection object) is the first, then followed by $sql (query string).
  • Teams queries had to be altered to use SEARCH DISTINCT instead of SEARCH * FROM [...] GROUP BY [...] due to SQL mode.
  • General debugging to fix minor things like permissions, access issues, etc., if they occur.

I strongly advise using Notepad++ for these changes as you can easily replace the same lines / functions in ALL files using NP++. You can also ask ChatGPT to generate regex syntax to easily replace all the instances you need.

Regarding MySQL general setup

Although I will not be going into detail due to how individual each situation is, I can give you general information.

  • Using MySQL, you have to create a database of desired name. You can go for something as simple as amx or amxx, as an example.
    • You can either use the terminal commands to do that, or use MySQL Workbench to do it with a GUI from a remote PC (this is easier, but requires you to allow access for the user for the IP of the remote machine that will need the access, explained below).
  • You need to create a user and give it a password.
    • You could use the following:
      CREATE USER 'amx'@'YOUR_IP' IDENTIFIED BY '<create_password_here>'
  • You have to give the user privileges to create, edit the database.
    • The easiest way out is to grant all privileges:
      GRANT ALL PRIVILEGES ON *.* TO 'amx'@'THE_IP_OF_CHOICE'
      • You could also be more specific to make sure you protect as much of your database as possible. For instance, specify the database using amx.* instead of *.*, to make sure that any other databases on the same server wouldn’t be affected if that particular user got compromised.
  • If it’s a remote user, you may need to give privileges for that particular IP (even if it is a local IP):
CREATE USER 'amx'@'LAN_IP_OF_ORIGIN' IDENTIFIED WITH mysql_native_password BY '<create_password_here>'

For each IP, you could say a new user is created to allow access. It is mandatory to use mysql_native_password because CS 1.6 is too old to support the new caching_sha2_password authentication. Keep in mind it will be deprecated in the future.

If you wish to allow a local PC or laptop to use MySQL Workbench and alter the databases remotely with a GUI, you may need to execute a similar command as well:

CREATE USER 'amx'@'LAN_IP_OF_PCLAPTOP' IDENTIFIED WITH caching_sha2_password BY '<create_password_here>'

You could use the same identification method as before, but it is always best to secure as much of the server as possible. For each of those user IPs, you will have to grant privileges that you need to.

Altering AMXX configs to use MySQL

After all that, you will need to alter your AMXX configs as follows:

  • Edit cstrike/addons/amxmodx/config/sql file to make sure to enter the correct MySQL credentials for the database you setup.
  • Edit cstrike/addons/amxmodx/configs/plugins.ini to make sure these changes:
    • Comment the line with admin.amxx
    • Uncomment the line with admin_sql.amxx
  • Edit cstrike/addons/amxmodx/configs/modules.ini to make sure these changes are present:
    • Uncomment mysql module to make sure it is enabled.

Setting up AMX Match Deluxe after updating

Naturally, the procedure is very simple afterwards.

First of all, upload the web files to /var/www.

  • You can do it on the same machine if it will be public facing and you know how to expose the statistics to the internet. You can also set it up on a different local machine that would be public facing instead, with a domain name and whatnot. This is up to you.

After that, edit the config.php file to enter the needed credentials to login into the MySQL database:

// Set the hostname for the database
$mysqli_host = "localhost";

// Set the username for the database
$mysqli_username = "YOUR_DB_USERNAME";

// Set the password for the database
$mysqli_password = "YOUR_DB_PASSWORD";

// Set the database name
$mysqli_database = "YOUR_DB_NAME";

// Set the title of the stats pages ( text is also used in place of a banner )
$server_name = "AMX Match Deluxe Match Stats";

OPTIONAL: Alter mysql_connect.php to provide more information in case of error:

<?php
// Connect to the database using mysqli_connect
$link = mysqli_connect($mysqli_host, $mysqli_username, $mysqli_password, $mysqli_database);

// Check connection
if (!$link) {
    die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
?>

After this, everything should work and you should be able to view the stats on your webpage.

Common Issues you might encounter

This is a list of things you have to keep in mind:

  • If setting up remote MySQL access, you have to open ports as well for those machines.
  • If setting up public facing statistics, you either have to setup nginx, setup certificates (if you use a domain), or expose it directly by IP (not advised unless you know what you do).
  • Logs are your best friend. To set up a webpage, you may use apache2. I advise to have a test-machine setup to debug errors that occur when running the .php scripts as it may vary depending on your situation. Logs are typically in /var/logs/<servicename>.
  • Things may break or not work due to simple user error, like a mistyping a directory/path. Follow what you do carefully.

ReHLDS setup concerns

If planning to use ReHLDS, keep in mind that you will have to alter LinuxGSM config and reinstall the server.
To do that, you have to edit the following file:

~/lgsm/config-lgsm/csserver/_default.cfg

and alter the following line:

branch="" // Original line of textbranch="steam_legacy" // New line of text

After this, you should run ./csserver install and then continue with setup of the server, ReHLDS, AMXX, Metamod, etc.

Provided files

The following archive contains files that are already fixed for newer PHP and SQL versions:

  • amx_match.sma – the source code of the plugin;
  • config.php – the credentials used for logging into the SQL database;
  • index.php – main page;
  • team.php – teams page;
  • player.php – player stats page;
  • map.php – maps page;
  • misc_functions.php
  • mysqli_connect.php – code used to connect to the db.

Comments

3 responses to “Setting up CS 1.6 server in 2024 with AMXX and Match Deluxe”

  1. Fabien Avatar
    Fabien

    Hello,
    If you have always Amx Match Deluxe updated files, i’m interesting. I try to install SQL module for statistics matchs, but due to new versions of SQL and PHP, it doesn’t work.
    Thanks in advance

    1. Paprika Avatar

      Hello,

      I’ll take a look and review the files for upload once I have some free time, if that’s alright. Once I do that, I’ll let you know. I assume you would need both the web side and the source of the plugin.

    2. Paprika Avatar

      I have uploaded the files. Feel free to check if they work for you. Keep in mind you have to change the credentials to the ones you use for your SQL database, as well as change the database name to the one you use as well.

Leave a Reply

Your email address will not be published. Required fields are marked *