TacoServer/Classic/scripts/autoexec/TeamBalanceNotify.cs

67 lines
2 KiB
C#
Raw Normal View History

//Enable or Disable
//$Host::EnableTeamBalanceNotify = 1;
//
2018-06-28 14:34:52 -04:00
//Give the client a notification on the current state of balancing.
2018-11-10 19:56:13 -05:00
//This function is in GetTeamCounts.cs
2019-02-03 03:55:40 -05:00
function TeamBalanceNotify( %game )
2018-06-28 14:34:52 -04:00
{
if( $CurrentMissionType !$= "LakRabbit" && $TotalTeamPlayerCount !$= 0 && $Host::EnableTeamBalanceNotify )
2019-02-03 03:55:40 -05:00
{
2018-11-10 19:56:13 -05:00
//echo ("%Team1Difference " @ %Team1Difference);
//echo ("%Team2Difference " @ %Team2Difference);
if( $PlayerCount[1] !$= $PlayerCount[2] )
{
//Uneven. Reset Balanced.
2018-11-11 01:38:18 -05:00
$BalancedMsgPlayed = 0;
2018-11-10 19:56:13 -05:00
2019-02-03 03:55:40 -05:00
if( $Team1Difference >= 2 || $Team2Difference >= 2 )
{
if( $StatsMsgPlayed !$= 1)
2019-01-26 10:44:53 -05:00
{
2019-02-03 03:55:40 -05:00
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0%1 vs %2 with %3 observers.', $PlayerCount[1], $PlayerCount[2], $PlayerCount[0] );
2019-01-26 10:44:53 -05:00
//Run once.
$StatsMsgPlayed = 1;
2019-02-03 03:55:40 -05:00
//Start Sound Schedule for 60 secs
schedule(60000, 0, "StatsUnbalanceSound", %game);
2019-01-26 10:44:53 -05:00
}
2019-01-31 02:07:19 -05:00
}
2018-06-28 14:34:52 -04:00
}
2018-11-10 19:56:13 -05:00
//If teams are balanced and teams dont equal 0.
2018-11-11 01:38:18 -05:00
else if( $PlayerCount[1] == $PlayerCount[2] && $TotalTeamPlayerCount !$= 0 && $BalancedMsgPlayed !$= 1 )
2018-11-10 19:56:13 -05:00
{
2019-01-01 13:34:41 -05:00
//messageAll('MsgTeamBalanceNotify', '\c1Teams are balanced.');
2018-11-10 19:56:13 -05:00
//Once per cycle.
2018-11-11 01:38:18 -05:00
$BalancedMsgPlayed = 1;
2018-11-10 19:56:13 -05:00
//Reset Stats.
2018-11-11 01:38:18 -05:00
$StatsMsgPlayed = 0;
2018-06-28 14:34:52 -04:00
}
}
2018-06-28 14:34:52 -04:00
}
//Reset Notify at defaultgame::gameOver in evo defaultgame.ovl
2019-02-03 03:55:40 -05:00
function ResetTeamBalanceNotifyGameOver()
2018-11-10 19:56:13 -05:00
{
//Reset All TeamBalance Variables
$BalancedMsgPlayed = -1;
$StatsMsgPlayed = -1;
2019-01-01 13:34:41 -05:00
}
//Called every 30 seconds
2019-01-03 15:48:33 -05:00
//2 or more difference
2019-02-03 03:55:40 -05:00
function StatsUnbalanceSound( %game )
2019-01-01 13:34:41 -05:00
{
2019-02-03 03:55:40 -05:00
if( $CurrentMissionType !$= "LakRabbit" && $Host::EnableTeamBalanceNotify && $StatsMsgPlayed $= 1 )
2019-01-26 10:44:53 -05:00
{
2019-02-03 03:55:40 -05:00
if( $Team1Difference == 1 || $Team2Difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
{
$StatsMsgPlayed = 0;
return;
}
else if( $Team1Difference >= 2 || $Team2Difference >= 2 )
{
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0%1 vs %2 with %3 observers.~wgui/vote_nopass.wav', $PlayerCount[1], $PlayerCount[2], $PlayerCount[0] );
schedule(30000, 0, "StatsUnbalanceSound", %game);
}
2019-01-26 10:44:53 -05:00
}
2019-02-03 03:55:40 -05:00
}