TK Autovote EndMatch Restriction

This commit is contained in:
ChocoTaco 2022-04-15 15:44:44 -04:00
parent 56d366eee5
commit cbaf5818e5

View file

@ -5,16 +5,16 @@ package TKwarn
// From Evo // From Evo
function DefaultGame::testTeamKill(%game, %victimID, %killerID, %damageType) function DefaultGame::testTeamKill(%game, %victimID, %killerID, %damageType)
{ {
if(!$countdownStarted && !$MatchStarted) if(!$countdownStarted && !$MatchStarted)
return; return;
%tk = Parent::testTeamKill(%game, %victimID, %killerID); %tk = Parent::testTeamKill(%game, %victimID, %killerID);
if(!%tk) if(!%tk)
return false; // is not a tk return false; // is not a tk
// No Bots // No Bots
//if(%killerID.isAIcontrolled() || %victimID.isAIcontrolled()) // if(%killerID.isAIcontrolled() || %victimID.isAIcontrolled())
// return true; // return true;
// Log TeamKill // Log TeamKill
@ -23,7 +23,7 @@ function DefaultGame::testTeamKill(%game, %victimID, %killerID, %damageType)
//No warnings in tournament mode //No warnings in tournament mode
if($Host::TournamentMode) if($Host::TournamentMode)
return true; return true;
// No Admins // No Admins
if(%killerID.isAdmin) if(%killerID.isAdmin)
return true; return true;
@ -31,7 +31,7 @@ function DefaultGame::testTeamKill(%game, %victimID, %killerID, %damageType)
// Ignore this map // Ignore this map
if($CurrentMission $= "Mac_FlagArena" || $CurrentMission $= "Machineeggs") if($CurrentMission $= "Mac_FlagArena" || $CurrentMission $= "Machineeggs")
return true; return true;
// warn the player of the imminent kick vote // warn the player of the imminent kick vote
if((%killerID.teamkills == $Host::TKWarn1 - 1) && $Host::TKWarn1 != 0) if((%killerID.teamkills == $Host::TKWarn1 - 1) && $Host::TKWarn1 != 0)
centerprint(%killerID, "You are receiving this warning for inappropriate teamkilling.\nBehave or a vote to kick will be started.", 10, 2); centerprint(%killerID, "You are receiving this warning for inappropriate teamkilling.\nBehave or a vote to kick will be started.", 10, 2);
@ -61,7 +61,7 @@ if (!isActivePackage(TKwarn))
function TKkick( %client, %admin, %guid ) function TKkick( %client, %admin, %guid )
{ {
messageAll( 'MsgAdminForce', '\c2%1 has been autokicked for teamkilling.', %client.name ); // z0dd - ZOD, 7/13/03. Tell who kicked messageAll( 'MsgAdminForce', '\c2%1 has been autokicked for teamkilling.', %client.name ); // z0dd - ZOD, 7/13/03. Tell who kicked
messageClient(%client, 'onClientKicked', ""); messageClient(%client, 'onClientKicked', "");
messageAllExcept( %client, -1, 'MsgClientDrop', "", Game.kickClientName, %client ); messageAllExcept( %client, -1, 'MsgClientDrop', "", Game.kickClientName, %client );
@ -87,12 +87,12 @@ function TKkick( %client, %admin, %guid )
%cl = ClientGroup.getObject( %i ); %cl = ClientGroup.getObject( %i );
if( %cl.guid == %guid ) if( %cl.guid == %guid )
{ {
%found = true; %found = true;
// kill and delete this client, their done in this server. // kill and delete this client, their done in this server.
if( isObject( %cl.player ) ) if( isObject( %cl.player ) )
%cl.player.scriptKill(0); %cl.player.scriptKill(0);
if ( isObject( %cl ) ) if ( isObject( %cl ) )
{ {
%client.setDisconnectReason( "You have been kicked out of the game for teamkilling." ); // z0dd - ZOD, 7/13/03. Tell who kicked %client.setDisconnectReason( "You have been kicked out of the game for teamkilling." ); // z0dd - ZOD, 7/13/03. Tell who kicked
@ -100,17 +100,17 @@ function TKkick( %client, %admin, %guid )
} }
// ban by IP as well // ban by IP as well
BanList::add( %guid, %client.getAddress(), $Host::KickBanTime ); BanList::add( %guid, %client.getAddress(), $Host::KickBanTime );
} }
} }
if( !%found ) if( !%found )
BanList::add( %guid, "0", $Host::KickBanTime ); // keep this guy out for a while since he left. BanList::add( %guid, "0", $Host::KickBanTime ); // keep this guy out for a while since he left.
} }
else // lan games else // lan games
{ {
// kill and delete this client // kill and delete this client
if( isObject( %client.player ) ) if( isObject( %client.player ) )
%client.player.scriptKill(0); %client.player.scriptKill(0);
if ( isObject( %client ) ) if ( isObject( %client ) )
{ {
%client.setDisconnectReason( "You have been kicked out of the game for teamkilling." ); %client.setDisconnectReason( "You have been kicked out of the game for teamkilling." );
@ -124,7 +124,7 @@ function TKkick( %client, %admin, %guid )
// From Evo // From Evo
// Info: Auto start a new vote // Info: Auto start a new vote
function TKvote(%typeName, %arg1, %arg2, %arg3, %arg4) function TKvote(%typeName, %arg1, %arg2, %arg3, %arg4)
{ {
// works only for kicking players // works only for kicking players
if(%typeName !$= "VoteKickPlayer") if(%typeName !$= "VoteKickPlayer")
return; return;
@ -132,38 +132,66 @@ function TKvote(%typeName, %arg1, %arg2, %arg3, %arg4)
// only works for FFA mode // only works for FFA mode
if($Host::TournamentMode) if($Host::TournamentMode)
return; return;
//Added for vote overtime
%curTimeLeftMS = ($Host::TimeLimit * 60 * 1000) + $missionStartTime - getSimTime();
if(%curTimeLeftMS <= 90000)
{
//log it
$tkvoteLog = formatTimeString("M-d") SPC formatTimeString("[hh:nn:a]") SPC "[Autovote Cancelled]" SPC %arg1.nameBase @ "(" @ %arg1.guid @ ")" SPC "Teamkill Autovote cancelled due insufficient time. #P[" @ $HostGamePlayerCount @ "]" SPC "CM[" @ $CurrentMission @ "]";
if($Host::ClassicTeamKillLog)
{
%logpath = $Host::ClassicTeamKillLogPath;
export("$tkvoteLog", %logpath, true);
logEcho($tkvoteLog);
}
echo($tkvoteLog);
return;
}
//notify any admins on the other team
for(%i = 0; %i < ClientGroup.getCount(); %i++)
{
%cl = ClientGroup.getObject(%i);
if (%cl.isAdmin == true)
{
if(%cl.team !$= %arg1.team) //Not on admins team
messageClient(%cl, '', '\c5[A]\c1%1 \c0Teamkill Autovote started to kick %2.~wgui/objective_notification.wav', "Vote in Progress:", %arg1.nameBase);
}
}
echo(formatTimeString("M-d") SPC formatTimeString("[hh:nn:a]") SPC "Teamkill Autovote started for..." SPC %arg1.nameBase @ "(" @ %arg1.guid @ ")" SPC "#P[" @ $HostGamePlayerCount @ "]" SPC "CM[" @ $CurrentMission @ "]");
// a vote is already running, cancel it // a vote is already running, cancel it
if(Game.scheduleVote !$= "") if(Game.scheduleVote !$= "")
stopCurrentVote(); stopCurrentVote();
%clientsVoting = 0; %clientsVoting = 0;
// admins can't be kicked // admins can't be kicked
if(%arg1.isAdmin) if(%arg1.isAdmin)
return; return;
Game.kickClient = %arg1; Game.kickClient = %arg1;
Game.kickClientName = %arg1.name; Game.kickClientName = %arg1.name;
Game.kickGuid = %arg1.guid; Game.kickGuid = %arg1.guid;
Game.kickTeam = %arg1.team; Game.kickTeam = %arg1.team;
%count = ClientGroup.getCount(); %count = ClientGroup.getCount();
for(%i = 0; %i < %count; %i++) for(%i = 0; %i < %count; %i++)
{ {
%cl = ClientGroup.getObject(%i); %cl = ClientGroup.getObject(%i);
if(%cl.team == %arg1.team && !%cl.isAIControlled() && %cl !$= %arg1) if(%cl.team == %arg1.team && !%cl.isAIControlled() && %cl !$= %arg1)
{ {
messageClient(%cl, 'VoteStarted', '\c2Vote initiated to kick the teamkiller %1 with %2 teamkills.', %arg1.name, $Host::TKWarn2); messageClient(%cl, 'VoteStarted', '\c2Vote initiated to kick the teamkiller %1 with %2 teamkills.', %arg1.name, $Host::TKWarn2);
%clientsVoting++; %clientsVoting++;
} }
} }
for(%i = 0; %i < %count; %i++) for(%i = 0; %i < %count; %i++)
{ {
%cl = ClientGroup.getObject(%i); %cl = ClientGroup.getObject(%i);
if(%cl.team == %arg1.team && !%cl.isAIControlled() && %cl !$= %arg1) if(%cl.team == %arg1.team && !%cl.isAIControlled() && %cl !$= %arg1)
messageClient(%cl, 'openVoteHud', "", %clientsVoting, ($Host::VotePassPercent / 100)); messageClient(%cl, 'openVoteHud', "", %clientsVoting, ($Host::VotePassPercent / 100));
} }
clearVotes(); clearVotes();