TacoServer/Classic/scripts/autoexec/EnableLogs.cs

61 lines
1.9 KiB
C#
Raw Normal View History

2020-03-23 20:23:42 +00:00
$Host::ClassicAdminLog = 1;
$Host::ClassicConnectLog = 1;
//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
$AdminLog = formatTimeString("M-d") SPC formatTimeString("[HH:nn]") SPC %client.nameBase @ " (" @ getField(%authInfo, 0) @ ", " @ %ip @ ", " @ %client.guid @ ", " @ %client.getAddress() @ ")" @ %msg SPC "[" @ $CurrentMission @ "]";
%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;
$ConnectLog = %inout SPC "#P[" @ $HostGamePlayerCount @ "]" SPC formatTimeString("M-d") SPC formatTimeString("[HH:nn]") SPC %name SPC "(" @ getField(%authInfo, 0) @ "," SPC %client.guid @ "," SPC %ip @ ")" SPC "[" @ $CurrentMission @ "]" SPC "NTC[" @ %ntc @ "]";
%logpath = $Host::ClassicConnLogPath;
export("$ConnectLog", %logpath, true);
logEcho($ConnectLog);
echo($ConnectLog);
}
}