Creating Team-specific Spawn points

I’m trying to make a custom gamemode. I already set up multiple spawnpoints that players randomly spawn on, but anyone from any team could spawn at any point. I want to segregate the spawn points by teams (so certain players always spawn at certain points, or a select group of points, and the other team has their own points). Does anyone know how to do this? I found some references to the Team.SetSpawnPoint function, but I’m not sure how to implement it, and all of my attempts have failed.

I should note that I’m working in the HL2 engine, and thus only have info_player_starts available. How would I differentiate between which ones a player on team 2 or whatever can spawn at? I did read something about searching for spawnpoints at certain entities. For instance, I found this piece of code;

team.SetSpawnPoint( TEAM_TERRORIST, “info_player_terrorist” );
team.SetSpawnPoint( TEAM_COUNTERTERRORIST, “info_player_counterterrorist” );

That goes in the init, I believe. Anyways they’re clearly defining spawn entities here. Does this mean that I could tie a spawn point to another entity, like a logic relay or a prop? I haven’t gotten that to work so far, but I’m wondering if it’s at least possible.

Just to be thorough, I should also note that I tried this piece of code too;

function GM:PlayerSpawn(ply)
if ply:Team() == TEAM_0 then
local points = ents.FindByClass(“info_player_start”)
ply:SetPos(points[math.random(1,#points)]:GetPos())
end
end

And I set up a similar function for the other team, and told it to find a different entity class for spawning. Didn’t work. Everyone could still spawn at every spawn point that was set around a player_start, and nothing else.

Anyways, does anyone know how this is done? Also, how would I check to see if a spawn point is blocked?

Bumpers. There must be someone around here who has done exactly this.

TEAM_0 is invalid I think

That was just me quickly plugging my version into the original. In my PlayerSpawn function, I put the local points and SetPos lines under my “if team = 1” or whatever it was. The rest of the function was working, and I was successfully giving different players different loadouts.

Sorry for the confusion.

Welp, bump. It’s been a week.

Would I have to create a table for each team and define exactly where each spawn point that team can use is, rather then having a mapwide search for a certain entity? I think I’ve seen a few examples of that, but I don’t know if it applies here.