forked from HaodongMo/ArcCW
detach owner sanity check
This commit is contained in:
parent
b555464d49
commit
ac3f1ff1f8
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user