Spawn NPCs on ENT?

I want to make zombie gamemode.

but i don’t know how can i spawn zombie on Player’s spawn point?

(Sorry for my bad english, If it bad i’m Thai)

local ent = ents.Create("npc_zombie") // creates the npc
	local spawns = ents.FindByClass("info_player_spawn") // gets the table whit avalible spawns
	ent:SetPos(spawns[math.random(1,#spawns]) // sets the pos of the zombie to an random spawn point
	ent:Spawn() // spawns the npc since when you create one, it isnt spawned yet!

there ya go^^

btw, my english is more terible so u shount feel guilty about it^^

thank you ! but how can i set maximum of them?
and how can i countdown to create zombie?

[lua]NumberOfZombies = 0
ZombieLimit = 10

function SpawnZombies()
if NumberOfZombies < ZombieLimit then --If there are less zombies then the limit then
–code to create a zombie
NumberOfZombies = NumberOfZombies + 1–increment the counter

timer.Create( “ZombieTimer”, 15, 0, SpawnZombies ) --This runs SpawnZombies each 15 seconds forever until stopped by timer.Remove()

hook.Add(“OnNPCKilled”, “ZombieCount”, function( victim, killer, weapon ) – Each time a Zombie is killed substract 1 to the total zombie ammount
if victim:GetClass() == “npc_zombie” then
NumberOfZombies = NumberOfZombies - 1


YOU stole me job! you ninja!

Thanks ! I will test it.