2020-04-04 18:38:45 +00:00
//$Host::ClassicAdminLog = 1;
2021-09-16 04:48:43 +00:00
//$Host::ClassicChatLog = 1;
2020-04-04 18:38:45 +00:00
//$Host::ClassicConnectLog = 1;
//$Host::ClassicVoteLog = 1;
2021-09-16 04:48:43 +00:00
//$Host::ClassicTeamKillLog = 1;
2020-04-04 18:38:45 +00:00
2020-03-23 20:23:42 +00:00
//exec("scripts/autoexec/EnableLogs.cs");
//Enable Logs
setlogmode ( 1 ) ;
// adminLog(%client, %msg)
// Info: Logs the admin events
function adminLog ( % client , % msg )
{
if ( % client . isAdmin & & $ Host : : ClassicAdminLog )
{
// get the client info
% authInfo = % client . getAuthInfo ( ) ;
% ip = getField ( strreplace ( % client . getAddress ( ) , ":" , "\t" ) , 1 ) ;
// this is the info that will be logged
2020-07-18 18:52:16 +00:00
$ AdminLog = formatTimeString ( "M-d" ) SPC formatTimeString ( "[hh:nn:a]" ) SPC % client . nameBase @ " (" @ getField ( % authInfo , 0 ) @ ", " @ % ip @ ", " @ % client . guid @ ", " @ % client . getAddress ( ) @ ")" @ % msg SPC "[" @ $ CurrentMission @ "]" ;
2020-03-23 20:23:42 +00:00
% logpath = $ Host : : ClassicAdminLogPath ;
export ( "$AdminLog" , % logpath , true ) ;
logEcho ( $ AdminLog ) ;
echo ( $ AdminLog ) ;
}
}
// connectLog(%client, %realname, %tag)
// Info: Logs the connections
function connectLog ( % client , % isDisconnect )
{
if ( $ Host : : ClassicConnectLog & & ! % client . isAIControlled ( ) )
{
// get the client info
% authInfo = % client . getAuthInfo ( ) ;
2022-01-19 17:46:10 +00:00
% ip = getField ( strreplace ( % client . getAddress ( ) , ":" , "\t" ) , 1 ) ;
2020-03-23 20:23:42 +00:00
// net tournament client present?
if ( ! % client . t2csri_sentComCertDone )
% ntc = "N" ;
else
% ntc = "Y" ;
if ( % isDisconnect )
% inout = "[Drop]" ;
else
% inout = "[Join]" ;
if ( % client . isSmurf )
% name = stripChars ( detag ( getTaggedString ( % client . name ) ) , "\cp\co\c6\c7\c8\c9" ) ;
else
% name = % client . nameBase ;
2020-07-18 18:52:16 +00:00
$ ConnectLog = % inout SPC "#P[" @ $ HostGamePlayerCount @ "]" SPC formatTimeString ( "M-d" ) SPC formatTimeString ( "[hh:nn:a]" ) SPC % name SPC "(" @ getField ( % authInfo , 0 ) @ "," SPC % client . guid @ "," SPC % ip @ ")" SPC "[" @ $ CurrentMission @ "]" SPC "NTC[" @ % ntc @ "]" ;
2020-03-23 20:23:42 +00:00
% logpath = $ Host : : ClassicConnLogPath ;
export ( "$ConnectLog" , % logpath , true ) ;
logEcho ( $ ConnectLog ) ;
echo ( $ ConnectLog ) ;
}
2020-04-04 18:38:45 +00:00
}
2020-11-06 03:33:39 +00:00
// voteLog(%client, %typeName, %arg1, %arg2, %arg3, %arg4)
// Info: Logs the vote events
function voteLog ( % client , % typeName , % arg1 , % arg2 , % arg3 , % arg4 )
{
if ( $ Host : : ClassicVoteLog )
2020-04-04 18:38:45 +00:00
{
// get the client info
% authInfo = % client . getAuthInfo ( ) ;
2020-11-06 03:33:39 +00:00
% ip = getField ( strreplace ( % client . getAddress ( ) , ":" , "\t" ) , 1 ) ;
2020-04-08 02:47:11 +00:00
// show name for Votekick
if ( % typeName $ = "VoteKickPlayer" )
2021-10-02 18:00:08 +00:00
% arg1 = % arg1 . nameBase @ "[" @ % arg1 . teamkills + 1 @ "tks]" ;
2020-04-04 18:38:45 +00:00
// this is the info that will be logged
2020-07-18 18:52:16 +00:00
$ VoteLog = "#P[" @ $ HostGamePlayerCount @ "]" SPC formatTimeString ( "M-d" ) SPC formatTimeString ( "[hh:nn:a]" ) SPC % client . nameBase @ " (" @ getField ( % authInfo , 0 ) @ "," SPC % client . guid @ ") Initiated a vote:" SPC % typeName SPC % arg1 SPC % arg2 SPC % arg3 SPC % arg4 SPC "CM[" @ $ CurrentMission @ "]" ;
2020-04-04 18:38:45 +00:00
% logpath = $ Host : : ClassicVoteLogPath ;
export ( "$VoteLog" , % logpath , true ) ;
logEcho ( $ VoteLog ) ;
}
2020-04-08 16:09:58 +00:00
}
2021-01-09 19:14:15 +00:00
// votePercentLog(%client, %typeName, %key, %game.votesFor[%game.kickTeam], %game.votesAgainst[%game.kickTeam], %totalVotes, %game.totalVotesNone)
// Info: Logs voting percent events
2021-01-13 21:14:45 +00:00
function votePercentLog ( % display , % typeName , % key , % voteYea , % voteNay , % voteTotal , % voteNone ) //%voteNone = Did Not Vote (DNV) (Abstain)
2021-01-09 19:14:15 +00:00
{
if ( $ Host : : ClassicVoteLog )
{
// Dif calc for "VoteKickPlayer"
if ( % typeName $ = "VoteKickPlayer" )
{
2021-01-13 21:14:45 +00:00
% percent = mFloor ( ( % voteYea / ClientGroup . getCount ( ) ) * 100 ) ;
2021-01-09 19:14:15 +00:00
% voteNone = "N/A" ;
% display = % typeName SPC "[" @ % display . nameBase @ "]" ;
}
else
{
2021-01-13 21:14:45 +00:00
% percent = mFloor ( ( % voteYea / ( ClientGroup . getCount ( ) - % voteNone ) ) * 100 ) ;
2021-01-09 19:14:15 +00:00
% display = % typeName SPC "[" @ % display @ "]" ;
}
2021-01-13 21:14:45 +00:00
$ VoteLog = "[" @ % key @ "]" SPC % display SPC "Yea[" @ % voteYea @ "] Nay[" @ % voteNay @ "] Abstain[" @ % voteNone @ "] Total[" @ % voteTotal @ "] Vote%[" @ % percent @ "]" ;
2021-01-09 19:14:15 +00:00
// this is the info that will be logged
% logpath = $ Host : : ClassicVoteLogPath ;
export ( "$VoteLog" , % logpath , true ) ;
logEcho ( $ VoteLog ) ;
}
}
2020-04-08 16:09:58 +00:00
// From Goon
// Slightly more elegant solution rather than spamming console
function ClassicChatLog ( % client , % id , % team , % msg )
{
// We don't care about bots.
if ( % client . isAIControlled ( ) )
return ;
// Don't log voicepack stuff.
2020-04-17 02:29:22 +00:00
if ( strstr ( % msg , "~w" ) ! = - 1 | | strstr ( % msg , "flag" ) ! = - 1 )
2020-04-08 16:09:58 +00:00
return ;
switch $ ( % id )
{
case 0 :
% team = "[Global]" ;
case 1 :
2020-07-12 18:23:19 +00:00
if ( $ countdownStarted )
% team = getTaggedString ( Game . getTeamName ( % team ) ) ;
else
% team = "Debrief" ;
if ( % team $ = "Unassigned" )
% team = "Observer" ;
else if ( $ CurrentMissionType $ = "LakRabbit" | | $ CurrentMissionType $ = "DM" )
% team = $ dtStats : : gtNameLong [ % client . lgame ] ; //from zDarktigerStats.cs
% team = "[" @ % team @ "]" ;
2020-04-08 16:09:58 +00:00
case 2 :
% team = "[Admin]" ;
case 3 :
% team = "[Bottomprint]" ;
case 4 :
% team = "[Centerprint]" ;
}
2020-07-18 18:52:16 +00:00
$ ClassicChatLog = "[" @formattimestring ( "hh:nn:ss:a" ) @"] " @ % team SPC getTaggedString ( % client . name ) @": " @ % msg ;
2020-04-08 16:09:58 +00:00
$ ClassicChatLog = stripChars ( $ ClassicChatLog , "\c0\c1\c2\c3\c4\c5\c6\c7\c8\c9\x10\x11\co\cp" ) ;
% path = $ Host : : ClassicChatLogPath @ formatTimeString ( "/yy/mm-MM/dd.log" ) ;
export ( "$ClassicChatLog" , % path , true ) ;
2021-09-13 21:33:21 +00:00
}
// Log Teamkills
2021-09-30 20:22:55 +00:00
function teamkillLog ( % victimID , % killerID , % damageType )
2021-09-13 21:33:21 +00:00
{
if ( ! $ Host : : ClassicTeamKillLog )
return ;
2021-09-16 04:48:43 +00:00
if ( ! $ CurrentMissionType $ = "CTF" & & ! $ CurrentMissionType $ = "SCTF" )
return ;
2021-09-13 21:33:21 +00:00
2021-09-30 20:22:55 +00:00
//damageType
% type = getTaggedString ( $ DamageTypeText [ % damageType ] ) ;
2021-09-15 20:53:52 +00:00
//Killer tks / Victim tks
2021-09-13 21:33:21 +00:00
//Note: %killerID.teamkills + 1 as this is added later
2021-09-16 18:31:42 +00:00
//Tks For this map only
2021-09-15 20:53:52 +00:00
% ktk = % killerID . teamkills + 1 ;
% vtk = % victimID . teamkills ;
//Stage in warnings
% s = "" ;
2022-01-19 17:46:10 +00:00
if ( ! % killerID . isAdmin & & ! $ Host : : TournamentMode ) //Admins dont get warnings. No warnings in Tournament Mode
2021-09-15 20:53:52 +00:00
{
if ( % ktk > = $ Host : : TKWarn1 & & % ktk < $ Host : : TKWarn2 )
2021-09-16 18:31:42 +00:00
% s = "[Warned] " ;
2021-09-15 20:53:52 +00:00
else if ( % ktk > = $ Host : : TKWarn2 & & % ktk < $ Host : : TKMax )
2021-09-16 18:31:42 +00:00
% s = "[Warned 2] " ;
2021-09-15 20:53:52 +00:00
else if ( % ktk > = $ Host : : TKMax )
2021-09-16 18:31:42 +00:00
% s = "[Kicked] " ;
2021-09-15 20:53:52 +00:00
}
2021-09-30 20:22:55 +00:00
$ teamkillLog = formatTimeString ( "M-d" ) SPC formatTimeString ( "[hh:nn:a]" ) SPC % s @ % killerID . nameBase @ "(" @ % killerID . guid @ ")[" @ % type @ "][" @ % ktk @ " tk] teamkilled" SPC % victimID . nameBase @ "[" @ % vtk @ " tk]. #P[" @ $ HostGamePlayerCount @ "]" SPC "CM[" @ $ CurrentMission @ "]" ;
2021-09-13 21:33:21 +00:00
$ teamkillLog = stripChars ( $ teamkillLog , "\c0\c1\c2\c3\c4\c5\c6\c7\c8\c9\x10\x11\co\cp" ) ;
% logpath = $ Host : : ClassicTeamKillLogPath ;
export ( "$teamkillLog" , % logpath , true ) ;
logEcho ( $ teamkillLog ) ;
echo ( $ teamkillLog ) ;
2020-03-23 20:23:42 +00:00
}