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