Guest User

Entity - Shared.lua

a guest
Oct 18th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. ENT.Type = "anim"
  2. ENT.Model = Model("models/valkyrie_camera/valkyrie_camera.mdl")
  3.  
  4. AccessorFunc(ENT, "Placer", "Placer")
  5. AccessorFunc(ENT, "PlacedBy", "PlacedBy")
  6.  
  7. function ENT:Initialize()
  8.     if (IsValid(self)) then
  9.         self:SetModel(self.Model)
  10.  
  11.         if SERVER then
  12.             self:PhysicsInit(SOLID_VPHYSICS)
  13.             self:SetMoveType(MOVETYPE_VPHYSICS)
  14.         end
  15.         self:SetSolid(SOLID_VPHYSICS)
  16.         self:SetCollisionGroup(COLLISION_GROUP_WEAPON)
  17.  
  18.         if SERVER then
  19.             self:SetUseType(SIMPLE_USE)
  20.             self:SetMaxHealth(10)
  21.         end
  22.         self:SetHealth(10)
  23.  
  24.         self:Activate()
  25.     end
  26. end
  27.  
  28. function ENT:Use(activator)
  29.     print("ENT:Use")
  30.     print(activator)
  31.  
  32.     if IsValid(self) and IsValid(activator) and activator:IsPlayer() then
  33.         local owner = self:GetPlacer()
  34.         if owner == activator then
  35.             if activator:HasWeapon("weapon_valkyrie_camera") then
  36.                 local weapon = activator:GetWeapon("weapon_valkyrie_camera")
  37.                 weapon:SetClip1(weapon:Clip1() + 1)
  38.             else
  39.                 local weapon = activator:Give("weapon_valkyrie_camera")
  40.                 weapon:SetClip1(1)
  41.             end
  42.            
  43.             if activator:HasWeapon("weapon_valkyrie_camera") then
  44.                 self:Remove()
  45.             end
  46.         end
  47.     end
  48. end
  49.  
  50. function ENT:Think()
  51.     -- if thrower disconnects while the camera is active, remove it
  52.     if SERVER and (not IsValid(self:GetPlacer())) then
  53.         self:Remove()
  54.         return
  55.     end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment