From 624c39890a3a56c6472df5847d30f9d0fad13bf6 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Wed, 30 Sep 2026 23:56:39 +0300 Subject: [PATCH 1/2] Disallow damaging players via E2 until you cantool them or you are admin Allows this function to be enabled on servers while preventing abuse such as killing every player on the server --- lua/entities/gmod_wire_expression2/core/damage.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/entities/gmod_wire_expression2/core/damage.lua b/lua/entities/gmod_wire_expression2/core/damage.lua index 92e450b2d5..b556e6b354 100644 --- a/lua/entities/gmod_wire_expression2/core/damage.lua +++ b/lua/entities/gmod_wire_expression2/core/damage.lua @@ -109,6 +109,7 @@ e2function void entity:takeDamage(number amount) if not Enabled:GetBool() then return self:throw("Dealing damage is disabled via wire_expression2_damage_enabled") end if not IsValid(this) then return self:throw("Invalid entity!", nil) end if not WireLib.CanDamage(self.player, this) then return self:throw("You cannot damage this entity!", nil) end + if this:IsPlayer() and not E2Lib.isFriend(self.player, this) and not WireLib.CanTool(self.player, this, "wire_expression2") then return self:throw("You cannot damage this player!", nil) end this:TakeDamage(amount, self.player, self.entity) end @@ -119,6 +120,7 @@ e2function void entity:takeDamage(number amount, entity attacker) if not IsValid(attacker) then return self:throw("Invalid attacker entity!", nil) end if not E2Lib.isOwner(self, attacker) then return self:throw("You do not own the attacker entity!", nil) end if not WireLib.CanDamage(self.player, this) then return self:throw("You cannot damage this entity!", nil) end + if this:IsPlayer() and not E2Lib.isFriend(self.player, this) and not WireLib.CanTool(self.player, this, "wire_expression2") then return self:throw("You cannot damage this player!", nil) end this:TakeDamage(amount, attacker, self.entity) end @@ -131,6 +133,7 @@ e2function void entity:takeDamage(number amount, entity attacker, entity inflict if not IsValid(inflictor) then return self:throw("Invalid inflictor entity!", nil) end if not E2Lib.isOwner(self, inflictor) then return self:throw("You do not own the inflictor entity!", nil) end if not WireLib.CanDamage(self.player, this) then self:throw("You cannot damage this entity!", nil) end + if this:IsPlayer() and not E2Lib.isFriend(self.player, this) and not WireLib.CanTool(self.player, this, "wire_expression2") then return self:throw("You cannot damage this player!", nil) end this:TakeDamage(amount, attacker, inflictor) end From 7716a154a3458a8c9f08f9baaabb0bea888cdd31 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Wed, 30 Sep 2026 23:57:58 +0300 Subject: [PATCH 2/2] Fix issue that i noticied --- lua/entities/gmod_wire_expression2/core/damage.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/core/damage.lua b/lua/entities/gmod_wire_expression2/core/damage.lua index b556e6b354..8eab3806ed 100644 --- a/lua/entities/gmod_wire_expression2/core/damage.lua +++ b/lua/entities/gmod_wire_expression2/core/damage.lua @@ -132,7 +132,7 @@ e2function void entity:takeDamage(number amount, entity attacker, entity inflict if not E2Lib.isOwner(self, attacker) then return self:throw("You do not own the attacker entity!", nil) end if not IsValid(inflictor) then return self:throw("Invalid inflictor entity!", nil) end if not E2Lib.isOwner(self, inflictor) then return self:throw("You do not own the inflictor entity!", nil) end - if not WireLib.CanDamage(self.player, this) then self:throw("You cannot damage this entity!", nil) end + if not WireLib.CanDamage(self.player, this) then return self:throw("You cannot damage this entity!", nil) end if this:IsPlayer() and not E2Lib.isFriend(self.player, this) and not WireLib.CanTool(self.player, this, "wire_expression2") then return self:throw("You cannot damage this player!", nil) end this:TakeDamage(amount, attacker, inflictor)