2020-08-01 21:33:28 +00:00
//exec("scripts/autoexec/TKwarn.cs");
2020-07-24 19:50:57 +00:00
package TKwarn
{
// From Evo
2021-09-30 20:22:55 +00:00
function DefaultGame : : testTeamKill ( % game , % victimID , % killerID , % damageType )
2022-04-15 19:44:44 +00:00
{
2021-09-29 20:58:40 +00:00
if ( ! $ countdownStarted & & ! $ MatchStarted )
return ;
2022-04-15 19:44:44 +00:00
2020-07-24 19:50:57 +00:00
% tk = Parent : : testTeamKill ( % game , % victimID , % killerID ) ;
2022-04-15 19:44:44 +00:00
if ( ! % tk )
2020-07-24 19:50:57 +00:00
return false ; // is not a tk
2021-09-13 21:33:21 +00:00
// No Bots
2022-04-18 17:14:14 +00:00
//if(%killerID.isAIcontrolled() || %victimID.isAIcontrolled())
//return true;
2021-09-13 21:33:21 +00:00
// Log TeamKill
2021-09-30 20:22:55 +00:00
teamkillLog ( % victimID , % killerID , % damageType ) ;
2022-01-19 17:46:10 +00:00
//No warnings in tournament mode
if ( $ Host : : TournamentMode )
return true ;
2022-04-15 19:44:44 +00:00
2021-09-13 21:33:21 +00:00
// No Admins
if ( % killerID . isAdmin )
2020-07-24 19:50:57 +00:00
return true ;
2020-08-01 21:33:28 +00:00
// Ignore this map
2022-01-19 17:46:10 +00:00
if ( $ CurrentMission $ = "Mac_FlagArena" | | $ CurrentMission $ = "Machineeggs" )
2020-08-01 21:33:28 +00:00
return true ;
2022-04-15 19:44:44 +00:00
2021-09-29 20:58:40 +00:00
// warn the player of the imminent kick vote
2020-07-24 19:50:57 +00:00
if ( ( % killerID . teamkills = = $ Host : : TKWarn1 - 1 ) & & $ Host : : TKWarn1 ! = 0 )
2021-09-29 20:58:40 +00:00
centerprint ( % killerID , "You are receiving this warning for inappropriate teamkilling.\nBehave or a vote to kick will be started." , 10 , 2 ) ;
2020-07-24 19:50:57 +00:00
// warn the player of his imminent kick
else if ( ( % killerID . teamkills = = $ Host : : TKWarn2 - 1 ) & & $ Host : : TKWarn2 ! = 0 )
2021-09-29 20:58:40 +00:00
{
TKvote ( "VoteKickPlayer" , % killerID ) ;
centerprint ( % killerID , "You are receiving this second warning for inappropriate teamkilling.\nBehave or you will be kicked." , 10 , 2 ) ;
}
2020-07-24 19:50:57 +00:00
// kick the player
else if ( ( % killerID . teamkills > = $ Host : : TKMax - 1 ) & & $ Host : : TKMax ! = 0 )
{
Game . kickClientName = % killerID . name ;
2020-08-01 21:33:28 +00:00
TKkick ( % killerID , true , % killerID . guid ) ;
adminLog ( % killerID , " was autokicked for teamkilling." ) ;
2020-07-24 19:50:57 +00:00
}
return true ;
}
} ;
// Prevent package from being activated if it is already
if ( ! isActivePackage ( TKwarn ) )
2020-08-01 21:33:28 +00:00
activatePackage ( TKwarn ) ;
// we pass the guid as well, in case this guy leaves the server.
function TKkick ( % client , % admin , % guid )
{
messageAll ( ' MsgAdminForce ' , ' \ c2 % 1 has been autokicked for teamkilling . ' , % client . name ) ; // z0dd - ZOD, 7/13/03. Tell who kicked
2022-04-15 19:44:44 +00:00
2020-08-01 21:33:28 +00:00
messageClient ( % client , ' onClientKicked ' , "" ) ;
messageAllExcept ( % client , - 1 , ' MsgClientDrop ' , "" , Game . kickClientName , % client ) ;
if ( % client . isAIControlled ( ) )
{
if ( $ Host : : ClassicCanKickBots | | % admin . isAdmin )
{
if ( ! $ Host : : ClassicBalancedBots )
{
$ HostGameBotCount - - ;
% client . drop ( ) ;
}
}
}
else
{
if ( $ playingOnline ) // won games
{
% count = ClientGroup . getCount ( ) ;
% found = false ;
for ( % i = 0 ; % i < % count ; % i + + ) // see if this guy is still here...
{
% cl = ClientGroup . getObject ( % i ) ;
if ( % cl . guid = = % guid )
{
2022-04-15 19:44:44 +00:00
% found = true ;
2020-08-01 21:33:28 +00:00
// kill and delete this client, their done in this server.
if ( isObject ( % cl . player ) )
% cl . player . scriptKill ( 0 ) ;
2022-04-15 19:44:44 +00:00
2020-08-01 21:33:28 +00:00
if ( isObject ( % cl ) )
{
2020-08-02 00:51:59 +00:00
% client . setDisconnectReason ( "You have been kicked out of the game for teamkilling." ) ; // z0dd - ZOD, 7/13/03. Tell who kicked
2021-09-30 20:22:55 +00:00
% cl . schedule ( 700 , "delete" ) ;
2020-08-01 21:33:28 +00:00
}
// ban by IP as well
BanList : : add ( % guid , % client . getAddress ( ) , $ Host : : KickBanTime ) ;
2022-04-15 19:44:44 +00:00
}
2020-08-01 21:33:28 +00:00
}
if ( ! % found )
2022-04-15 19:44:44 +00:00
BanList : : add ( % guid , "0" , $ Host : : KickBanTime ) ; // keep this guy out for a while since he left.
2020-08-01 21:33:28 +00:00
}
else // lan games
{
2021-09-29 20:58:40 +00:00
// kill and delete this client
if ( isObject ( % client . player ) )
% client . player . scriptKill ( 0 ) ;
2022-04-15 19:44:44 +00:00
2021-09-29 20:58:40 +00:00
if ( isObject ( % client ) )
{
% client . setDisconnectReason ( "You have been kicked out of the game for teamkilling." ) ;
% client . schedule ( 700 , "delete" ) ;
}
BanList : : add ( 0 , % client . getAddress ( ) , $ Host : : KickBanTime ) ;
}
}
}
// From Evo
// Info: Auto start a new vote
function TKvote ( % typeName , % arg1 , % arg2 , % arg3 , % arg4 )
2022-04-15 19:44:44 +00:00
{
2021-09-29 21:03:26 +00:00
// works only for kicking players
2021-09-29 20:58:40 +00:00
if ( % typeName ! $ = "VoteKickPlayer" )
return ;
// only works for FFA mode
if ( $ Host : : TournamentMode )
return ;
2022-04-15 19:44:44 +00:00
2022-04-18 17:14:14 +00:00
// admins can't be kicked
if ( % arg1 . isAdmin )
return ;
//Stop current votes
if ( Game . scheduleVote ! $ = "" )
2022-04-15 19:44:44 +00:00
{
2022-04-18 17:14:14 +00:00
//Added for vote overtime
//Dont stop if under 90 secs left
% curTimeLeftMS = ( $ Host : : TimeLimit * 60 * 1000 ) + $ missionStartTime - getSimTime ( ) ;
if ( % curTimeLeftMS < = 90000 )
2022-04-15 19:44:44 +00:00
{
2022-04-18 17:14:14 +00:00
//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 ;
}
else //Stop any current votes
{
//Notify clients the vote is being cancelled
for ( % i = 0 ; % i < % count ; % i + + )
{
% cl = ClientGroup . getObject ( % i ) ;
if ( % cl ! $ = % arg1 ) //dont notify the team killer
messageClient ( % cl , ' VoteStarted ' , ' \ c2Vote has been cancelled due to teamkill autovote . ' ) ;
}
stopCurrentVote ( ) ;
2022-04-15 19:44:44 +00:00
}
}
//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
2022-04-18 17:14:14 +00:00
messageClient ( % cl , ' ' , ' \ c5 [ A ] \ c1 % 1 \ c0Teamkill Autovote started to kick % 2 on the other team . ~ wgui / objective_notification . wav ' , "Vote in Progress:" , % arg1 . nameBase ) ;
2022-04-15 19:44:44 +00:00
}
}
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 @ "]" ) ;
2021-09-29 20:58:40 +00:00
% clientsVoting = 0 ;
2022-04-15 19:44:44 +00:00
2021-09-29 20:58:40 +00:00
Game . kickClient = % arg1 ;
Game . kickClientName = % arg1 . name ;
Game . kickGuid = % arg1 . guid ;
Game . kickTeam = % arg1 . team ;
2022-04-15 19:44:44 +00:00
2021-09-29 20:58:40 +00:00
% count = ClientGroup . getCount ( ) ;
for ( % i = 0 ; % i < % count ; % i + + )
{
% cl = ClientGroup . getObject ( % i ) ;
if ( % cl . team = = % arg1 . team & & ! % cl . isAIControlled ( ) & & % cl ! $ = % arg1 )
2022-04-15 19:44:44 +00:00
{
2021-09-29 20:58:40 +00:00
messageClient ( % cl , ' VoteStarted ' , ' \ c2Vote initiated to kick the teamkiller % 1 with % 2 teamkills . ' , % arg1 . name , $ Host : : TKWarn2 ) ;
% clientsVoting + + ;
2020-08-01 21:33:28 +00:00
}
}
2022-04-15 19:44:44 +00:00
2021-09-29 20:58:40 +00:00
for ( % i = 0 ; % i < % count ; % i + + )
{
% cl = ClientGroup . getObject ( % i ) ;
if ( % cl . team = = % arg1 . team & & ! % cl . isAIControlled ( ) & & % cl ! $ = % arg1 )
2022-04-15 19:44:44 +00:00
messageClient ( % cl , ' openVoteHud ' , "" , % clientsVoting , ( $ Host : : VotePassPercent / 100 ) ) ;
2021-09-29 20:58:40 +00:00
}
clearVotes ( ) ;
Game . voteType = % typeName ;
Game . scheduleVote = schedule ( ( $ Host : : VoteTime * 1000 ) , 0 , "calcVotes" , % typeName , % arg1 , % arg2 , % arg3 , % arg4 ) ;
// Eolk - Voting control variables
Game . votingArgs [ typeName ] = % typeName ;
Game . votingArgs [ arg1 ] = % arg1 ;
Game . votingArgs [ arg2 ] = % arg2 ;
Game . votingArgs [ arg3 ] = % arg3 ;
Game . votingArgs [ arg4 ] = % arg4 ;
// Log Vote
voteLog ( % client , % typeName , % arg1 , % arg2 , % arg3 , "TeamkillAutovote" ) ;
2020-08-01 21:33:28 +00:00
}