Simple Weapon Restrictor
This plugin simply restricts weapons, so they can't be used. All weapons can easily be restricted by the use of commands or the config file. The plugin is "sv_cheats"-friendly, and it's impossible to equip a restricted weapon. (If that's not the case, please contact me)
- Very simple to use
- Prevent specific weapons from being used
- Control restricted weapons through commands
- Easy-to-use config file for permanent restrictions
- wr_restrict <weapon*> - Restricts the given weapon.
- wr_unrestrict <weapon*> - Unrestricts the given weapon.
- wr_reload - Reloads the config files. (Note: This removes all temporary restrictions.)
All commands require the config admin flag.
The weapon parameter can either be the classname (e.g. weapon_awp) or the weapon alias (e.g. awp). It's also case-insensitive.
The config adds a neat and simple way to permanently restrict weapons. It's not needed and does not have to be present at all. The config is located in addons/sourcemod/configs/restricted_weapons.txt
. It's a plain text file, where each line is an entry in the restrictions list. A line consists of just a weapon alias, which works the same way as the commands. The plugin will yield warning, if a line is an invalid weapon or if the same weapon is listed multiple times. An example of a config file could be:
The config can use both class names and weapon aliases. There's some invalid weapons and some other weapons are listed multiple times in this config. The plugin skips the invalid entries and works fine even with errors in the config, but it does print some warnings in the console to assist the server manager:
[WR] Config file: WARNING - Invalid entry: rpg! (Line: 4)
[WR] Config file: WARNING - Invalid entry: stunstick! (Line: 6)
[WR] Config file: WARNING - Duplicate entry: p90! (Line: 7)
[WR] Config file: Loaded 4 restriction(s).
This makes it easy to identify mistakes. It loaded 4 restrictions in total: awp, p90, glock, and deagle. The other lines were simply skipped. A more detailed description of the loading process can be seen with debug enabled. The ConVar config is located in cfg/sourcemod/restricted_weapons.txt
If you want to utilize the config file, then you have to manually create the file: addons/sourcemod/configs/restricted_weapons.txt
. Otherwise, it's a normal plugin installation.
- wr_debug (default: false/0) - Prints debug information to the console.
- wr_version - The current version of the plugin.
- Commenting in config file
- Listing restrictions
- Further customization
I see this plugin as done, because I want to keep it simple. But I'm open for suggestions.
This plugin must be compiled with SourceMod v1.8 or higher.
I know this plugin isn't anything major, but I've been working with SourcePawn for about a year now, and I've mostly done private plugins. I thought this simple plugin, which I made for a friend, might be a good start on AM. So, yea, this is also my first post, so the formatting might be odd. Thanks for giving my plugin a look!