lua nextbot autoduplicate

Hi I’m new to Lua and I’m making my first project: an autoreplicant citizen that after tot seconds make an exact copy of himself (same weapon but not necessarily the same citizen model) in front of him.Sorry If seems that I’m trying to have a full code without doing anything but I didn’t find anything searching on forums or in codes of other nextbots so I dunno what to do

Hmm… you could maybe try writing some code. We can’t really help you here without any code. Have you started to form the base of the NPC at all?

ok nevermind I fixed it by myself but I have a little problem.When a copy of the entity spawns the code doesn’t consider it just like a npc so If I kill the npc that I SPAWNED the duplicating process stops…how to make it stops only when all the entities are died? I tried “timer.destroy” but it isn’t a fix because I need to know how to consider the duplicated nextbots like the spawned one so I can kill them for stopping the process instead of just killing the first nextbot spawned.I thought about a function like if !alive then timer.destroy (“Duplication”) where alive is the escaper_nextbot counter that gives 0 if it doesn’t find any nextbot of that type but how to indicate the duplicated entities? Apparently use dupl gives only a bunch of errors…

function dehdupl()

local dupl = ents.Create( "escaper_nextbot" )

dupl:SetPos( Vector( 0, 0, 0 ) )
timer.Create( "Duplication", 3, 0, dehdupl )


BUMP again

[lua]local maxNPCs = 60 – Don’t crash the game with too many entities
local ent_string = “escaper_nextbot” – name
local time_between = 30 --seconds

timer.Create( “Dont_bump_a_thread_within_7_hours”,time_between , 0, function()
local elist = ents.FindByClass(ent_string)
if #elist>=maxNPCs then return end – Don’t create too many

for I=1,math.min(#elist,maxNPCs-#elist) do -- Duplicate them, but don't go over the max
	local nent = ents.Create(ent_string)

end )[/lua]


All I did was watching your thread guys…searching on the forum everyone that didn’t have an answer in a day have bumped… so stop fooling around…