Monthly Target: $400 Donations: $140
 35% 

Notices

[Any] Command Cooldowns


Post New Thread Reply   
 
Thread Tools Display Modes
Author
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Plugin ID:
4098
Plugin Version:
14.0926
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    106 
    Plugin Description:
    Allows server ops to set a cooldown on any registered command.
    Old 02-15-2014 , 23:12   [Any] Command Cooldowns
    Reply With Quote #1

    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.         "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.         //All instances of {TIMELEFT} will be replaced by the number of seconds left on the cooldown, and         //all instances of {COMMAND_NAME} will be replaced by the command that was used, which is useful if         //more than 1 command is sharing the cooldown. The reply supports colors through morecolors.inc. Putting         //nothing ( "" ) between the quotation marks will disable the reply entirely. Not putting in the "reply" line         //at all will tell the plugin to use the default message, which is "You must wait {TIMELEFT} seconds!"         "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.                 "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... }

    HERE IS AN EXAMPLE OF A CONFIG:
    Spoiler


    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.

    Compiling the .sp requires these includes:

    DOWNLOADS:
    If you like what you see here, please consider donating~
    __________________

    Last edited by ddhoward; 10-16-2014 at 01:16.
    ddhoward is offline
    Fearts
    ferts of daeth
    Join Date: Oct 2008
    Old 02-16-2014 , 00:15   Re: [Any] Command Cooldowns
    Reply With Quote #2

    Nice idea
    __________________
    Fearts is offline
    Snaggle
    AlliedModders Donor
    Join Date: Jul 2010
    Location: England
    Old 02-16-2014 , 01:20   Re: [Any] Command Cooldowns
    Reply With Quote #3

    Good idea I'm sure it will be useful for a lot of things.
    Snaggle is offline
    Root_
    Veteran Member
    Join Date: Jan 2012
    Location: ryssland
    Old 02-18-2014 , 05:02   Re: [Any] Command Cooldowns
    Reply With Quote #4

    Nice replacement of this plugin.
    You can use command listener as SMAC does. Just AddCommandListener(Commands_CommandListener); , get CmdArgs in listener callback and compare with CommandCooldowns list.
    __________________


    dodsplugins.com - Plugins and Resources for Day of Defeat
    http://twitch.tv/zadroot
    Root_ is offline
    ddhoward
    Veteran Member
    Join Date: May 2012
    Location: California
    Old 02-18-2014 , 05:16   Re: [Any] Command Cooldowns
    Reply With Quote #5

    Didn't realize that AddCommandListener's second argument was optional. Not sure if I'd be able to completely replace OnClientCommand with it though. Looking into it now.
    __________________

    Last edited by ddhoward; 02-18-2014 at 05:16.
    ddhoward is offline
    ddhoward
    Veteran Member
    Join Date: May 2012
    Location: California
    Old 02-18-2014 , 06:55   Re: [Any] Command Cooldowns
    Reply With Quote #6

    It seems like it is going to work, but I'm not sure how to guarantee that THIS plugin's AddCommandListener callback will be called before the command's itself. Mine would obviously need to be called first, in order to return Plugin_Stop, right?
    __________________
    ddhoward is offline
    Root_
    Veteran Member
    Join Date: Jan 2012
    Location: ryssland
    Old 02-18-2014 , 08:47   Re: [Any] Command Cooldowns
    Reply With Quote #7

    Quote:
    Originally Posted by ddhoward View Post
    ... in order to return Plugin_Stop, right?
    Correct.
    __________________


    dodsplugins.com - Plugins and Resources for Day of Defeat
    http://twitch.tv/zadroot
    Root_ is offline
    ddhoward
    Veteran Member
    Join Date: May 2012
    Location: California
    Old 02-18-2014 , 15:21   Re: [Any] Command Cooldowns
    Reply With Quote #8

    Okay, I guess my next question is: is the CommandListener callback guaranteed to be called before the Reg*Command one? I'm thinking yes.
    __________________

    Last edited by ddhoward; 02-18-2014 at 15:21.
    ddhoward is offline
    ddhoward
    Veteran Member
    Join Date: May 2012
    Location: California
    Old 02-22-2014 , 16:55   Re: [Any] Command Cooldowns
    Reply With Quote #9

    Updated~~~
    __________________
    ddhoward is offline
    cool_myll
    SourceMod Donor
    Join Date: Aug 2011
    Old 02-22-2014 , 19:28   Re: [Any] Command Cooldowns
    Reply With Quote #10

    Can anything be done for client commands? eg fov_desired trick to zoom with spy weapons
    __________________
    cool_myll is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 14:27.


    Powered by vBulletin®
    Copyright ©2000 - 2017, vBulletin Solutions, Inc.
    Theme made by Freecode