detach owner sanity check

This commit is contained in:
TheOnly8Z 2023-11-22 18:52:52 -08:00
parent b555464d49
commit ac3f1ff1f8
2 changed files with 4 additions and 2 deletions

View File

@ -4,6 +4,9 @@ function ArcCW:PlayerCanAttach(ply, wep, attname, slot, detach)
-- The global variable takes priority over everything
if !ArcCW.EnableCustomization then return false end
-- Attach and Detach require a player (usually the owner)
if !IsValid(ply) then return false end
-- Spectators taking off your attachments is funny, but also cursed
if wep:GetOwner() != ply then return false end

View File

@ -1293,12 +1293,11 @@ function SWEP:Detach(slot, silent, noadjust, nocheck)
local ammo = atttbl.UBGL_Ammo or "smg1_grenade"
if SERVER then
if SERVER and IsValid(self:GetOwner()) then
self:GetOwner():GiveAmmo(clip, ammo, true)
end
self:SetClip2(0)
self:DeselectUBGL()
end