• Entities not respawning correctly
    3 replies, posted
Entity being respawned: AddCSLuaFile("shared.lua") AddCSLuaFile("cl_init.lua") include("shared.lua") resource.AddFile("addons/darkrpmodification-master/sound/booyah.mp3") local cooldown = 30 local t = 0 local interval = 5 function ENT:Initialize()     util.PrecacheSound("addons/coin_pickup/sound/Lemons.wav")     self:SetModel("models/props_c17/doll01.mdl")     self:SetMaterial("models/shiny")     self:PhysicsInit(SOLID_VPHYSICS)     self:SetMoveType(MOVETYPE_NONE)     self:SetSolid(SOLID_VPHYSICS)     self:SetColor(Color(255,221,0))     local phys = self:GetPhysicsObject()     if (phys:IsValid()) then         phys:Wake()     self:SetCollisionGroup(COLLISION_GROUP_WEAPON)          self:SetTrigger(true)--start touch events or others     self:DrawShadow(false)     self.PlyDelays = {} end end function ENT:PhysgunPickup(ply,ent)     if ply then return end end function ENT:GravGunPickupAllowed(ply,ent)     if ply then return end end function ENT:Touch(e) if e:IsPlayer() and e:Team() == TEAM_HOBO then self:EmitSound("booyah.mp3")             table.insert(e.ScavItems, self:GetClass()) self:Remove() return end     local curtime = CurTime()     local ID = e:GetCreationID()         if self.PlyDelays[ID] and self.PlyDelays[ID] > curtime then return end               self.PlyDelays[ID] = curtime + cooldown               if e:IsPlayer() and e:Team() != TEAM_HOBO then            e:SendLua("chat.AddText(Color(255,0,0), 'You are not the right job!')") return end end Entity doing the respawning: AddCSLuaFile("shared.lua") AddCSLuaFile("cl_init.lua") include("shared.lua") local spawnPos = { Vector(-810.278809, 850.462097, -12223.968750), Vector(790.265930, 775.635620, -12223.968750), Vector(751.735107, -783.828308, -12223.968750), Vector(-815.747437, -719.911682, -12223.968750), Vector(-154.760635, -79.551308, -12223.968750), } function ENT:Initialize()     self:SetModel("models/props_lab/huladoll.mdl")     self:SetMaterial("models/shiny")     self:PhysicsInit(SOLID_VPHYSICS)     self:SetMoveType(MOVETYPE_NONE)     self:SetSolid(SOLID_VPHYSICS)     self:SetColor(Color(255,221,0))     local phys = self:GetPhysicsObject()     if (phys:IsValid()) then         phys:Wake()     self:SetCollisionGroup(COLLISION_GROUP_WEAPON)          self:SetTrigger(true)--start touch events or others     self:DrawShadow(false)     self.PlyDelays = {}     for i = 0, 3 do     local ent = ents.Create("scav_common")         ent:SetPos(spawnPos[math.random(1, table.Count(spawnPos))])         ent:Spawn()         ent:Activate()         ent:CallOnRemove("scavrespawn", function() timer.Simple(5, function() local ent = ents.Create("scav_common") ent:SetPos(spawnPos[math.random(1, table.Count(spawnPos))]) ent:Spawn() end ) end) end self:Remove() end end Issue: The entity seems to respawn as intended until the entity gets stacked on itself too many times after I collect the stack of them it just stops respawning. Any clue as to why this is?
The code is called only when the entity is removed, what happens to them when you collect them?
They're removed
Try making a function defined in your gamemode that spawn a new scav_common, then run the function instead of rewriting it everytime. If that doesn't work have the function return the entity itself and check if it was created. Not sure what other reason it's not spawning.
Sorry, you need to Log In to post a reply to this thread.