ents.Create One at a Time?

[lua]
local function SpawnEntities()
if SERVER then
local zombie = ents.Create(“npc_zombie”)
local pistolammo = ents.Create(“item_ammo_pistol”)
local threefiftyammo = ents.Create(“item_ammo_357”)
pistolammo:SetPos(Vector(-702, 652, -195))
pistolammo:SetAngles(Angle(28, 80, 0))
pistolammo:Spawn()
threefiftyammo:SetPos(Vector(-88, 1874, -131.1111))
threefiftyammo:SetAngles(Angle(28, 80, 0))
threefiftyammo:Spawn()
zombie:SetPos(Vector(-88, 1874, -170))
zombie:SetAngles(Angle(0, 0, 0))
zombie:Spawn()
end
end
hook.Add( “InitPostEntity”, “SpawnEntities”, SpawnEntities)

timer.Create(“timer1”, 1000, 1, SpawnEntities)
[/lua]
Currently what I have. How can I make it so these entities create ONE AT A TIME instead of just glitching into eachother?
Thanks in advance!

I am confused, why should they glitch into each other? The position seems far enough and could you be more specific about how do you want them to spawn? Just a second after each other? And i noticed you spawn them in the hook and then again with timer, guess thats your problem

I would like to have it so once that zombie has died, another one spawns. And yes they glitch into each other, they spawn on top of each other.

[editline]8th February 2013[/editline]

And the gun ammo spawns a couple minutes after someone has picked it up.

try setting the the timer to like 5 or 10 so the npc’s have a chance to walk away

Bro they wont walk away unless someone is near… Thanks for trying though.

Can I get someone to help please? Brandon? I know youre pretty good with lua.


local function SpawnEntities()
    if SERVER then
        local zombie        = ents.Create("npc_zombie")
        local pistolammo        = ents.Create("item_ammo_pistol")
        local threefiftyammo    = ents.Create("item_ammo_357")
        pistolammo:SetPos(Vector(-702, 652, -195))
        pistolammo:SetAngles(Angle(28, 80, 0))
        pistolammo:Spawn()
        threefiftyammo:SetPos(Vector(-88, 1874, -131.1111))
        threefiftyammo:SetAngles(Angle(28, 80, 0))
        threefiftyammo:Spawn()
        zombie:SetPos(Vector(math.random(-50, - 150), math.random(1600, 1900), -170))
        zombie:SetAngles(Angle(0, 0, 0))
        zombie:Spawn()
    end
end
hook.Add( "InitPostEntity", "SpawnEntities", SpawnEntities)
 
timer.Create("timer1", 1000, 1, SpawnEntities)

Umm Minteh what is that supposed to do? It doesn’t work, I’ll tell you that.

It says that they will spawn on random locations.

He randomized the vectors, which is dumb.

You can always just check the sphere and see if there’s a zombie in it, if not, then spawn another.

Lerpaderp, that was EXACTLY what I was thinking! But, I’m new to coding and I don’t quite know how I would do that… Any tips man?

[LUA]for k,v in pairs(ents.FindInSphere( Vector(-88, 1874, -170), 100 ) do
if v:GetClass() != “npc_zombie” then
zombie:Spawn()
end
end[/LUA]

–EDIT-- Lerpaderp probably knows a better way, if there is a better way.

Thank you my good man.

[editline]9th February 2013[/editline]

Yeah umm it worked for a sec, stopped working :confused:

No worries, hope it works.

Yeah it may be because when the zombie dies in the sphere, its still detecting the ragdoll?

[editline]9th February 2013[/editline]

It only spawns once, then stops. I made sure to change the timer to 0, so its not that.

[editline]9th February 2013[/editline]

Is the error I get

[LUA]
for k,v in pairs(ents.FindInSphere( Vector(-88, 1874, -170), 100 )) do
if v:GetClass() != “npc_zombie” then
zombie:Spawn()
end
end
[/LUA]
I missed out an “)” to see if you’d spotted it or not, but apparently not.

If you want to make a DayZ gamemode, and you can’t even spot a tiny mistake which is even an easy fix because it TELLS you what to fix, you should maybe stick to more simpler things. Not trying to be mean, just hinting you.

It even says - On line 61, you’re missing an ‘)’ near ‘do’, it’s extremely easy to spot buddy.

Sorry… I wasn’t paying attention…

[editline]9th February 2013[/editline]

Wait, it’s not preventing it… Am I doing something wrong?
[lua]
local function SpawnEntities()
if SERVER then
local zombie = ents.Create(“npc_zombie”)
local pistolammo = ents.Create(“item_ammo_pistol”)
local threefiftyammo = ents.Create(“item_ammo_357”)

    pistolammo:SetPos(Vector(-4155, -809, 130))
    pistolammo:SetAngles(Angle(0, 0, 0))
	for k, v in pairs(ents.FindInSphere(Vector(-4155, -809, 130), 300)) do
		if v:GetClass() != "item_ammo_pistol" then
	pistolammo:Spawn()
	end
	end
end

end
timer.Create(“SpawnEntitiesTimer”, 4, 0, SpawnEntities)
[/lua]

Any help?

This problem is really annoying… Any help? Someone?

Are you still talking about the zombie problem?