Something is off about my auto balance code. It starts working fine for the first few rounds, but I believe if a team is dominating another by killing them every round. The round glitches, switching the player to another team, and to another team, and to another team, to the point where you cant even play, you're just stuck.
[CODE]
function AutoBalance()
if( table.Count( team.GetPlayers( 1 ) ) > table.Count( team.GetPlayers( 2 ) ) ) then
return 2
elseif( table.Count( team.GetPlayers( 1 ) ) < table.Count( team.GetPlayers( 2 ) ) ) then
return 1
else
local nanosAvgKDR = 0
local alienAvgKDR = 0
for k, v in pairs( team.GetPlayers( 1 ) ) do
nanosAvgKDR = nanosAvgKDR + v:Frags()/v:Deaths()
end
nanosAvgKDR = nanosAvgKDR/table.Count( team.GetPlayers( 1 ) )
for k, v in pairs( team.GetPlayers( 2 ) ) do
alienAvgKDR = alienAvgKDR + v:Frags()/v:Deaths()
end
alienAvgKDR = alienAvgKDR/table.Count( team.GetPlayers( 2 ) )
print( "Auto Balance: nanos KDR " .. nanosAvgKDR .. " | alien KDR " .. alienAvgKDR )
if( nanosAvgKDR > alienAvgKDR ) then
return 2
elseif( nanosAvgKDR < alienAvgKDR ) then
return 1
else
return math.random(1,2)
end
end
end[/CODE]
Just bump your old thread instead of making a new one.
[url]https://facepunch.com/showthread.php?t=1571137[/url]
[QUOTE=Sean Bean;52468863]Just bump your old thread instead of making a new one.
[url]https://facepunch.com/showthread.php?t=1571137[/url][/QUOTE]
Okay.
Sorry, you need to Log In to post a reply to this thread.