2020-04-04 18:38:45 +00:00
//$Host::ClassicAdminLog = 1;
//$Host::ClassicConnectLog = 1;
//$Host::ClassicVoteLog = 1;
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 ( ) ;
% ip = getField ( strreplace ( % client . getAddress ( ) , ":" , "\t" ) , 1 ) ;
// 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" )
% arg1 = % arg1 . nameBase ;
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
}
// 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 ) ;
2020-03-23 20:23:42 +00:00
}