Smart NPCs Spawn


function DraugrR()
local draugr = ents.Create( "npc_draugr" )
draugr:SetModel( "models/skyrim/draugr.mdl" )
draugr:SetPos( Vector( -2050.967041, 582.353149, -1471.968750 ) )
draugr:Spawn()
end
timer.Create( "draugr", 10, 0, DraugrR )

Please help!
how to make that if more than three npcs,others not spawn more?

Use the function ents.FindByClass and compare the amount of them to the max amount.
[lua]
local maxEnts = 8
if ( #ents.FindByClass( “npc_draugr” ) < maxEnts ) then
– spawn entity
end
[/lua]
Something like this if I understood you correctly.

Yes,yes.
Thanks for this!

But I have another problem. Need (automatically) to remove their corpses every 3-5 mins.

use a timer then remove self