Entity Spawner

I am working on a gamemode and I just made a spawner entity. I am wondering how I can make that spawner track the entities that it has spawned so that if one disappeared/dies it knows it can spawn another one.

An example would be:

A zombie spawner, since you don’t want the spawner endlessly spawning, you would put a limit on how many it can spawn at a time. How can I make the spawner track the zombies it has spawned and if one dies it can spawn another.

Thanks.

[LUA]
function ENT:yourspawnfunction()
if table.Count(self.SpawnedEnts) >= SpawnLimit then return end
/* your spawning stuff */
table.insert(self.SpawnedEnts,entity)
end

function ENT:Think()
/* your own stuff in ENT:Think() */
for k,v in pairs(self.SpawnedEnts) do
if not v:IsValid() then table.remove(self.SpawnedEnts,k) self:yourspawnfunction() end
end
end
[/LUA]

something like that I guess?

You would probably want to do Entity.CallOnRemove instead of checking each ent in Think.