Entity Spawn Pos

Help me get started…
OK so i have several props that I want to spawn, but I don’t want to spawn them on top of each other(They spawn from an NPC). What I’m trying to do is spawn them and then add 1 to a variable which is in an if statement changing the spawn position with every consecutive iteration. I’m guessing I would have to make functions in order to change the variable and check it.

Are there any BETTER, more efficient ways of changing the spawn position?

Edit: More Here
Or 3rd post

[lua]local pos, dir = Vector(0,0,0), Vector(0,1,0)
local step = 128
for i = 0,4 do
local npc = ents.Create(“npc_zombie”)
npc:SetPos(pos + dir * step * i)

Completely untested but this should spawn you a nice line of zombies.

I don’t know if that’s what you had in mind. If it isn’t this still shows how to increment a variable and use it in the context of a loop.

Thanks for the reply Crazy Quebec, but not exactly.

This is what I have, I’m running this function every time I press a button.
It returns a new spawn position, I’m checking whether there is a vehicle in the sphere. Yet every time it runs the First debug position.
What am i doing wrong?
[lua]local function checkSpawn(spawnPos)
local orgin_ents = ents.FindInSphere(spawnPos, 200)
if orgin_ents == nil then
pos = Vector(380.685699, 186.020569, -84.183701)
Msg("First Debug
return pos
for k,v in pairs(orgin_ents) do
if v:GetClass()==“prop_vehicle_jeep” then
Msg("Second Debug!
pos = Vector(81.458130, 297.146637, -84.165848)
return pos

Somewhere else what calls the function.
spawnPos is defined on map-start.
If I switch the position vectors it spawns at the switched position.
So it’s a problem in the for loop.
[lua]spawnPos = checkSpawn(spawnPos)[/lua]