Check, in case mag disappears somehow

This commit is contained in:
Fesiug 2023-11-29 02:51:43 -05:00
parent 4bc66529f1
commit 3d55f6c7d7
1 changed files with 5 additions and 1 deletions

View File

@ -107,7 +107,11 @@ function SWEP:Reload( hand )
local mid = self:D_GetMagID( hand )
if SERVER or (CLIENT and IsFirstTimePredicted()) then
if mid != "" then
if inv[mid].Ammo == 0 then
if !inv[mid] then
ErrorNoHalt( "Mag isn't a valid item" )
self:D_SetMagID( hand, "" )
wep_table.Loaded = ""
elseif inv[mid].Ammo == 0 then
if SERVER or (CLIENT and IsFirstTimePredicted()) then
p:INV_Discard( mid )
end