Gamemode with teams, how to set spawns for each team? ( X Y Z )

Okay, here’s my problem guys. I am making a test gamemode ( Using http://wiki.garrysmod.com/?title=LUA:Gamemode_from_scratch including page 2. )
However, I would like to have a specific spawn point for each team using XYZ coords.

For example, Team 1 would spawn in 143, 51, -9 . Team 2 = 21, -55, 93, etc. :words:

Any ideas? :pwn:

Something like this should work.
[lua]
local SpawnPoints = {
[“Team00”] = Vector(0,0,0),
[“Team01”] = Vector(1,1,1),
[“Team02”] = Vector(2,2,2),
[“Team03”] = Vector(3,3,3)
}

hook.Add(“PlayerSpawn”, “Team_PlayerSpawn”, function(ply)
local Team = team.GetName(ply:Team())
local pos = SpawnPoints[Team]

ply:SetPos(pos)

end)
[/lua]
Untested.

That would go in init.lua?

Yes.

Now, what if I wish to make them spawn with the toolgun, I would have to use ply:Give ( ??? )

I dont know the name of the toolgun in that case. Help me please?

gmod_tool I believe.

[lua]
local TeamTbl = {}
TeamTbl[1].Positions = {}
TeamTbl[1].Positions[“The lake or something”] = Vector(0,0,0)
TeamTbl[1].Positions[“The River”] = Vector(50,50,50)
TeamTbl[1].Give = {“gmod_tool”,“weapon_fiveseven”,“weapon_physcannon”}

hook.Add("PlayerSpawn","CallTables",function(player)
	for k,v in pairs(TeamTbl) do
		if player:Team() == v[k] then
			player:Give(v.Give)
			player:SetPos(table.Random(TeamTbl.Positions))
		end
	end
end)

[/lua]
I came up with this real quick, not sure if it works but it’s an example.

Thanks for the help guys, got it all working :slight_smile: