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 ) )
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.
local maxEnts = 8
if ( #ents.FindByClass( “npc_draugr” ) < maxEnts ) then
– spawn entity
Something like this if I understood you correctly.

Thanks for this!

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

use a timer then remove self