import es import gamethread import random import playerlib import psyco psyco.full() balancer_check = 0 balancer_max = 4 current_round = 0 winners = 0 def es_map_start(event_var): global balancer_check, current_round, winners balancer_check = 0 current_round = 0 winners = 0 def round_end(event_var): global winners, current_round, balancer_check if int(event_var['winner']) == 2: if winners == 2: current_round += 1 else: current_round = 1 winners = 2 elif int(event_var['winner']) == 3: if winners == 3: current_round += 1 else: current_round = 1 winners = 3 if current_round >= balancer_max: balancer_check = 1 if balancer_check: balancer_check = 0 balance_teams() def balance_teams(): es.server.queuecmd('est_god #l 1') tmp_list = playerlib.getUseridList('#human') tmp_removed = playerlib.getUseridList('#spec') for tmp in tmp_removed: tmp_list.remove(tmp) tmp_removed = playerlib.getUseridList('#un') for tmp in tmp_removed: tmp_list.remove(tmp) random.shuffle(tmp_list) tmp_ammount = len(tmp_list) / 2 i = 1 es.msg('#green','Winning team has ' + str(current_round) + ' wins in a row. Shuffling Teams.') while i <= tmp_ammount: es.server.queuecmd('est_team ' + str(tmp_list.pop()) + ' 2') i += 1 while len(tmp_list) > 0: es.server.queuecmd('est_team ' + str(tmp_list.pop()) + ' 3') es.server.queuecmd('est_csay #a Teams Have Been Balanced')