Guest User

Untitled

a guest
Mar 3rd, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[----------------------------------
  2. ULX Command Cooldown
  3. Originally coded by: Cobalt
  4. Updated by: lynx
  5. Updated: March 3, 2014
  6. ----------------------------------]]--
  7. ulx.groupcooldown = {}
  8.  
  9. --[[ Begin Configuration Section ]]--
  10.  
  11. -- ulx.groupcooldown.default
  12. -- This sets the default cooldown for groups not listed in the grouplist.
  13. ulx.groupcooldown.default = 15
  14.  
  15. -- ulx.groupcooldown.grouplist
  16. -- 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.
  17. -- This is a table. Please follow the example when adding groups.
  18. ulx.groupcooldown.grouplist = {
  19.     -- All groups must be formatted as followed:
  20.     -- "superadmin" = 5,
  21.     "superadmin" = 3,
  22.     "admin" = 5,
  23.     "operator" = 10,
  24. }
  25.  
  26. -- ulx.groupcooldown.whitelist
  27. -- Groups and Steam ID's defined in this list are exempt from the command cooldown regardless if their group is listed above.
  28. ulx.groupcooldown.whitelist = { "owner", "developer", "superadmin", "STEAM_0:0:0", "STEAM_0:0:29798183" }
  29.  
  30. -- ulx.groupcooldown.message
  31. -- This is the message dispalyed to the user. A second message will inform them of the time they have remaining to wait.
  32. ulx.groupcooldown.message = "You are not allowed to do that right now."
  33.  
  34. --[[ End Configuration. Please do not modify anything below this line otherwise stuff will break. ]]--
  35.  
  36. function ulx.CmdCooldown(ply, cmd, args)
  37.     if table.HasValue( ulx.groupcooldown.whitelist, ply:SteamID() ) or table.HasValue( ulx.groupcooldown.whitelist, ply:GetUserGroup() ) then
  38.         return
  39.     end
  40.    
  41.     if not ply.NextCommand or ply.NextCommand <= CurTime() then
  42.         ply.NextCommand = CurTime() + ( ulx.groupcooldown.grouplist[ply:GetUserGroup()] or ulx.groupcooldown.default )
  43.     end
  44.    
  45.     if ply.NextCommand > CurTime() then
  46.         local nextCmd = ply.NextCommand - CurTime()
  47.         ULib.tsay( ply, ulx.groupcooldown.message )
  48.         ULib.tsay( ply, string.format( "You have %s seconds to wait before you can use a command again.", math.floor(nextCmd) ) )
  49.         return false
  50.     end
  51. end
  52.  
  53. timer.Simple( 3, function()
  54.     hook.Add( "ULibCommandCalled", "CheckCommands", ulx.CmdCooldown )
  55. end )
Advertisement
Add Comment
Please, Sign In to add comment