ZombieRP; Entities Spawn Around the Map Help

Hello Facepunch.

I own a ZombieRP server on Garry’s Mod and my server contains Vehicles, Weapons, Food, (Can’t get Hunger Bar working) and much more supplies such as fuel and Body Armor.
Is there a Code to have entities spawn every server start and people can grab because I used Falco’s script http://forum.facepunch.com/showthread.php?t=735138 and it didn’t seem to work
on entities. Any help from a developer would be greatly appreciated.

~ Kajentan

I was bored so here you go

[lua]

–Put this code into a file and save it in the servers lua/autorun directory
if CLIENT then return end

–Example Entities, Change them to the Class name of the entites you want to spawn
–You can have as many as you like, simply add a comma at the end of the line when adding another
–(Pro Tip: if you want an entity to spawn more then others, simply add it’s name to this table multiply times)
local EntityList = {
“weapon_ar2”,
“weapon_physgun”,
“weapon_crowbar”
}

–Example positions, You can have as many as you want, to get a position in game type “getpos” into console
–The first 3 numbers printed after that console command should be put into the Vector format seen below.
local PositionList = {
Vector(0,0,0),
Vector(10,100,0),
Vector(5,10,2),
Vector(100,50,4)
}

–This is what will spawn the entites in the first list, randomly, at the positions in the second list
–You should not have to modify this; unless you know what you’re doing leave it be
local function SpawnEntities()
print(“Spawning Entites On The Map.”)
for _, pos in pairs( PositionList ) do
local ent = ents.Create(EntityList[math.random(#EntityList)])
ent:SetPos(pos)
ent:Spawn()
end
end
hook.Add( “InitPostEntity”, “MapStartEntites”, SpawnEntities )
[/lua]

The comments should explain everything, if for what ever reason you have any questions; i’ll watch this thread for the night.

Sorry, I know this is a bit old, but is there a way to make it repeat with a timer? So that every time the timer finishes it resets to a random time between two numbers(math.random(lowest,high) stuff. Like every 2-5 minutes it spawns a random weapon in only ONE of the random spots?
Sorry if this is asking a bit much.

Edit: Nevermind, it took me a bit of time to figure it out figuring idk much lua but I took your code and modified it to do what I need it to, besides the one position thing which I don’t really need
–Put this code into a file and save it in the servers lua/autorun directory


if SERVER then return
spawnTimer()
end


function spawnTimer()
timer.Create( "Entity Spawn", math.random(5,10), 0, entitySpawn)
end




local EntityList = {
	"weapon_ar2",
	"weapon_physgun",
	"weapon_crowbar"
}


local PositionList = {
	Vector(184, -541, -55),
	Vector(-1136.8, -1425, 304)
}


function entitySpawn()
	print("Entities Spawning")
	for _, pos in pairs( PositionList ) do
		local ent = ents.Create(EntityList[math.random(#EntityList)])
		ent:SetPos(pos)
		ent:Spawn()
	end
end

Edit2: Ok nevermind I need help again cause this isn’t fully working right