Simple balancer, switches a player with the lowest 5*kills/deaths ratio.
procedure OnJoinTeam(ID, Team: byte);
var
t: integer;
begin
t := AlphaPlayers-BravoPlayers;
if t <= -2 then Command('/setteam1 '+inttostr(ID));
if t >= 2 then Command('/setteam2 '+inttostr(ID));
end;
procedure SwitchPlayer(toTeam: byte);
var
i,swichedID: byte;
kills,deaths: integer;
minratio: single;
begin
minratio := 9999;
for i:=1 to 32 do
begin
kills := GetPlayerStat(i, 'Kills');
deaths := GetPlayerStat(i, 'Deaths');
if deaths = 0 then inc(deaths,1);
if (GetPlayerStat(i, 'Active')=true) and (5*kills/deaths <= minratio) and (GetPlayerStat(i, 'Team') < 5) and (GetPlayerStat(i, 'Team')<>toTeam) then
begin
minratio := 5*kills/deaths;
swichedID := i;
end;
end;
Command('/setteam'+inttostr(toTeam)+' '+inttostr(swichedID));
WriteConsole(0, IDToName(swichedID)+' switched', $FFFF0000);
end;
procedure AppOnIdle(Ticks: integer);
var
a,b: integer;
begin
if Ticks mod (5*60) = 0 then
begin
repeat
a := AlphaPlayers-BravoPlayers;
b := BravoPlayers-AlphaPlayers;
if a >= 2 then SwitchPlayer(2);
if b >= 2 then SwitchPlayer(1);
until (a < 2) and (b < 2);
end;
end;