Name Reserve [1.2.2]
This plugin allows you to specify a list of reserved names, so that if a random person joins your server with your name (or anyone's name you list in the config), they'll be renamed or kicked (configurable). Note: this only renames players *onconnect* -- if they rename themselves while in-game, they can bypass this. (See future ideas)
For example, if your name is "EngineerSpy" and you list that name in the config, then if a user connects with that name, one of the following will happen depending on your settings:
- They'll be renamed to "EngineerSpy (guest)" (where '(guest)' is a configurable cvar).
- They'll be renamed to "I tried to use a bad name ;_;" (where the name is a configurable cvar)
- They'll be kicked after X seconds, with warning messages displayed.
This also supports partial name matches. So if you set in your config a reserved name of "Foo", then a user joining with the name of "Foo" or "FooBar" or "BarFoo" they'll be renamed (unless authorized, of course).
This is my first plugin so please leave comments/suggestions so I can improve upon this :)
Also note: I flagged this under "Any" though I really only tested on TF2 -- in theory it should handle other games fine, but if anyone finds that's not the case please let me know!
Cvars:
When you load the plugin it'll create a namereserve.cfg in your cfg/sourcemod directory. You can edit the cvars there to modify these settings.
Code:
// Admin flag for reserved name use immunity. Empty string means all admins are checked and must have steam ids listed in the config.
// -
// Default: "b"
sm_namereserve_adminsflag "b"
// If PunishType is set to rename, this is the name the user will be changed to.
// -
// Default: "I tried to use a bad name ;_;"
sm_namereserve_badname "I tried to use a bad name ;_;"
// If PunishType is set to kick, this value is used as the delay before kicking the user.
// -
// Default: "60"
sm_namereserve_kickdelay "60"
// Set this to the kick message a user will see (if PunishType is set to kick)
// -
// Default: "Using a reserved name"
sm_namereserve_kickmsg "Using a reserved name"
// If PunishType is set to kick, this value is used as the amount of times the user will be issued warnings that they're going to get kicked. (This will be evenly divided out of kickDelay, so if you set kickDelay to 10 and this to 5, the user will be warned
// -
// Default: "1"
sm_namereserve_kickwarnamount "1"
// Message displayed to the user with each warning when a kick is pending. {rn} will be replaced by the reserved name.
// -
// Default: "If you don't change your name, you're gonna be kicked ({rn} is reserved)"
sm_namereserve_kickwarnmsg "If you don't change your name, you're gonna be kicked ({rn} is reserved)"
// The text to append to a user's name if it's reserved
// -
// Default: " (imposter)"
sm_namereserve_namesuffix " (imposter)"
// The punishment type to use when someone uses a reserved name. (0 = append suffix, 1= rename, 2 = kick)
// -
// Default: "0"
sm_namereserve_punishtype "0"
// The message shown to the user to let them know they've been renamed. {rn} will be replaced with the reserved name.
// -
// Default: "You were renamed to avoid admin confusion <3 ({rn} is reserved)"
sm_namereserve_renamemsg "You were renamed to avoid admin confusion <3 ({rn} is reserved)"
// Whether or not to inform the user that they've been renamed
// -
// Default: "1"
sm_namereserve_showrenamemsg "1"
// NameReserve version
// -
// Default: "1.2.2"
sm_namereserve_version "1.2.2"
Changelog:
Code:
2010-12-2 (v1.0.0)
- Initial release
2010-12-2 (v1.1.0)
- Added "Punishment types", so that rather than only appending a suffix on a player using a restricted name, they can now be entirely renamed or kicked
2010-12-2 (v1.1.1)
- Typo fix in one of the cvar comments, added a couple logging statements for debug
2010-12-3 (v1.2.0)
- Added support for partial name matching; also added cvar support to output the reserved name that was flagged to output to the user. (see cvars section)
2010-12-4 (v1.2.1)
- Added admins flag cvar to allow more specific immunity (rather than just generic admin checks)
2010-12-4(v1.2.2)
- Added config support for specifying admin flag immunity per name (the global cvar takes precedence)
Installation:
Installation is easy!
Drop namereserve.smx to your sourcemod/plugins directory.
Drop namereserve.cfg to your sourcemod/configs directory and edit as desired.
Sample Config:
In your configuration file, you list out the names which are reserved and the associated steam IDs that are allowed to use them. Set "isPartial "1" for partial matches. To have admin immunity per name (so you don't need to list steamIds), set "adminFlag" "b" (or whatever flag). Note that the admin flag cvar overrides anything set via config.
Code:
"Names"
{
"TheSpy"
{
// specify each user, e.g. user1, user2, etc
"user1"
{
"id" "steamid"
}
"user2"
{
"id" "steamid"
}
}
"TheEngineer"
{
"adminFlag" "a"
"user1"
{
"id" "steamid"
}
}
"morenames..."
{
}
"partialname"
{
"isPartial" "1"
// list users
}
}
Future ideas:
- Add rename monitoring support. Right now the plugin only renames a user when they connect; I didn't want to tackle monitoring renames and throttling the plugin to prevent rename spam in game. If there's demand for this I'll investigate it further but for now I left this out.
- Allow partial matching, e.g. for clan tag support done!
- Add cvar for admin flag (right now it's hard-coded to any admin) done!
- Add config level admin flags, e.g. to allow a particular name to have access granted for kick flag, and another for root done!
Thanks
Woo for IRC: A little thanks to thorrr and flaminsarge on irc for responding to a few questions I had on keyvalues, and to FlyingMongoose and asherkin for cvar questions :) And to Atreus for early feedback :P