From 0715773b6c88f49d1b9b8b29f24403d0fff4c035 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Thu, 14 May 2026 01:18:52 +0300 Subject: [PATCH 01/16] Bandaid fixes for gametick/per-player-quota in E2 For some unknown reason, these tables may contain NULLs, and i still have no idea why So i'm making this temporary fix to address this --- lua/entities/gmod_wire_expression2/core/gametick.lua | 3 +++ lua/entities/gmod_wire_expression2/init.lua | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lua/entities/gmod_wire_expression2/core/gametick.lua b/lua/entities/gmod_wire_expression2/core/gametick.lua index 18b607c508..6eeeb6befe 100644 --- a/lua/entities/gmod_wire_expression2/core/gametick.lua +++ b/lua/entities/gmod_wire_expression2/core/gametick.lua @@ -31,6 +31,9 @@ E2Lib.registerEvent("tick") hook.Add("Think", "Expression2TickClock", function() for entity in pairs(registered_chips) do local tab = entity:GetTable() + + -- For some reason entity can be NULL? (See #3353) + if not tab then continue end local data = tab.context.data data.tickrun = true diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index ebb6fe2384..fe7ad0bae6 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -314,6 +314,9 @@ function PlayerChips:getTotalTime() for _, chip in ipairs(self) do local tab = chip:GetTable() + + -- For some reason entity can be NULL? (See #3602) + if not tab then continue end if tab.error then continue end local context = tab.context @@ -330,6 +333,9 @@ function PlayerChips:findMaxTimeChip() for _, chip in ipairs(self) do local tab = chip:GetTable() + + -- For some reason entity can be NULL? (See #3602) + if not tab then continue end if tab.error then continue end local context = tab.context From 94d8bc0376c80d5ffdf7e9bbb5f81ce01ff31dcd Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Thu, 14 May 2026 03:10:25 +0300 Subject: [PATCH 02/16] Clear invalid entity in gametick instead of skipping --- lua/entities/gmod_wire_expression2/core/gametick.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/core/gametick.lua b/lua/entities/gmod_wire_expression2/core/gametick.lua index 6eeeb6befe..1ce750db33 100644 --- a/lua/entities/gmod_wire_expression2/core/gametick.lua +++ b/lua/entities/gmod_wire_expression2/core/gametick.lua @@ -33,7 +33,7 @@ hook.Add("Think", "Expression2TickClock", function() local tab = entity:GetTable() -- For some reason entity can be NULL? (See #3353) - if not tab then continue end + if not tab then registered_chips[entity] = nil continue end local data = tab.context.data data.tickrun = true From 547d83537f5b1b505b903c4a25fc9880e3199f1a Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 15 May 2026 21:56:04 +0300 Subject: [PATCH 03/16] Backwards iteration + safety checks to hopefully debug this --- lua/entities/gmod_wire_expression2/init.lua | 35 +++++++++++++++------ 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index fe7ad0bae6..2da701b3d8 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -312,11 +312,13 @@ end function PlayerChips:getTotalTime() local total_time = 0 - for _, chip in ipairs(self) do + -- Bakcwards iteration to safely remove NULLs during iteration + for i = #self, 1, -1 do + local chip = self[i] local tab = chip:GetTable() -- For some reason entity can be NULL? (See #3602) - if not tab then continue end + if not tab then self:remove(chip) continue end if tab.error then continue end local context = tab.context @@ -331,11 +333,13 @@ end function PlayerChips:findMaxTimeChip() local max_chip, max_time = nil, 0 - for _, chip in ipairs(self) do + -- Bakcwards iteration to safely remove NULLs during iteration + for i = #self, 1, -1 do + local chip = self[i] local tab = chip:GetTable() -- For some reason entity can be NULL? (See #3602) - if not tab then continue end + if not tab then self:remove(chip) continue end if tab.error then continue end local context = tab.context @@ -367,7 +371,15 @@ function PlayerChips:checkCpuTime() end end -function PlayerChips:add(chip) +function PlayerChips:add(add_chip) + -- Safety check + for index, chip in ipairs(self) do + if add_chip == chip then + ErrorNoHaltWithStack("Attempt to add the same chip to E2Lib.PlayerChips twice!") + return + end + end + table.insert(self, chip) end @@ -378,6 +390,15 @@ function PlayerChips:remove(remove_chip) break end end + + if #self == 0 then + for ply, chips in pairs(E2Lib.PlayerChips) do + if self == chips then + E2Lib.PlayerChips[ply] = nil + break + end + end + end end E2Lib.PlayerChips = E2Lib.PlayerChips or setmetatable({}, {__index = function(self, ply) local chips = PlayerChips:new() self[ply] = chips return chips end}) @@ -408,10 +429,6 @@ function ENT:OnRemove() if chips then chips:remove(self) - - if #chips == 0 then - E2Lib.PlayerChips[owner] = nil - end end BaseClass.OnRemove(self) From 5516b1a46c741e0f0644cec8088160c57621e977 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 15 May 2026 22:02:23 +0300 Subject: [PATCH 04/16] Fix --- lua/entities/gmod_wire_expression2/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 2da701b3d8..e97e499b3c 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -380,7 +380,7 @@ function PlayerChips:add(add_chip) end end - table.insert(self, chip) + table.insert(self, add_chip) end function PlayerChips:remove(remove_chip) From 35f84d36d31606c34543ad635756785aea553eda Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 15 May 2026 22:25:29 +0300 Subject: [PATCH 05/16] Change the logic of E2Lib.PlayerChips --- .../gmod_wire_expression2/core/core.lua | 6 +- lua/entities/gmod_wire_expression2/init.lua | 73 ++++++++----------- 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/core.lua b/lua/entities/gmod_wire_expression2/core/core.lua index ec44aa8014..414fad661c 100644 --- a/lua/entities/gmod_wire_expression2/core/core.lua +++ b/lua/entities/gmod_wire_expression2/core/core.lua @@ -217,8 +217,7 @@ e2function number totalCpuUsage() local owner = self.player if not IsValid(owner) then return self.timebench end - -- To avoid creating new table - local chips = rawget(E2Lib.PlayerChips, owner) + local chips = E2Lib.PlayerChips[owner] if not chips then return self.timebench end return chips:getTotalTime() @@ -228,8 +227,7 @@ end e2function number entity:totalCpuUsage() if not IsValid(this) or not this:IsPlayer() then return 0 end - -- To avoid creating new table - local chips = rawget(E2Lib.PlayerChips, this) + local chips = E2Lib.PlayerChips[owner] if not chips then return 0 end return chips:getTotalTime() diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index e97e499b3c..4c12422650 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -84,7 +84,8 @@ function ENT:Initialize() local owner = self.player if IsValid(owner) then - E2Lib.PlayerChips[owner]:add(self) + E2Lib.PlayerChips:get_or_create(owner) + E2Lib.PlayerChips:add(owner, self) end end @@ -312,13 +313,8 @@ end function PlayerChips:getTotalTime() local total_time = 0 - -- Bakcwards iteration to safely remove NULLs during iteration - for i = #self, 1, -1 do - local chip = self[i] + for _, chip in ipairs(self) do local tab = chip:GetTable() - - -- For some reason entity can be NULL? (See #3602) - if not tab then self:remove(chip) continue end if tab.error then continue end local context = tab.context @@ -333,13 +329,8 @@ end function PlayerChips:findMaxTimeChip() local max_chip, max_time = nil, 0 - -- Bakcwards iteration to safely remove NULLs during iteration - for i = #self, 1, -1 do - local chip = self[i] + for _, chip in ipairs(self) do local tab = chip:GetTable() - - -- For some reason entity can be NULL? (See #3602) - if not tab then self:remove(chip) continue end if tab.error then continue end local context = tab.context @@ -371,37 +362,40 @@ function PlayerChips:checkCpuTime() end end -function PlayerChips:add(add_chip) - -- Safety check - for index, chip in ipairs(self) do - if add_chip == chip then - ErrorNoHaltWithStack("Attempt to add the same chip to E2Lib.PlayerChips twice!") - return - end +local GlobalChips = {} +GlobalChips.__index = GlobalChips + +function GlobalChips:get_or_create(ply) + local chips = self[ply] + + if not chips then + chips = PlayerChips:new() + self[ply] = chips end - table.insert(self, add_chip) + return chips end -function PlayerChips:remove(remove_chip) - for index, chip in ipairs(self) do - if remove_chip == chip then - table.remove(self, index) - break - end - end +function GlobalChips:add(ply, add_chip) + table.insert(self[ply], add_chip) +end - if #self == 0 then - for ply, chips in pairs(E2Lib.PlayerChips) do - if self == chips then - E2Lib.PlayerChips[ply] = nil - break +function GlobalChips:remove(remove_chip) + -- Expensive iteration because chips may sometimes not be removed? (See #3602) + for ply, chips in pairs(self) do + for index, chip in ipairs(chips) do + if remove_chip == chip then + table.remove(chips, index) + + if #chips == 0 then + self[ply] = nil + end end end end end -E2Lib.PlayerChips = E2Lib.PlayerChips or setmetatable({}, {__index = function(self, ply) local chips = PlayerChips:new() self[ply] = chips return chips end}) +E2Lib.PlayerChips = E2Lib.PlayerChips or setmetatable({}, GlobalChips) hook.Add("Think", "E2_Think", function() if e2_timequota > 0 then @@ -424,12 +418,7 @@ function ENT:OnRemove() self:Destruct() end - local owner = self.player - local chips = rawget(E2Lib.PlayerChips, owner) - - if chips then - chips:remove(self) - end + E2Lib.PlayerChips:remove(self) BaseClass.OnRemove(self) end @@ -854,9 +843,11 @@ hook.Add("PlayerDisconnected", "Wire_Expression2_Player_Disconnected", function( end) hook.Add("PlayerAuthed", "Wire_Expression2_Player_Authed", function(ply, sid, uid) + E2Lib.PlayerChips:get_or_create(ply) + for _, ent in ipairs(ents.FindByClass("gmod_wire_expression2")) do if ent.uid == uid then - E2Lib.PlayerChips[ply]:add(ent) + E2Lib.PlayerChips:add(ply, ent) ent:SetNWEntity("player", ply) ent.player = ply end From a1e366054b53049893ead8471296c24784a32465 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 15 May 2026 22:30:06 +0300 Subject: [PATCH 06/16] Use entity removed --- lua/entities/gmod_wire_expression2/init.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 4c12422650..f6312b3997 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -418,11 +418,16 @@ function ENT:OnRemove() self:Destruct() end - E2Lib.PlayerChips:remove(self) - BaseClass.OnRemove(self) end +-- EntityRemoved instead PlayerDisconnected because is not called for the listen-host (for example during retry) +hook.Add("EntityRemoved", "E2_ClearPlayerChips", function(ent) + if ent:IsPlayer() then + E2Lib.PlayerChips:remove(ent) + end +end) + function ENT:PCallHook(...) local ok, ret = pcall(self.CallHook, self, ...) if ok then From c9a2e2218caa500711e7b2ea8db75afad7add16b Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 15 May 2026 22:31:11 +0300 Subject: [PATCH 07/16] Woops --- lua/entities/gmod_wire_expression2/init.lua | 27 ++++++++------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index f6312b3997..1b67aa9b4d 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -421,13 +421,6 @@ function ENT:OnRemove() BaseClass.OnRemove(self) end --- EntityRemoved instead PlayerDisconnected because is not called for the listen-host (for example during retry) -hook.Add("EntityRemoved", "E2_ClearPlayerChips", function(ent) - if ent:IsPlayer() then - E2Lib.PlayerChips:remove(ent) - end -end) - function ENT:PCallHook(...) local ok, ret = pcall(self.CallHook, self, ...) if ok then @@ -833,16 +826,16 @@ end -- -------------------------------- Transfer ---------------------------------- ---[[ - Player Disconnection Magic ---]] -hook.Add("PlayerDisconnected", "Wire_Expression2_Player_Disconnected", function(ply) - E2Lib.PlayerChips[ply] = nil - - for _, v in ipairs(ents.FindByClass("gmod_wire_expression2")) do - if v.player == ply and not v.error then - v:Error("Owner disconnected") - v:Destruct() +-- EntityRemoved instead PlayerDisconnected because is not called for the listen-host (for example during retry) +hook.Add("EntityRemoved", "Wire_Expression2_Player_Disconnected", function(ply) + if ply:IsPlayer() then + E2Lib.PlayerChips[ply] = nil + + for _, v in ipairs(ents.FindByClass("gmod_wire_expression2")) do + if v.player == ply and not v.error then + v:Error("Owner disconnected") + v:Destruct() + end end end end) From a76cc560ab483716242285987c6b128d8d049c93 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 15 May 2026 22:33:44 +0300 Subject: [PATCH 08/16] Don't create for every player --- lua/entities/gmod_wire_expression2/init.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 1b67aa9b4d..775a90a37c 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -841,10 +841,9 @@ hook.Add("EntityRemoved", "Wire_Expression2_Player_Disconnected", function(ply) end) hook.Add("PlayerAuthed", "Wire_Expression2_Player_Authed", function(ply, sid, uid) - E2Lib.PlayerChips:get_or_create(ply) - for _, ent in ipairs(ents.FindByClass("gmod_wire_expression2")) do if ent.uid == uid then + E2Lib.PlayerChips:get_or_create(ply) E2Lib.PlayerChips:add(ply, ent) ent:SetNWEntity("player", ply) ent.player = ply From 08b2f4849819256f4cf4991d2cf13876e3102ded Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 15 May 2026 22:35:37 +0300 Subject: [PATCH 09/16] Forgot to return that --- lua/entities/gmod_wire_expression2/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 775a90a37c..5d4ae6cdd7 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -418,6 +418,7 @@ function ENT:OnRemove() self:Destruct() end + E2Lib.PlayerChips:remove(self) BaseClass.OnRemove(self) end From 8259c53e0e32951a176a9f2b6eab6df804263863 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 15 May 2026 22:40:32 +0300 Subject: [PATCH 10/16] Move get_or_create inside add --- lua/entities/gmod_wire_expression2/init.lua | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 5d4ae6cdd7..9dbec88f40 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -84,7 +84,6 @@ function ENT:Initialize() local owner = self.player if IsValid(owner) then - E2Lib.PlayerChips:get_or_create(owner) E2Lib.PlayerChips:add(owner, self) end end @@ -365,7 +364,7 @@ end local GlobalChips = {} GlobalChips.__index = GlobalChips -function GlobalChips:get_or_create(ply) +function GlobalChips:add(ply, add_chip) local chips = self[ply] if not chips then @@ -373,10 +372,6 @@ function GlobalChips:get_or_create(ply) self[ply] = chips end - return chips -end - -function GlobalChips:add(ply, add_chip) table.insert(self[ply], add_chip) end @@ -844,7 +839,6 @@ end) hook.Add("PlayerAuthed", "Wire_Expression2_Player_Authed", function(ply, sid, uid) for _, ent in ipairs(ents.FindByClass("gmod_wire_expression2")) do if ent.uid == uid then - E2Lib.PlayerChips:get_or_create(ply) E2Lib.PlayerChips:add(ply, ent) ent:SetNWEntity("player", ply) ent.player = ply From 0928f729d328695ada71d93d87cf0b83654a1dd6 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 15 May 2026 22:41:08 +0300 Subject: [PATCH 11/16] Use local value --- lua/entities/gmod_wire_expression2/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 9dbec88f40..b2a3ffcbe9 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -372,7 +372,7 @@ function GlobalChips:add(ply, add_chip) self[ply] = chips end - table.insert(self[ply], add_chip) + table.insert(chips, add_chip) end function GlobalChips:remove(remove_chip) From f9e3772e7a986725d032fbad9b4ffd041b10688d Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 15 May 2026 23:05:30 +0300 Subject: [PATCH 12/16] Break loop --- lua/entities/gmod_wire_expression2/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index b2a3ffcbe9..5a3e91b15c 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -385,6 +385,8 @@ function GlobalChips:remove(remove_chip) if #chips == 0 then self[ply] = nil end + + return end end end From 6f9d5b9e1f9091442eb5ee9b16a4b15a6e4dd533 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Sat, 16 May 2026 14:53:18 +0300 Subject: [PATCH 13/16] Fallback to ent.FounderIndex when the chip may not be initialized (for example, if it was spawned with a compile error) --- lua/entities/gmod_wire_expression2/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 5a3e91b15c..7ca02d07e8 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -840,7 +840,7 @@ end) hook.Add("PlayerAuthed", "Wire_Expression2_Player_Authed", function(ply, sid, uid) for _, ent in ipairs(ents.FindByClass("gmod_wire_expression2")) do - if ent.uid == uid then + if ent.uid == uid or ent.FounderIndex == uid then E2Lib.PlayerChips:add(ply, ent) ent:SetNWEntity("player", ply) ent.player = ply From 4ccde737805c0c57cce76a1f0c174ee1fde6ab75 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Sat, 16 May 2026 14:56:55 +0300 Subject: [PATCH 14/16] Use :GetPlayer instead of UniqueID --- lua/entities/gmod_wire_expression2/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 7ca02d07e8..5da5ee4f4c 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -840,7 +840,7 @@ end) hook.Add("PlayerAuthed", "Wire_Expression2_Player_Authed", function(ply, sid, uid) for _, ent in ipairs(ents.FindByClass("gmod_wire_expression2")) do - if ent.uid == uid or ent.FounderIndex == uid then + if ent:GetPlayer() == ply then E2Lib.PlayerChips:add(ply, ent) ent:SetNWEntity("player", ply) ent.player = ply From 9c070b0cd50f5ce24c504d301bac0b69b8caeac1 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Sat, 16 May 2026 14:59:33 +0300 Subject: [PATCH 15/16] I think it can be switched to PlayerInitialSpawn --- lua/entities/gmod_wire_expression2/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 5da5ee4f4c..73557a597f 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -838,7 +838,7 @@ hook.Add("EntityRemoved", "Wire_Expression2_Player_Disconnected", function(ply) end end) -hook.Add("PlayerAuthed", "Wire_Expression2_Player_Authed", function(ply, sid, uid) +hook.Add("PlayerInitialSpawn", "Wire_Expression2_Player_Spawned", function(ply) for _, ent in ipairs(ents.FindByClass("gmod_wire_expression2")) do if ent:GetPlayer() == ply then E2Lib.PlayerChips:add(ply, ent) From 2d8c404b25a127047f0f7a001f06f69e23dfa50d Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Sat, 16 May 2026 15:15:59 +0300 Subject: [PATCH 16/16] Add to the account only for the real owner --- lua/entities/gmod_wire_expression2/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 73557a597f..27bc43538e 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -838,10 +838,14 @@ hook.Add("EntityRemoved", "Wire_Expression2_Player_Disconnected", function(ply) end end) -hook.Add("PlayerInitialSpawn", "Wire_Expression2_Player_Spawned", function(ply) +hook.Add("PlayerAuthed", "Wire_Expression2_Player_Authed", function(ply, sid, uid) for _, ent in ipairs(ents.FindByClass("gmod_wire_expression2")) do + -- Add to the account only for the real owner if ent:GetPlayer() == ply then E2Lib.PlayerChips:add(ply, ent) + end + + if ent.uid == uid then ent:SetNWEntity("player", ply) ent.player = ply end