Random spawning props

So, I have been messing around with making a gamemode lately, and I have been trying to make props spawn randomly throughout the map. I managed to make the props spawn, but they are all in the same place, can someone tell me how i can make it random spawning? heres my code:



function SpawnProps()
	SpawnProp(Vector( 0, 0, 0 ), "models/props_lab/blastdoor001c.mdl")
	SpawnProp(Vector( 0, 0, 0 ), "models/props_wasteland/cargo_container01b.mdl")
	SpawnProp(Vector( 0, 0, 0 ), "models/props_interiors/VendingMachineSoda01a.mdl")
	SpawnProp(Vector( 0, 0, 0 ), "models/props_combine/combine_window001.mdl")
end
hook.Add("InitPostEntity","SpawnTheProps",timer.Simple(1,SpawnProps))

function SpawnProp(position, model)
		local ent1 = ents.Create("prop_physics")
		local ang = Vector(0,0,1):Angle();
		ang.pitch = ang.pitch + 90;
		ang:RotateAroundAxis(ang:Up(), math.random(0,360))
		ent1:SetAngles(ang)
		ent1:SetModel(model)
		local pos = position
		pos.z = pos.z - ent1:OBBMaxs().z
		ent1:SetPos( pos )
		ent1:Spawn()
end


You could put the data into a table like

[lua]local props = {}
props[1] = { Vector( 0, 0, 0 ), “models/blah/blah/blah.mdl” }
props[2] = { Vector{ 1, 1, 1 ), “models/blah/blah/blah2.mdl” }[/lua]

then use [lua]math.Rand( 0, #props )[/lua] to pick an entity to spawn

[lua]local entity = math.Rand( 0, #props )
local pos = entity[1]
local mdl = entity[2][/lua]

using tables like props[1] is a terrible an inefficient way, use it like this:
[lua]
local props = {
{Vector( 0, 0, 0 ), “models/blah/blah/blah.mdl” },
{ Vector{ 1, 1, 1 ), “models/blah/blah/blah2.mdl”}
}
[/lua]

[lua]local t = SysTime()
local tbl = { { Vector( 0, 0, 0 ), “model/blah/blah/blah.mdl” }, { Vector( 1, 1, 1 ), “model/blah/blah/blah2.mdl” } }
local t2 = SysTime()

print( t2 - t )

local t = SysTime()
local tbl = {}
tbl[1] = { Vector( 0, 0, 0 ), “model/blah/blah/blah.mdl” }
tbl[2] = { Vector( 1, 1, 1 ), “model/blah/blah/blah2.mdl” }
local t2 = SysTime()

print( t2 - t )[/lua]

http://puu.sh/1Q7EZ

Seems identical, and possibly that remotely faster.

Your argument is invalid.