random car spawning

how would i make cars spawn at given vectors when my server starts up? would i spawn it in through a entity?

You’d want to spawn them within this hook

GM/InitPostEntity

thanks and i know there is some sort of console command for spawning cars but that doesnt let you spawn them in on vectors, so if i would be using that how would i actually spawn them in at given vectors, and multiple ones

[editline]10th May 2015[/editline]

would i create it through an entity

ents.Create

Entity:SetPos

Example from Wiki:
[lua]
local button = ents.Create( “gmod_button” )
if ( !IsValid( button ) ) then return end // Check whether we successfully made an entity, if not - bail
button:SetModel( “models/dav0r/buttons/button.mdl” )
button:SetPos( Vector( 0, 0, 100 ) )
button:Spawn()
[/lua]




GM.EntsSpawn = {}
GM.EntsSpawn["rp_bangclaw"] = {Vector(139.617477, -941.014038, 81.789017),Vector(118.631638, -122.643875, 81.079865),Vector(1263.070435, -139.263702, 80.794846),Vector(1268.770996, -955.267273, 77.933685)}

function GM.SpawnEnts()

   for k,v in pairs( GM.EntsSpawn[string.lower(game.GetMap())] )  do
   
      local Entity = ents.Create("Entity Class Here")
      Entity:SetPos(v)
      Entity:Spawn()
      
   end
end


hook.Add("InitPostEntity","GM:MapSetup",function()

   if( GM.EntsSpawn[string.lower(game.GetMap())]) then
      GM.SpawnEnts()
   end
  
   
end)



That’s how you can create multiple of them however you should add a validity check like the OP did.

thanks but if im right this only spawns 1 type of car?

You could really easily adjust the script to change what car you want to spawn, At least attempt it yourself before opening your mouth for the spoonfeed.

i was asking a question… i didnt say well this only spawns 1 type of car make me a new script did i?

[editline]10th May 2015[/editline]

well anyway thanks for the help i managed to get it sorted!