Author Topic: need teambalance script  (Read 741 times)

0 Members and 1 Guest are viewing this topic.

Offline PorN

  • Major
  • *
  • Posts: 55
need teambalance script
« on: October 25, 2008, 01:10:06 pm »
i need a VERY SIMPLE team balance script that changes one special id from red to blue or from blue to red if one of the teams are unbalanced.
« Last Edit: October 25, 2008, 01:24:16 pm by PorN »

Offline UnknownSniper

  • Camper
  • ***
  • Posts: 428
  • Southern by the Grace of God
Re: need teambalance script
« Reply #1 on: October 25, 2008, 01:51:33 pm »
http://forums.soldat.pl/index.php?topic=26442.0

That is a simple script, and if you have half a brain you will be able to figure it out quickly. ;)
I had a job and a piece of land
My sweet wife was my best friend
But I traded that for Cocaine and a whore
-Jamey Johnson


Offline tk

  • Soldier
  • **
  • Posts: 235
Re: need teambalance script
« Reply #2 on: October 25, 2008, 01:52:56 pm »
Simple balancer, switches a player with the lowest 5*kills/deaths ratio.

Code: [Select]
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;
« Last Edit: October 25, 2008, 02:05:40 pm by tk »

Offline PorN

  • Major
  • *
  • Posts: 55
Re: need teambalance script
« Reply #3 on: October 25, 2008, 02:10:53 pm »
got a second problem, i need a second little script, if there is teammatch and on alpha and bravo are 0players or the teams are balanced, how to set the guys who join charlie/delta to the alpha or bravo then?
« Last Edit: October 25, 2008, 02:24:09 pm by PorN »

Offline deevus

  • Major(1)
  • Posts: 16
Re: need teambalance script
« Reply #4 on: October 28, 2008, 02:54:23 am »
I have written a simple balancing script - http://forums.soldat.pl/index.php?topic=30804.0

Currently only works for CTF