diff --git a/beatrun/gamemodes/beatrun/entities/weapons/shapedrawer/shared.lua b/beatrun/gamemodes/beatrun/entities/weapons/shapedrawer/shared.lua index 655280c..b661ae3 100644 --- a/beatrun/gamemodes/beatrun/entities/weapons/shapedrawer/shared.lua +++ b/beatrun/gamemodes/beatrun/entities/weapons/shapedrawer/shared.lua @@ -67,7 +67,7 @@ end function SWEP:PrimaryAttack() self:CallOnClient("PrimaryAttack") - local ply = self.Owner + local ply = self:GetOwner() if not self.points[#self.points] or (ply:EyePos() + ply:EyeAngles():Forward() * 50):Distance(self.points[#self.points]) > 5 then table.insert(self.points, ply:EyePos() + ply:EyeAngles():Forward() * 50) @@ -77,17 +77,21 @@ end function SWEP:SecondaryAttack() self:CallOnClient("SecondaryAttack") - local ply = self.Owner + local ply = self:GetOwner() self.center:Set(ply:GetEyeTrace().HitPos) end hook.Add("PostDrawTranslucentRenderables", "ShapeGun", function() - local ply = Entity(1) - local wep = ply:GetActiveWeapon() or nil + local ply = self:GetOwner() - if IsValid(wep) and wep:GetClass() == "shapedrawer" then - for k, v in ipairs(wep.points) do + if not ply:IsValid() then return end + + local wep = ply:GetActiveWeapon() + local isShapeDrawer = wep:GetClass() == "shapedrawer" + + if IsValid(wep) and isShapeDrawer then + for _, v in ipairs(wep.points) do render.DrawWireframeBox(v, angle_zero, Vector(-1, -1, -1), Vector(1, 1, 1)) end