CapsAdmin

Untitled

Mar 19th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. local cvar = CreateConVar("allow_attack", "1")
  2. local once
  3.  
  4. local whitelist =
  5. {
  6.     "weapon_physgun",
  7. }
  8.  
  9. local function Allow(bool)
  10.     for key, ply in pairs(player.GetAll()) do
  11.         for key, wep in pairs(ply:GetWeapons()) do
  12.             if not table.HasValue(whitelist, wep:GetClass()) then
  13.                 local t = bool and CurTime() or CurTime() + 10
  14.                
  15.                 wep:SetNextPrimaryFire(t)
  16.                 wep:SetNextSecondaryFire(t)
  17.             end
  18.         end
  19.     end    
  20. end
  21.  
  22. timer.Create("allow_attack", 0, 0, function()
  23.     local A = cvar:GetBool()
  24.    
  25.     if A then
  26.         if not once then
  27.             Allow(true)
  28.             once = true
  29.         end
  30.     else
  31.         Allow(false)
  32.         once = nil
  33.     end
  34. end)
Advertisement
Add Comment
Please, Sign In to add comment