Dedicated Linux server extras

From TF2 Classic Wiki
Revision as of 20:03, 15 November 2022 by Sumea (talk | contribs)
Jump to navigation Jump to search

TF2 Classic SourceMod+Metamod Setup

Note: This guide was adapted and revised from a guide written by Raizo, the original of which can be found here: https://iraizo.github.io/tf2-classic-sourcemod-setup/

SourceMod+Metamod is powerful administrator tool for dedicated server owners and operators. SourceMod lets you add administrators easily based on SteamID, control and authenticate to the server securely and even add additional functionality to everyone on server like extended map voting functionality.

SourceMod isn’t necessarily drag-and-drop like supported SM games are such as live TF2 and CS:Source due to this simply being a mod built off of Source SDK 2013 with things like a different game name (tf2classic), offsets, signatures, etc.

While the process of getting SM to work isn’t that hard, generic source server guides do not cover few unique factors that come with setting up fully working MM+SM for mods like TF2 Classic.

Prerequisites

This guide assumes you already have a dedicated Linux server installed that can run without issues. If not you should follow this guide to setup your server first.

This guide will use the same example install path as the main setup guide, so feel free to follow this guide directly if you use the same directory too /opt/tf2classic/server/, sometimes just ../server/. Otherwise remember to use your own path instead.

Getting SourceMod and MetaMod

Visit the Stable builds section of sourcemod.net and grab the latest Linux build and upload it to your server using SFTP. If you do not have SFTP on your server, download it to your server using wget or similar tool.

Using Terminal or SSH instead of SFTP, first navigate to your server tf2classic folder, following example location from Dedicated Server Setup Guide, you would navigate to /opt/tf2classic/server/tf2classic/ first.
Then you can run wget to download SourceMod archive to your current directory:

$ wget https://sm.alliedmods.net/smdrop/1.11/sourcemod-1.11.0-git6917-linux.tar.gz
This link may be outdated. You can check sourcemod downloads page for the newest version and copy the URL of newest build from there.

You’ll also need stable Metamod:Source. Download it with one of the ways you did.

$ wget https://mms.alliedmods.net/mmsdrop/1.11/mmsource-1.11.0-git1148-linux.tar.gz
This link may be outdated as well. You can check metamod:source downloads page for the newest version's URL.

you can now extract both inside your tf2classic folder:

$ tar -xf sourcemod-1.11.0-git6917-linux.tar.gz
$ tar -xf mmsource-1.11.0-git1148-linux.tar.gz

You can delete the archive files after the extracted files are in correct place.

$ rem sourcemod-1.11.0-git6917-linux.tar.gz
$ rem mmsource-1.11.0-git1148-linux.tar.gz

Replacing metamod.vdf

Correct metamod.vdf is necessary for metamod:source to start correctly. Since this is a third party mod, we can use a web tool to generate a custom metamod.vdf file that points to tf2classic. Otherwise, we create one from scratch in text editor.

You should navigate to your ../server/tf2classic/addons/.

You can now delete metamod.vdf and metamod_x64.vdf in this directory. No need to back up these or anything, they are less than useless for TF2C server.

$ rem metamod.vdf
$ rem metamod_x64.vdf

Head over to sourcemm.net/vdf. You’re going to leave the “Game:” blank, or as “—”. In the “Game Folder” box, enter tf2classic. After downloading generated file with these variables, use SFTP to transfer it to your server's ../server/tf2classic/addons/ directory.

If you currently do not have SFTP available on your game server, you can alternatively do everything from Command Line/SSH, provided you have a text editor like nano installed.

Make sure that you are working in ../server/tf2classic/addons directory.

First create a metamod.vdf file in this directory with following command:

$ touch metamod.vdf

Followed by opening the file in your favorite command line text editor, nano in this example:

$ nano metamod.vdf

And type in the following to this blank file:

"Plugin"
{
	"file"	"../tf2classic/addons/metamod/bin/server"
}

before saving and exitting.

Importing custom gamedata

To fix many functions of SourceMod when running under Team Fortress 2 Classic, we need to import custom gamedata.
Move first to work under ../server/tf2classic/ directory. (/opt/tf2classic/server/tf2classic/)

If you are working with Ubuntu Server, you might have git installed. Try first the following command:

$ git clone https://github.com/Scags/TF2Classic-Tools.git

If you do not have git, download the repo with wget directly:

$ wget https://github.com/Scags/TF2Classic-Tools/archive/master.zip

Then unzip it:

$ unzip master.zip

cd into the directory, being either TF2Classic-Tools or TF2Classic-Tools-master depending on how you downloaded it.
Run the following command to copy sourcemod directory to your server's addons folder:

$ cp -r sourcemod/ ../addons/

Now we have the necessary gamedata for plugins and core SM and MM functions to work with TF2C.

Setting yourself as the “root” admin user and finalizing.

To register yourself as an administrator on your server's SourceMod, we have to add people to admins_simple.ini file.

You want to find out your and/or your to-be administrator's SteamID using a website like steamid.io. Enter your steam community URL to the site and you should get set of info that includes your steamID, which should be in STEAM_0:1:16 format.

Open the file ../server/tf2classic/addons/sourcemod/configs/admins_simple.ini with a text editor, nano for example. The file will be full of guidance and additional information about how the file works after slashes. Do not worry about leaving it all in as every line beginning with number of slashes are simply ignored, so this filled looking file is empty as it comes to how SourceMod handles it. Punch a new line at the bottom of this file and enter the following:

"STEAM_0:1:16"		"99:z"

Replace STEAM_0:1:16 with your own or your master administrator's steamID that you extracted with afformentioned steamid.io for example. "99:z" in this case assigns high immunity level and root (full) access for administration and server control. You can add more people to admins_simple.ini file but you should limit their access to the server appropriately by using examples within the file itself and documentation from SourceMod's wiki: https://wiki.alliedmods.net/Adding_Admins_(SourceMod)

Save, exit and start/restart your server and everything should be running fine. You can test this by typing meta version in your server console (or RCON). You should see a line like "Loaded As: Valve Server Plugin.". Additionally, if you assigned yourself as an administrator for the server, typing !admin or /admin in chat should bring up administrative menu on player hud. sm_admin should additionally work when typed in to your client console window, and you can use sm_rcon to use SourceMod to relay any console command to the server, if you set yourself up with z flag.

Further tweaking of SourceMod to suit your needs is out of scope for this guide. You can get familiar with SourceMod's other functions and configuration in their wiki: wiki.alliedmods.net/Category:SourceMod_Documentation

Additionally, if you have setup RCON on your server before setting up SourceMod, you should disable it by wiping RCON_PASSWORD empty in server.cfg. After it is working, using SourceMod and sm_rcon for RCON commands is more secure for publicly hosted servers.