Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[----------------------------------
- ULX Command Cooldown
- Originally coded by: Cobalt
- Updated by: lynx
- Updated: March 3, 2014
- ----------------------------------]]--
- ulx.groupcooldown = {}
- --[[ Begin Configuration Section ]]--
- -- ulx.groupcooldown.default
- -- This sets the default cooldown for groups not listed in the grouplist.
- ulx.groupcooldown.default = 15
- -- ulx.groupcooldown.grouplist
- -- This list defines the cooldown times for the groups. If a group is unlisted and not on the whitelist, it will default to default above.
- -- This is a table. Please follow the example when adding groups.
- ulx.groupcooldown.grouplist = {
- -- All groups must be formatted as followed:
- -- "superadmin" = 5,
- "superadmin" = 3,
- "admin" = 5,
- "operator" = 10,
- }
- -- ulx.groupcooldown.whitelist
- -- Groups and Steam ID's defined in this list are exempt from the command cooldown regardless if their group is listed above.
- ulx.groupcooldown.whitelist = { "owner", "developer", "superadmin", "STEAM_0:0:0", "STEAM_0:0:29798183" }
- -- ulx.groupcooldown.message
- -- This is the message dispalyed to the user. A second message will inform them of the time they have remaining to wait.
- ulx.groupcooldown.message = "You are not allowed to do that right now."
- --[[ End Configuration. Please do not modify anything below this line otherwise stuff will break. ]]--
- function ulx.CmdCooldown(ply, cmd, args)
- if table.HasValue( ulx.groupcooldown.whitelist, ply:SteamID() ) or table.HasValue( ulx.groupcooldown.whitelist, ply:GetUserGroup() ) then
- return
- end
- if not ply.NextCommand or ply.NextCommand <= CurTime() then
- ply.NextCommand = CurTime() + ( ulx.groupcooldown.grouplist[ply:GetUserGroup()] or ulx.groupcooldown.default )
- end
- if ply.NextCommand > CurTime() then
- local nextCmd = ply.NextCommand - CurTime()
- ULib.tsay( ply, ulx.groupcooldown.message )
- ULib.tsay( ply, string.format( "You have %s seconds to wait before you can use a command again.", math.floor(nextCmd) ) )
- return false
- end
- end
- timer.Simple( 3, function()
- hook.Add( "ULibCommandCalled", "CheckCommands", ulx.CmdCooldown )
- end )
Advertisement
Add Comment
Please, Sign In to add comment