Xeno Posted December 13, 2011 Posted December 13, 2011 So say I had two teams, how would I even out the number of players on each one onPlayerJoin? team1 = createTeam("Team1", 255,255,255) team2 = createTeam("Team 2",0,255,255) function onPlayerJoin() end addEventHandler("onPlayerJoin", ect ect... I would appreciate it if you could help me.
Castillo Posted December 13, 2011 Posted December 13, 2011 team1 = createTeam("Team1", 255,255,255) team2 = createTeam("Team 2",0,255,255) function onPlayerJoin() outputChatBox("Team 1 has: ".. tostring(countPlayersInTeam(team1)) .." players.", source) outputChatBox("Team 2 has: ".. tostring(countPlayersInTeam(team2)) .." players.", source, 0,255,255) end addEventHandler("onPlayerJoin", root, onPlayerJoin)
Xeno Posted December 13, 2011 Author Posted December 13, 2011 team1 = createTeam("Team1", 255,255,255) team2 = createTeam("Team 2",0,255,255) function onPlayerJoin() outputChatBox("Team 1 has: ".. tostring(countPlayersInTeam(team1)) .." players.", source) outputChatBox("Team 2 has: ".. tostring(countPlayersInTeam(team2)) .." players.", source, 0,255,255) end addEventHandler("onPlayerJoin", root, onPlayerJoin) No no, not like that. I mean, say if I had 4 players on one team, and 5 on another, a new player would be put in the team with 4 players in, and not 5, to even out the number of players on each team.
12p Posted December 13, 2011 Posted December 13, 2011 Use a comparison between the players in team A and the players of team B. countPlayersInTeam
Xeno Posted December 13, 2011 Author Posted December 13, 2011 Use a comparison between the players in team A and the players of team B. countPlayersInTeam So something like on the wiki page? function balanceTeams ( thePlayer ) --get the team pointers from their names local groveTeam = getTeamFromName ( "grove" ) local ballasTeam = getTeamFromName ( "ballas" ) --count the number of players in each team, and store them local groveCount = countPlayersInTeam ( groveTeam ) local ballasCount = countPlayersInTeam ( ballasTeam ) if groveCount == ballasCount then --if the teams are equal setPlayerTeam ( thePlayer , groveTeam ) --place the player in grove elseif groveCount > ballasCount then --if there are more in grove setPlayerTeam ( thePlayer , ballasTeam ) --place him in ballas elseif groveCount < ballasCount then --if there are more in ballas setPlayerTeam ( thePlayer , groveTeam ) --place him in grove. end end ??
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now