From 499770d9d399f1ac674760284c9217f239300d9e Mon Sep 17 00:00:00 2001 From: kosmik641 Date: Thu, 6 Nov 2025 08:26:50 +0300 Subject: [PATCH] =?UTF-8?q?Ownership=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=B2=D0=BB=D0=B0=D0=B4=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D1=86=D0=B5=D0=B2=20=D1=8D=D0=BD=D1=82=D0=B8=D1=82=D0=B8=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BD=D0=B4=D0=B0=D1=80=D1=82=D0=BD=D1=8B?= =?UTF-8?q?=D0=BC=D0=B8=20=D1=84=D0=BD=D1=83=D0=BA=D1=86=D0=B8=D1=8F=D0=BC?= =?UTF-8?q?=D0=B8=20GMod'=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/entities/gmod_subway_base/init.lua | 11 +++++++++-- lua/entities/gmod_train_bogey/init.lua | 15 ++++++++++++++- lua/entities/gmod_train_special_box/init.lua | 5 +++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lua/entities/gmod_subway_base/init.lua b/lua/entities/gmod_subway_base/init.lua index 8e7e437..3832bc7 100644 --- a/lua/entities/gmod_subway_base/init.lua +++ b/lua/entities/gmod_subway_base/init.lua @@ -57,6 +57,7 @@ function ENT:PostEntityPaste(ply,ent,createdEntities) v[1].NoPhysics = v[2] or nil -- Assign ownership + if IsValid(self:GetOwner()) then v[1]:SetOwner(self:GetOwner()) end if CPPI and IsValid(self:CPPIGetOwner()) then v[1]:CPPISetOwner(self:CPPIGetOwner()) end -- Some shared general information about the bogey @@ -105,8 +106,9 @@ function ENT:Initialize() end self:SetUseType(SIMPLE_USE) -- Prop-protection related - if CPPI and IsValid(self.Owner) then - self:CPPISetOwner(self.Owner) + if IsValid(self.Owner) then + self:SetOwner(self.Owner) + if CPPI then self:CPPISetOwner(self.Owner) end end -- Entities that belong to train and must be cleaned up later self.TrainEntities = {} @@ -1032,6 +1034,7 @@ function ENT:CreateBogey(pos,ang,forward,typ) bogey:Spawn() -- Assign ownership + if IsValid(self:GetOwner()) then bogey:SetOwner(self:GetOwner()) end if CPPI and IsValid(self:CPPIGetOwner()) then bogey:CPPISetOwner(self:CPPIGetOwner()) end -- Some shared general information about the bogey @@ -1069,6 +1072,7 @@ function ENT:CreateBogey(pos,ang,forward,typ) end function ENT:AddLightSensor(pos,ang,model) local sensor = ents.Create("gmod_train_autodrive_coil") + if IsValid(self:GetOwner()) then sensor:SetOwner(self:GetOwner()) end if CPPI and IsValid(self:CPPIGetOwner()) then sensor:CPPISetOwner(self:CPPIGetOwner()) end sensor:SetPos(self:LocalToWorld(pos)) sensor:SetAngles(self:LocalToWorldAngles(ang)) @@ -1091,6 +1095,7 @@ function ENT:AddAutodriveCoil(bogey,right) bogey.CoilL = coil end -- Assign ownership + if IsValid(self:GetOwner()) then coil:SetOwner(self:GetOwner()) end if CPPI and IsValid(self:CPPIGetOwner()) then coil:CPPISetOwner(self:CPPIGetOwner()) end end if right then @@ -1116,6 +1121,7 @@ function ENT:CreateCouple(pos,ang,forward,typ) coupler:Spawn() -- Assign ownership + if IsValid(self:GetOwner()) then coupler:SetOwner(self:GetOwner()) end if CPPI and IsValid(self:CPPIGetOwner()) then coupler:CPPISetOwner(self:CPPIGetOwner()) end -- Some shared general information about the bogey @@ -1188,6 +1194,7 @@ function ENT:CreateSeatEntity(seat_info) self:DrawShadow(false) --Assign ownership + if IsValid(self:GetOwner()) then seat:SetOwner(self:GetOwner()) end if CPPI and IsValid(self:CPPIGetOwner()) then seat:CPPISetOwner(self:CPPIGetOwner()) end -- Hide the entity visually diff --git a/lua/entities/gmod_train_bogey/init.lua b/lua/entities/gmod_train_bogey/init.lua index de2cc44..893c7b9 100644 --- a/lua/entities/gmod_train_bogey/init.lua +++ b/lua/entities/gmod_train_bogey/init.lua @@ -149,7 +149,20 @@ function ENT:InitializeWheels() else constraint.Weld(self,wheels,0,0,0,1,0) end - if CPPI then wheels:CPPISetOwner(self:CPPIGetOwner() or self:GetNW2Entity("TrainEntity"):GetOwner()) end + + -- Assign ownership + if IsValid(self:GetOwner()) then + wheels:SetOwner(self:GetOwner()) + elseif IsValid(self:GetNW2Entity("TrainEntity"):GetOwner()) then + wheels:SetOwner(self:GetNW2Entity("TrainEntity"):GetOwner()) + end + + if CPPI and IsValid(self:CPPIGetOwner()) then + wheels:CPPISetOwner(self:CPPIGetOwner()) + elseif CPPI and IsValid(self:GetNW2Entity("TrainEntity"):CPPIGetOwner()) then + wheels:CPPISetOwner(self:GetNW2Entity("TrainEntity"):CPPIGetOwner()) + end + wheels:SetNW2Entity("TrainBogey",self) self.Wheels = wheels end diff --git a/lua/entities/gmod_train_special_box/init.lua b/lua/entities/gmod_train_special_box/init.lua index 0e95388..7b8a3d2 100644 --- a/lua/entities/gmod_train_special_box/init.lua +++ b/lua/entities/gmod_train_special_box/init.lua @@ -37,8 +37,9 @@ function ENT:Use(_,ply) self.Cover:SetOwner(self.Owner) local phys = self.Cover:GetPhysicsObject() phys:ApplyForceCenter(self.Cover:GetUp()*phys:GetMass()*40+self.Cover:GetRight()*phys:GetMass()*35 ) - if CPPI and IsValid(self.Owner) then - self.Cover:CPPISetOwner(self.Owner) + if IsValid(self.Owner) then + self.Cover:SetOwner(self.Owner) + if CPPI then self.Cover:CPPISetOwner(self.Owner) end end if self.Code then self:SetNW2Int("Code",self.Code) end elseif self:GetModel() == "models/metrostroi_train/reversor/reversor_collection_box2.mdl" then