• How to make a ent that will not be removed by Remove()
    4 replies, posted
i spawn another ent on ENT:OnRemove() but it is not the real "can't remove" someone make a npc that can not be remove this is full code anyone can tell me how to use ? ----------- AddCSLuaFile() local NPCMETA = FindMetaTable("NPC") local ENTMETA = FindMetaTable("Entity") local D1   = math.random(1,9999) local A1   = math.random(1,9999) local overrideKey = string.char(math.random(70,100))..string.char(math.random(70,100))..string.char(math.random(70,100))..string.char(math.random(70,100))..string.char(math.random(70,100))..string.char(math.random(70,100))..string.char(math.random(70,100))..string.char(math.random(70,100))..string.char(math.random(70,100))..string.char(math.random(70,100))..string.char(math.random(70,100))..string.char(math.random(70,100)) local overridden = {} local function OverrideFunction(meta,name,afterSpawn,ret) local oldFunc = meta[name] if overridden[name] then return end if !oldFunc then return end overridden[name] = true meta[name] = function(self,...) if self:GetClass() == "qtg_invincible_npc" and (!afterSpawn or self.hasSpawned) then local args = {...} if args[#args] != overrideKey then return ret and unpack(ret) or nil end end return oldFunc(self,...) end end local function OverrideNonMeta(tbl,name,entArgNums,retBlockVal) local oldFunc = tbl[name] if !oldFunc then return end tbl[name] = function(...) local args = {...} for k,v in ipairs(entArgNums) do if IsValid(args[v]) and args[v]:GetClass() == "qtg_invincible_npc" and args[#args] != overrideKey then return istable(retBlockVal) and table.Copy(retBlockVal) or retBlockVal end end return oldFunc(...) end end local oldDelRemove = ENTMETA.DeleteOnRemove function ENTMETA:DeleteOnRemove(ent) if ent:GetClass() == "qtg_invincible_npc" then return end oldDelRemove(self,ent) end OverrideFunction(ENTMETA,"Remove") OverrideFunction(ENTMETA,"SetNoDraw") OverrideFunction(ENTMETA,"SetMoveType") OverrideFunction(ENTMETA,"SetVelocity") OverrideFunction(ENTMETA,"SetLocalVelocity") OverrideFunction(ENTMETA,"SetModel") OverrideFunction(ENTMETA,"SetSolid") OverrideFunction(ENTMETA,"SetHealth") OverrideFunction(ENTMETA,"SetNotSolid") OverrideFunction(ENTMETA,"SetCollisionGroup") OverrideFunction(ENTMETA,"DrawShadow") OverrideFunction(ENTMETA,"SetRenderMode") OverrideFunction(ENTMETA,"SetGravity") OverrideFunction(ENTMETA,"SetModelScale") OverrideFunction(ENTMETA,"SetMaterial") OverrideFunction(ENTMETA,"SetColor") OverrideFunction(ENTMETA,"ManipulateBonePosition") OverrideFunction(ENTMETA,"ManipulateBoneScale") OverrideFunction(ENTMETA,"ManipulateBoneJiggle") OverrideFunction(ENTMETA,"SetParent") OverrideFunction(ENTMETA,"SetFlexScale") OverrideFunction(ENTMETA,"SetSequence") OverrideFunction(ENTMETA,"SetCycle") OverrideFunction(ENTMETA,"SetOwner") OverrideFunction(ENTMETA,"Ignite") OverrideFunction(ENTMETA,"SetModelName") OverrideFunction(ENTMETA,"AddCallback") OverrideFunction(ENTMETA,"AddEffects") OverrideFunction(ENTMETA,"AddFlags") OverrideFunction(ENTMETA,"AddGesture") OverrideFunction(ENTMETA,"AddGestureSequence") OverrideFunction(ENTMETA,"AddLayeredSequence") OverrideFunction(ENTMETA,"AddSolidFlags") OverrideFunction(ENTMETA,"AddToMotionController") OverrideFunction(ENTMETA,"AlignAngles") OverrideFunction(ENTMETA,"EnableConstraints") OverrideFunction(ENTMETA,"EnableCustomCollisions") OverrideFunction(ENTMETA,"Fire") OverrideFunction(ENTMETA,"FireBullets") OverrideFunction(ENTMETA,"NextThink") OverrideFunction(ENTMETA,"SetAbsVelocity") OverrideFunction(ENTMETA,"PhysicsInit") OverrideFunction(ENTMETA,"PhysicsDestroy") OverrideFunction(ENTMETA,"PhysicsFromMesh") OverrideFunction(ENTMETA,"PhysicsInitBox") OverrideFunction(ENTMETA,"PhysicsInitConvex") OverrideFunction(ENTMETA,"PhysicsInitMultiConvex") OverrideFunction(ENTMETA,"PhysicsInitShadow") OverrideFunction(ENTMETA,"PhysicsInitSphere") OverrideFunction(ENTMETA,"PhysicsInitStatic") OverrideFunction(ENTMETA,"RemoveFromMotionController") OverrideFunction(ENTMETA,"RemoveSolidFlags") OverrideFunction(ENTMETA,"Respawn") OverrideFunction(ENTMETA,"SetMoveCollide") OverrideFunction(ENTMETA,"SetMoveParent") OverrideFunction(ENTMETA,"AddEFlags") OverrideFunction(ENTMETA,"SetKeyValue") OverrideFunction(ENTMETA,"SetPos",true) OverrideFunction(ENTMETA,"SetAngles",true) OverrideFunction(ENTMETA,"DropToFloor",true) OverrideFunction(ENTMETA,"SetCreator",true) OverrideFunction(ENTMETA,"Spawn",true) OverrideFunction(NPCMETA,"SetNPCState") OverrideFunction(NPCMETA,"SetMovementActivity") OverrideFunction(NPCMETA,"SetCurrentWeaponProficiency") OverrideFunction(NPCMETA,"SetHullSizeNormal") OverrideFunction(NPCMETA,"SetHullType") OverrideFunction(NPCMETA,"UpdateEnemyMemory") OverrideFunction(NPCMETA,"SetSchedule") OverrideFunction(NPCMETA,"SetEnemy") OverrideFunction(NPCMETA,"CapabilitiesAdd") OverrideFunction(NPCMETA,"CapabilitiesClear") OverrideFunction(NPCMETA,"CapabilitiesRemove") OverrideFunction(NPCMETA,"Give") OverrideFunction(NPCMETA,"MaintainActivity") OverrideFunction(NPCMETA,"MarkEnemyAsEluded") OverrideFunction(NPCMETA,"MoveOrder") OverrideFunction(NPCMETA,"NavSetGoal") OverrideFunction(NPCMETA,"NavSetGoalTarget") OverrideFunction(NPCMETA,"NavSetRandomGoal") OverrideFunction(NPCMETA,"NavSetWanderGoal") OverrideFunction(NPCMETA,"SetArrivalActivity") OverrideFunction(NPCMETA,"SetArrivalDirection") OverrideFunction(NPCMETA,"SetArrivalDistance") OverrideFunction(NPCMETA,"SetArrivalSequence") OverrideFunction(NPCMETA,"SetArrivalSpeed") OverrideFunction(NPCMETA,"SetLastPosition") OverrideFunction(NPCMETA,"SetMaxRouteRebuildTime") OverrideFunction(NPCMETA,"UseActBusyBehavior") OverrideFunction(NPCMETA,"UseAssaultBehavior") OverrideFunction(NPCMETA,"UseFollowBehavior") OverrideFunction(NPCMETA,"UseFuncTankBehavior") OverrideFunction(NPCMETA,"UseLeadBehavior") OverrideFunction(NPCMETA,"UseNoBehavior") OverrideFunction(NPCMETA,"SetMovementSequence") OverrideFunction(NPCMETA,"SetCondition") OverrideFunction(NPCMETA,"AddEntityRelationship") OverrideFunction(NPCMETA,"ClearExpression") OverrideFunction(NPCMETA,"ClearEnemyMemory") OverrideFunction(NPCMETA,"ClearGoal") OverrideFunction(NPCMETA,"ClearSchedule") OverrideFunction(NPCMETA,"AlertSound") OverrideNonMeta(constraint,"RemoveAll",{1}) OverrideNonMeta(constraint,"GetAllConstrainedEntities",{1},{}) local oldCleanup = game.CleanUpMap function game.CleanUpMap(send,filter) if !filter then filter = {} end if !table.HasValue(filter,"qtg_invincible_npc") then filter[#filter+1] = "qtg_invincible_npc" end oldCleanup(send,filter) end local oldEffect = util.Effect function util.Effect(efName,ef,a,b,ovr) if ef:GetEntity():IsValid() and ef:GetEntity():GetClass() == "qtg_invincible_npc" and ovr != overrideKey then return end oldEffect(efName,ef,a,b) end hook.Add("EntityTakeDamage",A1..A1..A1..D1,function(ent,dmg) if ent:GetClass() == "qtg_invincible_npc" then return true end end) hook.Add("EntityTakeDamage",A1..A1..A1..D1, function(target,dmginfo) if target:GetClass() == "npc_lubenweibot" then target.OnRemove = function() target:StopSound("lubenweipanic") return true end target:Remove() end end) hook.Add("EntityTakeDamage",A1..A1..A1..D1, function(target,dmginfo) if target:GetClass() == "npc_windgrinbot" then target.OnRemove = function()  target:StopSound("windgrinpanic") end target:Remove() end end) ENT.Base = "base_nextbot" ENT.PhysgunDisabled = true ENT.AutomaticFrameAdvance = false local IsValid = IsValid if SERVER then local TAUNT_INTERVAL = 1.2 local PATH_INFRACTION_LOCKOUT_TIME = 5 resource.AddWorkshop("1517812362") local trace = { mask = MASK_SOLID_BRUSHONLY } local function isPointNearSpawn(point, distance) if (not GAMEMODE.SpawnPoints) then return false end local distanceSqr = (distance * distance) for _, spawnPoint in pairs(GAMEMODE.SpawnPoints) do if (not IsValid(spawnPoint)) then continue end if point:DistToSqr(spawnPoint:GetPos()) <= distanceSqr then return true end end return false end local function isPositionExposed(pos) for _, ply in pairs(player.GetAll()) do if (IsValid(ply) and ply:Alive() and ply:IsLineOfSightClear(pos)) then return true end end return false end local function isPointSuitableForHiding(point) trace.start = point trace.endpos = point + Vector(0, 0, 96) local tr = util.TraceLine(trace) return (not tr.Hit) end local g_hidingSpots = nil local function buildHidingSpotCache() local rStart = SysTime() g_hidingSpots = {} local startPoint = (GAMEMODE.SpawnPoints and GAMEMODE.SpawnPoints[1] or nil) local startPos = nil if (IsValid(startPoint)) then startPos = startPoint:GetPos() else local tr = util.QuickTrace(vector_origin, -vector_up * 16384) startPos = tr.HitPos end local areas = navmesh.Find(startPos, 1e9, 16384, 16384) local goodSpots, badSpots = 0, 0 for _, area in pairs(areas) do for _, hidingSpot in pairs(area:GetHidingSpots()) do if (isPointSuitableForHiding(hidingSpot)) then g_hidingSpots[goodSpots + 1] = { pos = hidingSpot, nearSpawn = isPointNearSpawn(hidingSpot, 200), occupant = nil } goodSpots = goodSpots + 1 else badSpots = badSpots + 1 end end end end local function isValidTarget(ent) if (not IsValid(ent)) then return false end if (ent:IsPlayer()) then return ent:Alive() end local class = ent:GetClass() return (ent:Health() > 0 and class ~= "qtg_invincible_npc" and not class:find("bullseye")) end ENT.LastPathRecompute = 0 ENT.LastTargetSearch = 0 ENT.LastJumpScan = 0 ENT.LastCeilingUnstick = 0 ENT.LastTaunt = 0 ENT.LastIdle = 0 ENT.RandomSkillTime = 120 ENT.CurrentTarget = nil ENT.HidingSpot = nil ENT.AttackDamage = 999999999999 function ENT:Initialize() self:SetModel("models/humans/group01/male_0"..math.random(1,9)..".mdl",overrideKey) self:SetSpawnEffect(false,overrideKey) self:SetBloodColor(DONT_BLEED,overrideKey) self:SetSolid(SOLID_BBOX,overrideKey) self:AddEFlags(EFL_NO_DISSOLVE+EFL_NO_MEGAPHYSCANNON_RAGDOLL+EFL_NO_PHYSCANNON_INTERACTION+EFL_NO_DAMAGE_FORCES+EFL_CHECK_UNTOUCH,overrideKey) self:SetHealth(99999999,overrideKey) self:SetCollisionGroup(COLLISION_GROUP_IN_VEHICLE,overrideKey) self:SetSolidFlags(FSOLID_NOT_SOLID,overrideKey) self:AddFlags(FL_DISSOLVING+FL_TRANSRAGDOLL,overrideKey) self:SetNoDraw(false,overrideKey) self:DrawShadow(true,overrideKey) self:SetRenderMode(RENDERMODE_TRANSALPHA,overrideKey) self:SetColor(Color(255, 255, 255, 255),overrideKey) self:SetCollisionBounds(Vector(-13, -13, 0), Vector(13, 13, 72),overrideKey) self.loco:SetDeathDropHeight(2000,overrideKey) self.loco:SetDesiredSpeed(2000,overrideKey) self.loco:SetAcceleration(2000,overrideKey) self.loco:SetDeceleration(2000,overrideKey) self.loco:SetJumpHeight(2000,overrideKey) self:OnReloaded() self:Animation() self.hasSpawned = true self:SetNWInt("NpcSkill", 0) self:SetNWInt("RandomSkillTime", CurTime() + 40) end function ENT:Think() for _,v in ipairs(ents.FindInSphere(self:GetPos(),100)) do if v == self then continue end v:TakeDamage(self.AttackDamage,self) if v:GetPhysicsObject():IsValid() then v:GetPhysicsObject():ApplyForceOffset(self:GetForward()*999999999999,VectorRand()) end if v:IsPlayer() and v:Alive() then v:Kill() end v:Remove() end if self:GetNWInt("NpcSkill") == 1 then local owner = self:GetOwner() local skill = ents.Create("qtg_skill_boom_servermhs") skill:SetPos(self:GetPos()) skill:SetOwner(self:GetOwner()) skill:Spawn() for k,v in pairs(ents.GetAll()) do timer.Simple(4,function() if v:IsNPC() then v:SetHealth(1) v:TakeDamage(999999999999, self) end if v:IsPlayer() then v:SetHealth(0) v:TakeDamage(999999999999, self) end if v:IsPlayer() and v:Alive() then v:Kill() end end) end for k, v in pairs(player.GetAll()) do v:ChatPrint( "无敌NPC使用技能:核爆!") v:ChatPrint( "Invincible npc use skill: Nuclear bomb!") end self:SetNWInt("NpcSkill", 0) elseif self:GetNWInt("NpcSkill") == 2 then for k,v in pairs(player.GetAll()) do  v:ChatPrint( "无敌NPC使用技能:瞬移所有玩家!") v:ChatPrint( "Invincible npc use skill: Teleport all players!") v:ViewPunch(Angle(  math.random(360,90),   math.random(10,60),   math.random(10,180) )) timer.Simple(1,function() v:SetPos(self:GetPos()) end) end self:SetNWInt("NpcSkill", 0) elseif self:GetNWInt("NpcSkill") == 3 then for k,v in pairs(player.GetAll()) do  v:ChatPrint( "无敌NPC使用技能:杀死所有玩家!") v:ChatPrint( "Invincible npc use skill: Kill all players!") v:ViewPunch(Angle(  math.random(360,90),   math.random(10,60),   math.random(10,180) )) end for k,v in pairs(ents.GetAll()) do timer.Simple(1,function() if v:IsPlayer() then v:SetHealth(0) v:TakeDamage(999999999999, self) end if v:IsPlayer() and v:Alive() then v:Kill() end end) end self:SetNWInt("NpcSkill", 0) end self:RandomSkill() end function ENT:Animation() if (self:IsOnGround()) then self:StartActivity( ACT_RUN ) end end function ENT:RandomSkill() if self:GetNWInt("RandomSkillTime") < CurTime() then self:SetNWInt("RandomSkillTime", CurTime() + 40) self:SetNWInt("NpcSkill", math.random(1,3)) end end function ENT:OnTakeDamage(dmg) dmg:SetDamage(0) end function ENT:HasTarget() return IsValid(self.targetEntity) end function ENT:OnInjured(dmg) dmg:SetDamage(0) end function ENT:OnReloaded() if (g_hidingSpots == nil) then buildHidingSpotCache() end end function ENT:OnRemove() self:ClaimHidingSpot(nil) end function ENT:GetNearestTarget() local myPos = self:GetPos() local distToSqr = myPos.DistToSqr local getPos = self.GetPos local target = nil local getClass = self.GetClass for _, ent in pairs(ents.GetAll()) do if (not isValidTarget(ent)) then continue end local distSqr = distToSqr(getPos(ent), myPos) target = ent end if target == nil then if (CurTime() - self.LastIdle > 2) then self.LastIdle = CurTime() self:StartActivity( ACT_IDLE ) end end return target end function ENT:AttackNearbyTargets(radius) local hitSource = self:LocalToWorld(self:OBBCenter()) local hit = false for _, ent in pairs(ents.FindInSphere(hitSource, radius)) do if (isValidTarget(ent)) then local health = ent:Health() if (ent:IsPlayer() and IsValid(ent:GetVehicle())) then local vehicle = ent:GetVehicle() local vehiclePos = vehicle:LocalToWorld(vehicle:OBBCenter()) local hitDirection = (vehiclePos - hitSource):GetNormal() local phys = vehicle:GetPhysicsObject() if (IsValid(phys)) then phys:Wake() local hitOffset = vehicle:NearestPoint(hitSource) phys:ApplyForceOffset(hitDirection * (999999999999 * phys:GetMass()), hitOffset) end vehicle:TakeDamage(math.max(999999999999, ent:Health()), self, self) vehicle:EmitSound(string.format("physics/metal/metal_sheet_impact_hard%d.wav", math.random(6, 8)), 350, 120) else ent:EmitSound(string.format("physics/body/body_medium_impact_hard%d.wav", math.random(1, 6)), 350, 120) end local hitDirection = (ent:GetPos() - hitSource):GetNormal() ent:SetVelocity(hitDirection * 999999999999 + vector_up * 500) local dmgInfo = DamageInfo() dmgInfo:SetAttacker(self) dmgInfo:SetInflictor(self) dmgInfo:SetDamage(999999999999) dmgInfo:SetDamagePosition(self:GetPos()) dmgInfo:SetDamageForce((hitDirection * 999999999999 + vector_up * 500) * 100) ent:TakeDamageInfo(dmgInfo) local newHealth = ent:Health() hit = (hit or (newHealth < health)) elseif (ent:GetMoveType() == MOVETYPE_VPHYSICS) then if (ent:IsVehicle() and IsValid(ent:GetDriver())) then continue end local entPos = ent:LocalToWorld(ent:OBBCenter()) local hitDirection = (entPos - hitSource):GetNormal() local hitOffset = ent:NearestPoint(hitSource) constraint.RemoveAll(ent) local phys = ent:GetPhysicsObject() local mass = 0 local material = "Default" if (IsValid(phys)) then mass = phys:GetMass() material = phys:GetMaterial() end if (mass >= 5) then ent:EmitSound(material .. ".ImpactHard", 350, 120) end for id = 0, ent:GetPhysicsObjectCount() - 1 do local phys = ent:GetPhysicsObjectNum(id) if (IsValid(phys)) then phys:EnableMotion(true) phys:ApplyForceOffset(hitDirection * (999999999999 * mass), hitOffset) end end ent:TakeDamage(999999999999, self, self) end end return hit end function ENT:IsHidingSpotFull(hidingSpot) local occupant = hidingSpot.occupant if (not IsValid(occupant) or occupant == self) then return false end return true end function ENT:GetNearestUsableHidingSpot() local nearestHidingSpot = nil local nearestHidingDistSqr = 1e8 local myPos = self:GetPos() local isHidingSpotFull = self.IsHidingSpotFull local distToSqr = myPos.DistToSqr return nearestHidingSpot end function ENT:ClaimHidingSpot(hidingSpot) if (self.HidingSpot ~= nil) then self.HidingSpot.occupant = nil end if (hidingSpot == nil or self:IsHidingSpotFull(hidingSpot)) then self.HidingSpot = nil return false end self.HidingSpot = hidingSpot self.HidingSpot.occupant = self return true end function ENT:AttemptJumpAtTarget() if (not self:IsOnGround()) then self:StartActivity( ACT_JUMP ) return end local xyDistSqr = (self.CurrentTarget:GetPos() - self:GetPos()):Length2DSqr() local zDifference = self.CurrentTarget:GetPos().z - self:GetPos().z if (xyDistSqr <= math.pow(100 + 200, 2) and zDifference >= 100) then local jumpHeight = zDifference + 50 self.loco:SetJumpHeight(jumpHeight) self.loco:Jump() self.loco:SetJumpHeight(2000) end self:Animation() end local VECTOR_HIGH = Vector(0, 0, 16384) ENT.LastPathingInfraction = 0 function ENT:RecomputeTargetPath() if (CurTime() - self.LastPathingInfraction < PATH_INFRACTION_LOCKOUT_TIME) then return end local targetPos = self.CurrentTarget:GetPos() trace.start = targetPos trace.endpos = targetPos - VECTOR_HIGH trace.filter = self.CurrentTarget local tr = util.TraceEntity(trace, self.CurrentTarget) if (tr.Hit and util.IsInWorld(tr.HitPos)) then targetPos = tr.HitPos end local rTime = SysTime() self.MovePath:Compute(self, targetPos) if (SysTime() - rTime > 0.005) then self.LastPathingInfraction = CurTime() end end function ENT:BehaveStart() self.MovePath = Path("Follow") self.MovePath:SetMinLookAheadDistance(500) self.MovePath:SetGoalTolerance(10) end function ENT:BehaveUpdate() if (CurTime() - self.LastTargetSearch > 1) then local target = self:GetNearestTarget() if (target ~= self.CurrentTarget) then self.LastPathRecompute = 0 end self.CurrentTarget = target self.LastTargetSearch = CurTime() end if (IsValid(self.CurrentTarget)) then if (self:AttackNearbyTargets(100)) then if (CurTime() - self.LastTaunt > TAUNT_INTERVAL) then self.LastTaunt = CurTime() end self.LastTargetSearch = 0 end if (CurTime() - self.LastPathRecompute > 0.1) then self.LastPathRecompute = CurTime() self:RecomputeTargetPath() end self.MovePath:Update(self) if (self:IsOnGround()) then if (CurTime() - self.LastJumpScan >= 0.5) then self:AttemptJumpAtTarget() self.LastJumpScan = CurTime() end end end if (CurTime() - self.LastCeilingUnstick >= 1) then self:UnstickFromCeiling() self.LastCeilingUnstick = CurTime() end if (CurTime() - self.LastStuck >= 5) then self.StuckTries = 0 end end ENT.LastStuck = 0 ENT.StuckTries = 0 function ENT:OnStuck() self.LastStuck = CurTime() self:SetPos(self.MovePath:GetPositionOnPath(self.MovePath:GetCursorPosition() + 40 * math.pow(2, self.StuckTries))) self.StuckTries = self.StuckTries + 1 self.loco:ClearStuck() end function ENT:UnstickFromCeiling() if (self:IsOnGround()) then return end local myPos = self:GetPos() local myHullMin, myHullMax = self:GetCollisionBounds() local myHull = (myHullMax - myHullMin) local myHullTop = myPos + vector_up * myHull.z trace.start = myPos trace.endpos = myHullTop trace.filter = self local upTrace = util.TraceLine(trace, self) if (upTrace.Hit and upTrace.HitNormal ~= vector_origin and upTrace.Fraction > 0.5) then local unstuckPos = myPos + upTrace.HitNormal * (myHull.z * (1 - upTrace.Fraction)) self:SetPos(unstuckPos) end end else killicon.Add("qtg_invincible_npc", "neptune_qtg/npc/killicon/qtg_invincible_npc", color_white) language.Add("qtg_invincible_npc", "QTG Invincible Npc") end list.Set("NPC", "qtg_invincible_npc", { Name = "QTG Invincible Npc", Class = "qtg_invincible_npc", Category = "Neptune QTG NPCs", AdminOnly = true })
What now? Do you want us to look through all 1303 lines of code? also on first line you do AddCSLuaFile with no arguments. What? why? Even the gmod wiki says WARNING If the file trying to be added is empty, an error will occur, and the file will not be sent to the client.
no need you to see that code ,, i just want to know any idea for bypass ENT:Remove()
why do you spam the replys.
use code tags pls and short the code to important things.. if you want an ent thats not removed if you make ENT:Remove() then dont code a ent:REmove() function if you mean PostCleanup or if you do a mapclean up you need two hooks first the hook before cleanup to save the placed entity and then the hook after clean up to spawn the placed entity. Before: GM/PreCleanupMap After: GM/PostCleanupMap and just make sure to savethe ents in a table.. like this: hook.Add("PreCleanupMap", "DenyCleanupPre", function(ply) SavedEnts = {} for index, en in pairs(ents.GetAll()) do if en.DontCleanUp then -- this is a little ent config option to get a ent a not cleanup variable SavedEnts [#SavedEnts +1] = { Pos = en:GetPos(), Ang = en:GetAngles(), Class = en:GetClass(), Model = en:GetModel(), } end end end) hook.Add("PostCleanupMap", "DenyCleanup", function(ply) for index, info in pairs(SavedEnts ) do local ent = ents.Create(info.Class) if IsValid(ent) then ent:SetPos(info.Pos) ent:SetAngles(info.Ang) ent:SetModel(info.Model) ent:Spawn() ent:Activate() SavedEnts = nil end end end) i dont know if you mean this... but this could be helpful aswell
Sorry, you need to Log In to post a reply to this thread.