This plugin allows server operators to set a cooldown on any command, without editing the plugin's code and recompiling. The cooldowns do not apply to the server console (or rcon, sm_rcon, ServerCommand(), etc.)
Commands to set cooldowns on must be specified in addons/sourcemod/configs/commandCooldowns.txt. The file utilizes standard KeyValues structure, and should look as follows:
Code:
"CommandCooldowns"{"sm_command sm_someothercommand"//Here, you specify what commands to apply the single cooldown to. Commands are seperated with a space,//and SHARE a cooldown.{"cooldown""10"//The time it takes for the command(s) to be usable again. This is the only mandatory key."override""some_Command_or_Override"//A player with access to the command or override listed here can bypass the cooldown."flags""abcdefghijklmnopqrstz"//If no "override" is specified, or the override cannot be found, these flags are used instead for//cooldown bypass. The user must have all of these flags to bypass the cooldown (or just the 'z' flag).//In short://* If you specify an override that exists (either as an actual override or a command), then that override's access level will be// used as the access requirement for cooldown bypass.//* If you specify neither a flag NOR an overrride, then no one can get around the cooldown, not even root admins.//* If you specify an override that doesn't exist, and DO NOT specify any flags, then EVERYONE can get around the cooldown."reset""1"//If "reset" is set to 1, the cooldown will RESTART if the user tries to use it too early.//For example, if a command has a 10 second cooldown, and a player uses the command once, and then once//again after only 4 seconds, then 6 seconds will be added to the cooldown.//Leaving out the "reset" line entirely is the same as putting a "0" in there."shared""1"//If "shared" is set to "1", then the cooldown timer is SHARED BETWEEN ALL PLAYERS.//This means that, assuming a command has a 60 second cooldown, once a player uses that command,//HE AND ALL OTHER PLAYERS will have to wait 60 seconds before using that command.//Leaving out the "shared" line entirely is the same as putting a "0" in there.//It might not be a good idea to use both "shared" and "reset" together on one cooldown."disabled""1"//If set, the cooldown will be stored, but won't actually do anything. This will be useful in a future update."reply""{unusual}hahaha!{default} you must wait {TIMELEFT} seconds before using {COMMAND_NAME} again!"//This is the message that the user will see when trying to use the command too soon. This is run through ReplyToCommand();//If you do not specify this, the default text is "You must wait {TIMELEFT} seconds!"//Putting nothing ( "" ) between the quotation marks will disable the reply entirely. "showactivity""tried to use {COMMAND_NAME} too early and got slayed!"//Anything set here will be run through CShowActivity2. Syntax is "servercmd""sm_slay #{USERID}"//Command to be run by the server when a user uses the command too soon."clientcmd""say I'm a huge dummy"//Command to be run by the user (through FakeClientCommand()) when using the command too soon.//"reply", "showactivity", "servercmd", and "clientcmd" all support the following text substitutions//{TIMELEFT} will be replaced by the number of seconds left on the cooldown//{COMMAND_NAME} will be replaced by the command that was used, which is useful if more than 1 command is sharing the cooldown.//{COOLDOWN_TIME} will be replaced by the total length of the cooldown//{USERID} will be replaced by the user's user ID according to the engine.//{USERNAME} will be replaced by the user's current display name on the server.//"reply" and "showactivity" both support colors through morecolors.inc"plugin""somePlugin.smx"//The "plugin" key is only to be used if the command you want to apply a cooldown to was created through//AddCommandListener() rather than a Reg*Cmd() function. If you notice that players bypass the cooldown, but//they are still able to see the "reply", you will need to specify the plugin here.//The plugin that is listed here will be RESTARTED once CommandCooldowns finished loading the txt file//(depending on the setting of the cvar sm_commandcooldowns_reloadplugins). This is necessary because//CommandCooldowns must register the command listener BEFORE the other plugin does, or the cooldown will not work.}"sm_someThirdCommand"{"cooldown""4.4"// etc...}//etc...}
"CommandCooldowns"{"sm_noclip"{"cooldown""10""override""noclip_bypasscooldown"}"sm_god sm_buddha"{"cooldown""5""flags""k"}"sm_resizemyhead"{"cooldown""15""override""sm_resizehead""flags""a"}"sm_pumpkin sm_ipumpkin"{"cooldown""5.5""reply"""}"sm_nukem"{"cooldown""600""reply""haha you have to wait {green}{TIMELEFT}{default} seconds before using another {unusual}nuke""shared""1"}"someListenCommand"//this command was "created" with AddCommandListener, and not Reg*Cmd{"cooldown""7""plugin""somePlugin.smx"}"otherListenCommand"//this command was "created" with AddCommandListener, and not Reg*Cmd{"cooldown""25.5""flags""bg"}"sm_bonkme sm_scareme sm_stunme sm_gstunme"{"cooldown""10""override""sm_bonk""reset""1""reply""you must wait {TIMELEFT} seconds before using {COMMAND_NAME}!"}"sm_reloadadmins"{"cooldown""30""shared""1"}"sm_randomCommand"{"cooldown""10""showactivity""tried to use {COMMAND_NAME} too soon!""servercmd""sm_slay #{USER_ID}"}"sm_someSillyCommand"{"cooldown""10""clientcmd""say I'm a big dummy butt"}}
In the above example, 9 cooldowns of various lengths have been created.
sm_noclip has been given a cooldown of 10 seconds.
Any user with access to the override "noclip_bypasscooldown" will be able to get around the cooldown.
Since no "flags" have been specified, if "noclip_bypasscooldown" cannot be found in the overrides, EVERYONE will be able to get around the cooldown.
sm_god and sm_buddha have been given a cooldown of 5 seconds.
If a player uses one of the commands, he must wait the 5 seconds to use EITHER command.
Any user with the 'K' flag (or the Z flag, obviously) can bypass the cooldown.
sm_resizemyhead has been given a cooldown of 15 seconds.
Any user who can use sm_resizehead can get around the cooldown.
If sm_resizehead does not exist, then the 'a' flag is used instead.
sm_pumpkin and sm_ipumpkin have been given a cooldown of 5 and a half seconds.
The two commands share the same cooldown, just like sm_god and sm_buddha did earlier in this example.
No override/flag information has been specified, so no one can get around the cooldown other than the console.
Because a blank "reply" keyvalue was set, the user will NOT see any notification that their command was blocked.
sm_nukem has been given a cooldown of 600 seconds.
Rather than displaying the default message of "You must wait X seconds!" the reply is instead the silly "haha" message. On games that support these colors, the time left will be the color green, and the word "nuke" will be purple-ish.
Because "shared" has been set to "1", if a player uses the nuke, he and all other players will need to wait 600 seconds before using it again.
Again, because no override or flag information was set, only the console can get around the cooldown.
someListenCommand has been given a cooldown of 7 seconds.
No override/flag information has been given, so no one will be able to bypass the cooldown other than the console.
When commandCooldowns.smx is loaded, it will cause somePlugin.smx to be reloaded (assuming that sm_commandcooldowns_reloadplugins = 1). This ensures that the cooldown time will be checked BEFORE the actual command code is executed. Specifying "plugin" is only necessary when the command has been registered with AddCommandListener.
otherListenCommand has been given a cooldown of 25.5 seconds.
Users with BOTH the 'b' and 'g' flags (or just the 'z' flag) can bypass the cooldown.
The plugin that created this command did so by using AddCommandListener. Because of this, and because of the fact that "plugin" has not been specified, if commandCooldowns.smx loads after the other plugin, the cooldown will not work.
sm_bonkme, sm_scareme, sm_stunme, and sm_gstunme have all been given a cooldown of 10 seconds.
Anyone with access to sm_bonk can bypass this cooldown.
Because of the "reset" keyvalue, the user's cooldown will be RESTARTED if the command is blocked. If he keeps trying to use one of these commands before the cooldown is over, he will be indefinitely prevented from using it.
All 4 commands share the same cooldown. If he uses sm_bonkme, he will need to wait 10 seconds before using ANY of these 4 commands.
When the command is blocked, the user will see "you must wait 10 seconds before using sm_gstunme!" or something similar.
sm_reloadadmins has been given a cooldown of 30 seconds.
No one can get around the cooldown other than the console.
When one player uses this command, all players must wait 30 seconds before it can be used again.
When the command is blocked, the user will see the default message.
sm_randomCommand has been given a cooldown of 10 seconds.
No one can get around the cooldown other than the console.
Others will be notified that the player tried to use the command before the cooldown was up, due to use of "showactivity"
The server will run sm_slay on the user.
sm_someSillyCommand has been given a cooldown of 10 seconds.
In addition to all the other stuff happening and/or not happening that you'd expect by now, the server will also force the player to say "I'm a big dummy butt" in the chat
The plugin has one command: sm_commandcooldowns_reload. This command will cause the plugin to reload the cooldowns config file.
"sm_commandcooldowns_reload 1" will cause the plugins specified in the "plugin" key to be reloaded.
"sm_commandcooldowns_reload 0" will cause them to NOT be reloaded.
Any other argument (or a lack of an argument) will tell the plugin to use the "default" setting, which you can specify with the cvar "sm_commandcooldowns_reloadplugins" (0/1)
This plugin supports automatic updating through Updater. Please consider installing Updater, if you haven't already. Automatic updating can be disabled by setting sm_commandcooldowns_update to "0". The plugin does NOT require Updater to function.