Basically I have two teams. Is there a way to make it so when a player joins the server they would get moved to the team with the least players straight away?
Thanks a lot!
[lua]function hi( ply )
if (team.NumPlayers(1) < team.NumPlayers(2)) then
ply:SetTeam(1)
elseif (team.NumPlayers(2) < team.NumPlayers(1)) then
ply:SetTeam(2)
end
end
hook.Add( "PlayerInitialSpawn", "978857645768608678696", hi )[/lua]
Something along those lines for a noob to understand
You could also use this
[b][url=http://wiki.garrysmod.com/?title=Team.BestAutoJoinTeam]Team.BestAutoJoinTeam [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[QUOTE=wakeboarderCWB;33821982]You could also use this
[b][url=http://wiki.garrysmod.com/?title=Team.BestAutoJoinTeam]Team.BestAutoJoinTeam [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b][/QUOTE]
that too
Thanks! And that would go into init.lua correct?
yeah, or shared.lua if you are using wakeboarder's method
Mine can be used on server aswell. The example it gives
[lua]
function GM:PlayerInitialSpawn( ply )
self.BaseClass:PlayerInitialSpawn( ply )
ply:SetTeam ( team.BestAutoJoinTeam() )
end[/lua]
is used in init.lua
don't call self.BaseClass:PlayerInitialSpawn()
it gives my gamemodes an error that stops the gamemode from loading.
Even if i do it on a gamemode with literally nothing in it
Sorry, you need to Log In to post a reply to this thread.