CapsAdmin

Untitled

Jun 1st, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 KB | None | 0 0
  1. local PART = {}
  2.  
  3. PART.ClassName = "event"
  4. PART.HideGizmo = true
  5.  
  6. PART.Events =
  7. {
  8.     velocity = function(owner, self)
  9.         local num = tonumber(self.Arguments)
  10.         if num and owner:GetVelocity():Length() > num then
  11.             return true
  12.         end
  13.     end,
  14.  
  15.     on_fire = net and (function(owner)
  16.         return owner:IsOnFire()
  17.     end) or nil,
  18.  
  19.     flashlight = function(owner)
  20.         if owner:IsPlayer() and owner:FlashlightIsOn() then
  21.             return true
  22.         end
  23.     end,
  24.    
  25.     voice_chat = function(owner)
  26.         if owner:IsPlayer() and owner:IsSpeaking() then
  27.             return true
  28.         end
  29.     end,
  30.  
  31.     primary_ammo_empty = function(owner)
  32.         local wep = owner:GetActiveWeapon()
  33.         if wep:IsValid() and wep:Clip1() == 0 then
  34.             return true
  35.         end
  36.     end,
  37.    
  38.     secondary_ammo_empty = function(owner)
  39.         local wep = owner:GetActiveWeapon()
  40.         if wep:IsValid() and wep:Clip2() == 0 then
  41.             return true
  42.         end
  43.     end,
  44.    
  45.     on_ground = function(owner)
  46.         if owner:IsPlayer() and owner:IsOnGround() then
  47.             return true
  48.         end
  49.     end,
  50.    
  51.     under_water = function(owner, self)
  52.         local num = tonumber(self.Arguments) or 3
  53.  
  54.         if owner:WaterLevel() > num then
  55.             return true
  56.         end
  57.     end,
  58. }
  59.  
  60. function PART:Think()
  61.     local owner = self:GetOwner()
  62.    
  63.     if owner:IsValid() then
  64.         local func = self.Events[self.Event]
  65.        
  66.         if func then
  67.             local parent = self:GetParent()
  68.             if parent:IsValid() then
  69.                 if self.Invert then
  70.                     parent.EventHide = not (func(owner, self) or false)
  71.                 else
  72.                     parent.EventHide = (func(owner, self) or false)
  73.                 end
  74.             end
  75.         end
  76.     end
  77. end
  78.  
  79. function PART:Initialize()
  80.     self.StorableVars = {}
  81.    
  82.     pac.StartStorableVars()
  83.         pac.GetSet(self, "Name", "")
  84.         pac.GetSet(self, "Description", "")
  85.         pac.GetSet(self, "Hide", false)
  86.         pac.GetSet(self, "Event", "")
  87.         pac.GetSet(self, "Arguments", "")
  88.         pac.GetSet(self, "Invert", false)
  89.     pac.EndStorableVars()
  90. end
  91.  
  92. pac.RegisterPart(PART)
Advertisement
Add Comment
Please, Sign In to add comment