Guest User

Untitled

a guest
Feb 22nd, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. -- add all usergroups here with cooldown times
  2. local groups = {}
  3. groups.admin = 10
  4. groups.superadmin = 5
  5. groups.owner = 3
  6.  
  7. -- groups who shouldnt be affected by a cooldown
  8. local blacklist = { "owner", "superadmin" }
  9.  
  10. timer.Simple( 10, function()
  11.     hook.Add( "ULibCommandCalled", "CheckCommands", function( ply, cmd, args )
  12.         if table.HasValue( blacklist, ply:GetUserGroup() ) then
  13.             return
  14.         end
  15.         if not ply.cooldown or ply.cooldown <= 0 then
  16.             ply.cooldown = groups[ ply:GetUserGroup() ]
  17.         else
  18.             ply:ChatPrint( "Please wait " .. tostring( ply.cooldown ) .. " more seconds before you use a command again." )
  19.             return false
  20.         end
  21.     end )
  22. end )
  23.  
  24. timer.Create( "Cooldown", 1, 0, function()
  25.     for k, v in next, player.GetAll() do
  26.         if v.cooldown then
  27.             if v.cooldown > 0 then
  28.                 v.cooldown = v.cooldown - 1
  29.                 if v.cooldown == 0 then
  30.                     v.cooldown = nil
  31.                 end
  32.             elseif v.cooldown <= 0 then
  33.                 v.cooldown = nil
  34.             end
  35.         end
  36.     end
  37. end )
Advertisement
Add Comment
Please, Sign In to add comment