TacoServer/Classic/scripts/autoexec/VoteOverTime.cs

88 lines
2.2 KiB
C#
Raw Normal View History

2018-08-07 06:50:49 +00:00
//Changes were also made in the Evo Admin.ovl and DefaultGame.ovl
//DefaultGame::voteChangeMission, DefaultGame::voteChangeTimeLimit, serverCmdStartNewVote
2018-11-18 23:29:37 +00:00
package VoteOverTime
{
2018-08-07 06:50:49 +00:00
2018-08-09 20:55:08 +00:00
function DefaultGame::checkTimeLimit(%game, %forced)
2018-08-07 06:50:49 +00:00
{
2018-08-09 20:55:08 +00:00
// Don't add extra checks:
if ( %forced )
cancel( %game.timeCheck );
2018-08-07 06:50:49 +00:00
2018-08-09 20:55:08 +00:00
// if there is no time limit, check back in a minute to see if it's been set
if(($Host::TimeLimit $= "") || $Host::TimeLimit == 0)
{
%game.timeCheck = %game.schedule(20000, "checkTimeLimit");
return;
}
%curTimeLeftMS = ($Host::TimeLimit * 60 * 1000) + $missionStartTime - getSimTime();
2018-08-07 06:50:49 +00:00
2018-08-09 20:55:08 +00:00
if (%curTimeLeftMS <= 0)
{
//Vote Overtime
//Check if Vote is active or if the timelimit has changed.
2018-11-11 04:10:39 +00:00
if( !$VoteInProgress && !$TimeLimitChanged )
{
2018-08-09 20:55:08 +00:00
// time's up, put down your pencils
%game.timeLimitReached();
2018-08-11 12:10:49 +00:00
}
2018-11-11 04:10:39 +00:00
else if( $missionRunning && $VoteInProgress && !$TimeLimitChanged )
{
2018-08-09 20:55:08 +00:00
//Restart the function so the map can end if the Vote doesnt pass.
2018-08-14 19:28:16 +00:00
schedule(2000, 0, "RestartcheckTimeLimit", %game, %forced);
2018-11-13 05:07:36 +00:00
if( !$VoteInProgressMsg )
2018-11-11 04:10:39 +00:00
{
2018-08-11 12:10:49 +00:00
messageAll('', '\c2Vote Overtime Initiated.~wfx/powered/turret_heavy_activate.wav', %display);
2018-11-13 05:07:36 +00:00
$VoteInProgressMsg = true;
2018-08-07 06:50:49 +00:00
}
2018-08-09 20:55:08 +00:00
}
}
else
{
if(%curTimeLeftMS >= 20000)
%game.timeCheck = %game.schedule(20000, "checkTimeLimit");
else
%game.timeCheck = %game.schedule(%curTimeLeftMS + 1, "checkTimeLimit");
2018-08-07 06:50:49 +00:00
2018-08-09 20:55:08 +00:00
//now synchronize everyone's clock
messageAll('MsgSystemClock', "", $Host::TimeLimit, %curTimeLeftMS);
}
2018-08-07 06:50:49 +00:00
}
2018-08-14 19:28:16 +00:00
};
2018-08-09 20:55:08 +00:00
function RestartcheckTimeLimit(%game, %forced)
2018-08-07 06:50:49 +00:00
{
2018-08-09 20:55:08 +00:00
%game.checkTimeLimit(%game, %forced);
2018-08-07 06:50:49 +00:00
}
2018-08-14 19:28:16 +00:00
function StartVOTimeVote(%game)
{
$VoteSoundInProgress = true;
$VoteInProgress = true;
$TimeLimitChanged = false;
}
function ResetVOTimeChanged(%game)
{
$VoteInProgress = false;
$TimeLimitChanged = true;
2018-11-13 05:07:36 +00:00
$VoteInProgressMsg = false;
2018-08-14 19:28:16 +00:00
$VoteSoundInProgress = false;
}
function ResetVOall(%game)
{
$VoteInProgress = false;
$TimeLimitChanged = false;
2018-11-13 05:07:36 +00:00
$VoteInProgressMsg = false;
2018-08-14 19:28:16 +00:00
$VoteSoundInProgress = false;
}
2018-08-07 06:50:49 +00:00
// Prevent package from being activated if it is already
if (!isActivePackage(VoteOverTime))
activatePackage(VoteOverTime);