Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HL2MP] Add proper server admin tools #948

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

speedvoltage
Copy link
Contributor

@speedvoltage speedvoltage commented Mar 5, 2025

Description

The too long did not read version: I feel like some natively built-in server admin tools could be beneficial to folks running servers. While Source already comes with some commands, like kick, kickid, banid, etc. those only are useful on a listen server and require rcon on a dedicated server.

This is not to say this replaces Sourcemod, but this allows those who do not want to download plugins to have admin tools natively built-in the SDK.

I worked for a while on this, hopefully, this is bug-free. This was developed and tested with HL2DM, but I don't see a reason why this wouldn't work on TF2.

Full usage

Server Administration Interface

Introduction

This new server administration interface was implemented to provide an all in one package and provide server owners with the tools that they need to administrate their servers. The advantage is that it is built within the binaries, tailored for HL2MP and loads fast and does not come with any useless features. If you are coming from Sourcemod, a lot of the new system is built around familiarity so that if you wish to make the transition, you will not feel lost.

Admin Commands & Levels

Admin Commands

Usage

The server admin interface comes with a number of commands, all of which used to keep players in line with your rules or to maintain your server.

To use an admin command, you must follow the following syntax:

  • [Server Admin] Usage: sa <command> [arguments]

If you use the console to input commands, you must always prepend sa before the command: sa map dm_lockdown
If you use the chat to input commands, you do not need sa at all: !map dm_lockdown
Additionally, you can silence chat commands by using a forward slash: /map dm_lockdown

It also supports reply sources. If you type a command in the chat, it will reply in the chat, if you use the console (player or srcds server console), it will reply in those.

Targeting

Multiple options are available to target a player or a group:

NOTE: Not all commands may support this:

General Targets Purpose
name Targets a player by their name. Partial names are supported; full names may require quotes if they contain spaces or need exact matching.
#userid Targets a player by their user ID. Use the status command in the console to retrieve a player's ID. The # symbol is required.
@all Targets all players on the server.
@me Targets yourself as the admin executing the command.
@blue Targets all players on the Combine team.
@red Targets all players on the Rebels team.
@!me Targets all players except yourself.
@alive Targets all players who are currently alive.
@dead Targets all players who are currently dead.
@bots Targets all bot players.
@humans Targets all human (non-bot) players.

Below is a table listing all available commands. Please note that non-root admins may only see commands they have access to.

Command Format Admin Access Level Description
say <message> Chat (j) Sends an admin formatted message to all players in the chat
csay <message> Chat (j) Sends a centered message to all players
psay <name|#userID> <message> Chat (j) Sends a private message to a player
chat <message> Chat (j) Sends a chat message to connected admins only
ban <name|#userID> <time> [reason] Ban (d) Ban a player
kick <name|#userID> [reason] Kick (c) Kick a player
addban <time> <SteamID3> [reason] RCON (m) Add a manual ban to banned_user.cfg
unban <SteamID3> Unban (e) Remove a banned SteamID from banned_user.cfg
slap <name|#userID> [amount] Slay (f) Slap a player with damage if defined
slay <name|#userID> Slay (f) Slay a player
noclip <name|#userID> Slay (f) Toggle noclip mode for a player
team <name|#userID> <team index> Slay (f) Move a player to another team
gag <name|#userID> Chat (j) Gag a player
ungag <name|#userID> Chat (j) Ungag a player
mute <name|#userID> Chat (j) Mute a player
unmute <name|#userID> Chat (j) Unmute a player
bring <name|#userID> Slay (f) Teleport a player to where an admin is aiming
goto <name|#userID> Slay (f) Teleport yourself to a player
map <map name> Change Map (g) Change the map
cvar <cvar name> [new value] CVAR (h) Modify any cvar's value
exec <filename> Config (i) Executes a configuration file
rcon <command> [value] RCON (m) Send a command as if it was written in the server console
reloadadmins No arguments Config (i) Refresh the admin cache
help No arguments Generic (b) Provide instructions on how to use the admin interface
version No arguments Generic (b) Display version

Admin Levels

Different commands require different levels. It is up to the server owner to define what an admin has access to.

Name Flag Description
Generic b Basic admin functions (help, credits, version).
Kick c Permission to kick players.
Ban d Permission to ban players.
Unban e Permission to unban players.
Slay f Player management (slap, slay, noclip).
Change Map g Permission to change the map.
CVAR h Permission to modify server variables (cvars).
Config i Permission to execute configuration files and refresh the admin cache.
Chat j Chat functions (gag, mute, psay).
Vote k Start or create votes.
Password l Set a password on the server.
RCON m Server console access without password.
Root z Full permissions and immunity.

There is no notion of immunity. It is expected and assumed that selected admins are fit for the job they were assigned. Only root admins are protected from being kicked, banned, gagged and muted.
Finally, there is no admin menus available. After surveying a number of people, it is clear the admin menu has absolutely no use and therefore was not included.

Adding Admins

Adding admins is straightforward. All admin data is handled in a single file called admins.txt. Navigate to hl2mp\cfg\admin and open admins.txt. This file also includes instructions on adding admins in case you need a reminder. At the bottom of the file, use the KeyValues format to add your admins:

"Admins"
{
	"STEAMID"
	{
		"flags"		"ACCESS"
	}
}

Note: You must use the SteamID3 format. Any other format will be ignored.

Example:

"Admins"
{
	"[U:1:400275221]"
	{
		"flags"		"z"
	}
}

Admin data loads on every level initialization. You can also use sa reloadadmins to manually refresh the admin cache.


Admin Logs

Admin Logs

All admin commands are logged in the hl2mp\cfg\admin\logs directory. Admin log files are prefixed with adminlogs_, followed by the current date. Each log entry is formatted as follows:

[MAP] DATE @ TIME => Admin ADMIN_NAME <SteamID3> ACTION

Example:

[dm_overwatch] 2024/11/01 @ 09:34:35 => Admin Console <Console> changed map to dm_powerhouse
[dm_overwatch] 2024/11/01 @ 09:47:18 => Admin Peter Brev <[U:1:400275221]> executed rcon: botrix bot add
[dm_overwatch] 2024/11/01 @ 09:47:21 => Admin Peter Brev <[U:1:400275221]> kicked Bart (fool) <BOT> (No reason provided)
[dm_overwatch] 2024/11/01 @ 09:52:21 => Admin Peter Brev <[U:1:400275221]> executed rcon: sv_noclipspeed 15
[dm_overwatch] 2024/11/01 @ 11:50:07 => Admin Console <Console> changed map to dm_runoff

Note: Admin logs cannot be disabled.

► Added proper server admin tools natively to the Source SDK 2013.
@speedvoltage speedvoltage changed the title Add proper server admin tools [HL2MP] Add proper server admin tools Mar 5, 2025
► Removed due to top menus issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant