From e76ed5239a55cdb3d765d1b105a98bc19ac33195 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Sat, 4 Jan 2025 03:17:30 +0300 Subject: [PATCH] Fix invalid return of of e:weapon() --- lua/entities/gmod_wire_expression2/core/weapon.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/weapon.lua b/lua/entities/gmod_wire_expression2/core/weapon.lua index 1ed134604d..d10ce24f72 100644 --- a/lua/entities/gmod_wire_expression2/core/weapon.lua +++ b/lua/entities/gmod_wire_expression2/core/weapon.lua @@ -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