Evil-Cod3r Posted March 5, 2012 Share Posted March 5, 2012 Hi all i want to Make script Team ballance if team 1 = 10 players i write /b the teams well be team 1 = 5 team 2 = 5 i want the script automauicy get teams Name what ever they are ! can some one give me the functions and events i need to make this script ? Link to comment
Castillo Posted March 5, 2012 Share Posted March 5, 2012 You want to make a script which will check the players in each team and output the names with players to chat? If so: addCommandHandler getTeamFromName countPlayersInTeam Link to comment
Evil-Cod3r Posted March 5, 2012 Author Share Posted March 5, 2012 i want script check the teams if team 1 = team 2 count then play the map else make teams the same team 1 = 5 players team 2 = 5 players and play the Map ! Link to comment
Castillo Posted March 5, 2012 Share Posted March 5, 2012 Well, you can use countPlayersInTeam to count players in a team. Link to comment
Evil-Cod3r Posted March 5, 2012 Author Share Posted March 5, 2012 what if teams keep changeing ? function balanceTeams ( thePlayer ) local Team1 = getTeamFromName () local Team2 = getTeamFromName () local Count1 = countPlayersInTeam () local Count2 = countPlayersInTeam () if Count1 == Count2 then setPlayerTeam ( thePlayer , Team1 ) elseif Count1 > Count2 then setPlayerTeam ( thePlayer , Team2 ) elseif Count1 < Count2 then setPlayerTeam ( thePlayer , Team2 ) end Link to comment
Castillo Posted March 5, 2012 Share Posted March 5, 2012 Well, I guess you have defined the team when you create them, like this: team1 = createTeam("Test 1", 255, 255, 255) team2 = createTeam("Test 2", 255, 255, 255) function balanceTeams ( thePlayer ) local Count1 = countPlayersInTeam (team1) local Count2 = countPlayersInTeam (team2) if (Count1 == Count2) then setPlayerTeam ( thePlayer, team1 ) elseif (Count1 > Count2) then setPlayerTeam ( thePlayer, team2 ) elseif (Count1 < Count2) then setPlayerTeam ( thePlayer, team2 ) end end Link to comment
Evil-Cod3r Posted March 5, 2012 Author Share Posted March 5, 2012 no i mean in BaseMode you can change the teams Name with F1 there is no function can get the teams names every time ?? Link to comment
Castillo Posted March 5, 2012 Share Posted March 5, 2012 You can use this: for index, team in ipairs(getElementsByType"team") do -- Loop through all server teams. -- Do something. end Link to comment
Evil-Cod3r Posted March 6, 2012 Author Share Posted March 6, 2012 Like This ? local teams = getElementsByType("team") for i,team in ipairs(teams) do local teamName = getTeamName(teams) function balanceTeams ( thePlayer ) local Count1 = countPlayersInTeam (teamName) local Count2 = countPlayersInTeam (teamName) if (Count1 == Count2) then setPlayerTeam ( thePlayer, teamName ) elseif (Count1 > Count2) then setPlayerTeam ( thePlayer, teamName ) elseif (Count1 < Count2) then setPlayerTeam ( thePlayer, teamName ) end end end Link to comment
Kenix Posted March 6, 2012 Share Posted March 6, 2012 Wrong. Comments here: local teams = getElementsByType("team") for i,team in ipairs(teams) do -- Ok you loop all teams local teamName = getTeamName(teams) -- why? Variable teams is table function balanceTeams ( thePlayer ) -- You create function in loop? Why? local Count1 = countPlayersInTeam (teamName) -- false, because getTeamName return false local Count2 = countPlayersInTeam (teamName) -- false, because getTeamName return false if (Count1 == Count2) then -- All wrong next. setPlayerTeam ( thePlayer, teamName ) elseif (Count1 > Count2) then setPlayerTeam ( thePlayer, teamName ) elseif (Count1 < Count2) then setPlayerTeam ( thePlayer, teamName ) end end end --[[ You need tabulate your code. ]] Link to comment
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