Fix invalid return of of e:weapon() (#3238)

This commit is contained in:
Astralcircle 2025-01-04 05:05:40 +03:00 committed by GitHub
parent 45c2987bbc
commit 886ef66aa9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,16 +14,16 @@ __e2setcost(2) -- temporary
[nodiscard]
e2function entity entity:weapon()
if not IsValid(this) then return nil end
if not this:IsPlayer() and not this:IsNPC() then return nil end
if not IsValid(this) then return self:throw("Invalid entity!", NULL) end
if not this:IsPlayer() and not this:IsNPC() then return self:throw("Expected a Player or NPC but got Entity", NULL) end
return this:GetActiveWeapon()
end
[nodiscard]
e2function entity entity:weapon(string weaponclassname)
if not IsValid(this) then return nil end
if not this:IsPlayer() and not this:IsNPC() then return nil end
if not IsValid(this) then return self:throw("Invalid entity!", NULL) end
if not this:IsPlayer() and not this:IsNPC() then return self:throw("Expected a Player or NPC but got Entity", NULL) end
return this:GetWeapon(weaponclassname)
end