|
| 1 | +In this guide, I will show you how to manage user permissions in [SourceMod](https://www.sourcemod.net/about.php). |
| 2 | + |
| 3 | +SourceMod is a [MetaMod](https://www.metamodsource.net/about) addon that supports most games running on the Source Engine. It is a powerful and highly optimized platform for creating plugins and managing server administration. SourceMod is widely used in games such as [Team Fortress 2](https://store.steampowered.com/app/440/Team_Fortress_2/), [Left 4 Dead 2](https://store.steampowered.com/app/550/Left_4_Dead_2/), and [Counter-Strike: Source](https://store.steampowered.com/app/240/CounterStrike_Source/)! |
| 4 | + |
| 5 | +When running a game server with SourceMod installed, it is likely that at some point you'll want to grant yourself or others permissions such as the ability to kick and ban players (admin access). |
| 6 | + |
| 7 | +## Finding Steam IDs |
| 8 | +Before assigning permissions to users, you will need to find their Steam ID. Both SteamID2 (`STEAM_X:X:XXXXXXXX`) and SteamID3 (`[U:X:XXXXXX]`) formats are supported in SourceMod. |
| 9 | + |
| 10 | +If you're connected to a server running on the Source Engine, you can execute the `status` command in the Developer Console to retrieve the Steam IDs of the current players connected to the server. |
| 11 | + |
| 12 | +Otherwise, you may use tools such as [Steam ID Finder](https://www.steamidfinder.com/) and [Steam ID I/O](https://steamid.io/) to find Steam IDs. |
| 13 | + |
| 14 | +## Flags |
| 15 | +To determine what specific permissions you want to assign to users, you need to understand SourceMod's flags system and what access they provide. Each flag is assigned using a single character. |
| 16 | + |
| 17 | +Here is a list of flags available in SourceMod. |
| 18 | + |
| 19 | +| Name | Flag | Purpose | |
| 20 | +| ---- | ---- | ------- | |
| 21 | +| reservation | `a` | Grants reserved slot access. | |
| 22 | +| generic | `b` | Grants generic admin (required for admin). | |
| 23 | +| kick | `c` | Grants access to kick other players. | |
| 24 | +| ban | `d` | Grants access to ban other players. | |
| 25 | +| unban | `e` | Grants access to remove bans. | |
| 26 | +| slay | `f` | Grants access to slay and harm other players. | |
| 27 | +| changemap | `g` | Grants access to change maps or major gameplay features. | |
| 28 | +| cvar | `h` | Grants access to change most ConVars. | |
| 29 | +| config | `i` | Grants access to execute config files. | |
| 30 | +| chat | `j` | Grants special chat privileges. | |
| 31 | +| vote | `k` | Grants access to start or create votes. | |
| 32 | +| password | `l` | Grants access to set a password on the server. | |
| 33 | +| rcon | `m` | Grants access to use [RCON](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol) commands. | |
| 34 | +| cheats | `n` | Grants access to change the `sv_cheats` ConVar or use cheating commands. | |
| 35 | +| root | `z` | Enables all flags and ignores immunity values. | |
| 36 | + |
| 37 | +Additionally, there are **custom** flags which can be used by plugins and such. |
| 38 | + |
| 39 | +| Name | Flag |
| 40 | +| ---- | ---- |
| 41 | +| custom1 | `o` | |
| 42 | +| custom2 | `p` | |
| 43 | +| custom3 | `q` | |
| 44 | +| custom4 | `r` | |
| 45 | +| custom5 | `s` | |
| 46 | +| custom6 | `t` | |
| 47 | + |
| 48 | +More information about flags may be found [here](https://wiki.alliedmods.net/Adding_Admins_(SourceMod)#Levels). |
| 49 | + |
| 50 | +## Passwords |
| 51 | +If you'd like, you can require specific users to input a password before being able to use the custom permissions assigned to them. They will need to input this password every time they connect to the game server, but they can automate this process on their side if they'd like. |
| 52 | + |
| 53 | +Firstly, you'll want to modify the `addons/sourcemod/configs/core.cfg` file and change the `PassInfoVar` line value from `_password` to something custom such as `_test`. The user will need to know their specific password and the password you set `PassInfoVar` to. |
| 54 | + |
| 55 | +When the user connects to the game server, they will need to execute the following command in the Developer Console. |
| 56 | + |
| 57 | +``` |
| 58 | +setinfo "<PassInfoVar Password>" "<User Password>" |
| 59 | +``` |
| 60 | + |
| 61 | +For example: |
| 62 | + |
| 63 | +``` |
| 64 | +setinfo "_test" "myCustomPass123" |
| 65 | +``` |
| 66 | + |
| 67 | +If the user wants to automate this process on their side, they'll need to modify the file `<Game Dir>/cfg/autoexec.cfg` and add the command above to the file. |
| 68 | + |
| 69 | +## How To Manage User Permissions |
| 70 | +Managing user permissions and assigning flags is done by modifying a file inside of the `addons/sourcemod/configs` directory (or `addons\sourcemod\configs` folder on Windows). |
| 71 | + |
| 72 | +There are two files you may edit which are explained below. |
| 73 | + |
| 74 | +### Using The `admins_simple.ini` File |
| 75 | +This file is used for quickly assigning user permissions. This is best for simple setups or wanting to quickly assign permissions to a user. When assigning permissions in this file, each line should have the following format. |
| 76 | + |
| 77 | +``` |
| 78 | +"<Steam ID/!IP/Steam name>" "[Immunity Level:]<Flags/@group>" ["password"] |
| 79 | +``` |
| 80 | + |
| 81 | +Here is an example of granting a user the `reservation`, `generic`, `kick`, and `ban` flags with `70` immunity. |
| 82 | + |
| 83 | +``` |
| 84 | +"STEAM_0:0:36969327" "70:abcd" |
| 85 | +``` |
| 86 | + |
| 87 | +### Using The `admins.cfg` File |
| 88 | +Using this file requires inputting more lines when assigning permissions to users, but may be considered cleaner. The format of the file uses SourceMod's [KeyValues](https://wiki.alliedmods.net/KeyValues_(SourceMod_Scripting)). Users should be added inside of the `Admins` section. |
| 89 | + |
| 90 | +Here is a generic format for adding users. |
| 91 | + |
| 92 | +``` |
| 93 | +"<Name>" |
| 94 | +{ |
| 95 | + "auth" "steam" |
| 96 | + "identity" "<Steam ID>" |
| 97 | + "flags" "<Flags>" |
| 98 | + "immunity" "<Immunity>" |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +Here is a list of *keys* you can assign to each user. |
| 103 | + |
| 104 | +* `auth` - Must be one of `steam`, `name`, or `ip` (unless there is a custom auth method), and instructs SourceMod how to interpret the identity value. |
| 105 | +* `identity` - A qnique value that allows SourceMod to find the user given an authentication method and the given value. |
| 106 | +* `password` - Specifies the password the user must enter. |
| 107 | +* `group` - Specifies a group name the user should inherit if available. More than one *group* line can be specified. There should be no `@` symbol as there is no ambiguity. |
| 108 | +* `flags` - The access flags the user should receive. |
| 109 | +* `immunity` - The immunity level the user should receive. |
| 110 | + |
| 111 | +## Reloading Users |
| 112 | +After assigning permissions to user(s) through the files mentioned above, you will need to reload the admin cache so that the permissions propagates. |
| 113 | + |
| 114 | +The cache should automatically reload when the map changes or server restarts. You may use the server command `sm_reloadadmins` to reload the cache manually so you don't have to wait until a map change or server restart. |
| 115 | + |
| 116 | +## See Also |
| 117 | +* [Adding Admins](https://wiki.alliedmods.net/Adding_Admins_(SourceMod)) - Detailed Wiki on adding admins officially by AlliedMods. |
| 118 | +* [SourceBans++](https://sbpp.github.io/) - A popular plugin that makes it easier to manage users, groups, bans, and more! |
0 commit comments