2018-04-28 01:22:18 -04:00
|
|
|
#include maps\mp\_utility;
|
|
|
|
#include maps\mp\gametypes\_hud_util;
|
|
|
|
#include common_scripts\utility;
|
|
|
|
|
|
|
|
init()
|
|
|
|
{
|
|
|
|
level thread WaitForCommand();
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitForCommand()
|
|
|
|
{
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
command = getDvar("sv_iw4madmin_command");
|
2018-05-28 21:30:31 -04:00
|
|
|
commandArgs = strtok(getDvar("sv_iw4madmin_commandargs"), ",");
|
|
|
|
|
2018-04-28 01:22:18 -04:00
|
|
|
switch(command)
|
|
|
|
{
|
|
|
|
case "balance":
|
2018-05-28 21:30:31 -04:00
|
|
|
BalanceTeams(commandArgs);
|
2018-04-28 01:22:18 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
setDvar("sv_iw4madmin_command", "");
|
2018-05-28 21:30:31 -04:00
|
|
|
setDvar("sv_iw4madmin_commandargs", "");
|
2018-04-28 01:22:18 -04:00
|
|
|
|
|
|
|
wait(1);
|
|
|
|
}
|
2018-05-28 21:30:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
BalanceTeams(commandArgs)
|
|
|
|
{
|
|
|
|
if (isRoundBased())
|
|
|
|
{
|
|
|
|
iPrintLnBold("Balancing Teams..");
|
|
|
|
|
|
|
|
for (i = 0; i < commandArgs.size; i+= 2)
|
|
|
|
{
|
2018-06-05 17:31:36 -04:00
|
|
|
teamNum = commandArgs[i+1];
|
|
|
|
clientNum = commandArgs[i];
|
|
|
|
if (teamNum == "0")
|
|
|
|
newTeam = "allies";
|
|
|
|
else
|
|
|
|
newTeam = "axis";
|
|
|
|
player = level.players[clientNum];
|
2018-05-28 21:30:31 -04:00
|
|
|
|
|
|
|
if (!isPlayer(player))
|
|
|
|
continue;
|
|
|
|
|
2018-06-05 17:31:36 -04:00
|
|
|
iPrintLnBold(player.name + " " + teamNum);
|
|
|
|
|
2018-05-28 21:30:31 -04:00
|
|
|
switch (newTeam)
|
|
|
|
{
|
|
|
|
case "axis":
|
|
|
|
player[[level.axis]]();
|
|
|
|
break;
|
|
|
|
case "allies":
|
|
|
|
player[[level.allies]]();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-28 01:22:18 -04:00
|
|
|
}
|