ItsMods

Full Version: Teambalance routine change
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,
here is a mini release of a teambalance mod i just made, because some people wanted the teambalance routine to be changed...
It chooses the player with the lowest "session time" on the server instead of the player that has been on the team the shortest ammount of time.

BTW: timePlayed["total"] only gets counted up if you are on axis or allies not for spectators ;D.

go to _teams.gsc and search for the balanceTeams() function and change it to:

Code:
balanceTeams()
{
    iPrintLnBold( game["strings"]["autobalance"] );
    //Create/Clear the team arrays
    AlliedPlayers = [];
    AxisPlayers = [];

    // Populate the team arrays
    players = level.players;
    for(i = 0; i < players.size; i++)
    {            
        if(!isdefined(players[i].timePlayed["total"]))
            continue;

        if((isdefined(players[i].pers["team"])) && (players[i].pers["team"] == "allies"))
            AlliedPlayers[AlliedPlayers.size] = players[i];
        else if((isdefined(players[i].pers["team"])) && (players[i].pers["team"] == "axis"))
            AxisPlayers[AxisPlayers.size] = players[i];
    }
    totalTime = undefined;
    while((AlliedPlayers.size > (AxisPlayers.size + 1)) || (AxisPlayers.size > (AlliedPlayers.size + 1)))
    {
        if(AlliedPlayers.size > (AxisPlayers.size + 1))
        {
            //(OLD) Move the player that's been on the team the shortest ammount of time (highest teamTime value) (OLD)
            
            //Move the player that's been in the server for the shortest amount of time (lowest timePlayed value)
            for(j = 0; j < AlliedPlayers.size; j++)
            {
                if(isdefined(AlliedPlayers[j].dont_auto_balance))
                    continue;
                
                if(!isdefined(totalTime))
                    totalTime = AlliedPlayers[j];        
                else if(AlliedPlayers[j].timePlayed["total"] < totalTime.timePlayed["total"])
                    totalTime = AlliedPlayers[j];
            }

            totalTime [[level.axis]]();
        }
        else if(AxisPlayers.size > (AlliedPlayers.size + 1))
        {
            //(OLD)Move the player that's been on the team the shortest ammount of time (highest teamTime value) (OLD)
            
            //Move the player that's been in the server for the shortest amount of time (lowest timePlayed value)
            for(j = 0; j < AxisPlayers.size; j++)
            {
                if(isdefined(AxisPlayers[j].dont_auto_balance))
                    continue;

                if(!isdefined(totalTime))
                    totalTime = AxisPlayers[j];
                else if(AxisPlayers[j].timePlayed["total"] < totalTime.timePlayed["total"])
                    totalTime = AxisPlayers[j];
            }

            totalTime [[level.allies]]();
        }

        totalTime = undefined;
        AlliedPlayers = [];
        AxisPlayers = [];

        players = level.players;
        for(i = 0; i < players.size; i++)
        {
            if((isdefined(players[i].pers["team"])) && (players[i].pers["team"] == "allies"))
                AlliedPlayers[AlliedPlayers.size] = players[i];
            else if((isdefined(players[i].pers["team"])) &&(players[i].pers["team"] == "axis"))
                AxisPlayers[AxisPlayers.size] = players[i];
        }
    }
}

Or just download the attachment.

Virustotal: https://www.virustotal.com/file/26ce761c...341933812/
Very good practical use. +1.
very nice, i like this better than the old routine, just seems more reasonable to the players that have been in the server the longest, plus keeps the team balance happening without changing rounds! +1
I suggest you move the first n players who die, I hate when teambalance kill me while im in a row!