From e8246521dcce4ceb557545fff82c67c7ad78422f Mon Sep 17 00:00:00 2001 From: Denneisk <20892685+Denneisk@users.noreply.github.com> Date: Fri, 6 Oct 2023 05:33:26 +0000 Subject: [PATCH] Allow constraints with world entity (#2782) * Add world to isOwner check in checkEnts * nil check * Changes --- .../core/custom/constraintcore.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/custom/constraintcore.lua b/lua/entities/gmod_wire_expression2/core/custom/constraintcore.lua index d6cd5e109b..377e223a15 100644 --- a/lua/entities/gmod_wire_expression2/core/custom/constraintcore.lua +++ b/lua/entities/gmod_wire_expression2/core/custom/constraintcore.lua @@ -91,11 +91,17 @@ local countLookup = { local function checkEnts(self, ent1, ent2) - if not IsValid(ent1) and not ent1:IsWorld() then return self:throw("Invalid entity!", false) end - if not IsValid(ent2) and not ent2:IsWorld() then return self:throw("Invalid target entity!", false) end + if not ent1 or not ent2 then return self:throw("Invalid entity!", false) end - if not isOwner(self, ent1) then return self:throw("You are not the owner of the entity!", false) end - if not isOwner(self, ent2) then return self:throw("You are not the owner of the target entity!", false) end + if not ent1:IsWorld() then + if not ent1:IsValid() then return self:throw("Invalid entity!", false) end + if not isOwner(self, ent1) then return self:throw("You are not the owner of the entity!", false) end + end + + if not ent2:IsWorld() then + if not ent2:IsValid() then return self:throw("Invalid target entity!", false) end + if not isOwner(self, ent2) then return self:throw("You are not the owner of the target entity!", false) end + end if ent1:IsPlayer() or ent2:IsPlayer() then return self:throw("Cannot constrain players!", false) end return true