Quick question: setting a limit on teams

Hey, just a quick one: how could I make it so that only a certain amount of players can be in one team? Not sure if there’s a hook for this or not, I just managed to find TeamHasEnoughPlayers on the wiki.

There you go

[lua]
function GM:PlayerSpawn(ply) --if it is an hook
if team.NumPlayers(TEAM_INDEX_HERE) < maxteamnumber then
ply:SetTeam(TEAM_INDEX_HERE)
else
ply:SetTeam(ANOTHER_TEAM_INDEX_HERE)
end
end
[/lua]

Thanks.