From ae753ab0cf99c757ac181cd2af546ce6dd2cc5f6 Mon Sep 17 00:00:00 2001 From: ChocoTaco1 Date: Wed, 8 Apr 2020 12:09:58 -0400 Subject: [PATCH] Proper Chatlogs (Goon Style) --- Classic/prefs/serverPrefs.cs | 2 ++ Classic/scripts/autoexec/EnableLogs.cs | 35 ++++++++++++++++++++++++++ Classic/scripts/message.cs | 6 +++++ Classic/scripts/serverDefaults.cs | 2 ++ 4 files changed, 45 insertions(+) diff --git a/Classic/prefs/serverPrefs.cs b/Classic/prefs/serverPrefs.cs index 9e17204..baf8eb3 100644 --- a/Classic/prefs/serverPrefs.cs +++ b/Classic/prefs/serverPrefs.cs @@ -30,6 +30,8 @@ $Host::ClassicBadWordFilter = 0; $Host::ClassicBanlist = "prefs/banlist.cs"; $Host::ClassicBalancedBots = 0; $Host::ClassicCanKickBots = 0; +$Host::ClassicChatLog = 1; +$Host::ClassicChatLogPath = "logs/Chat/"; $Host::ClassicConnectLog = 1; $Host::ClassicConnLogPath = "logs/Connect/Connect.log"; $Host::ClassicCycleMisTypes = 0; diff --git a/Classic/scripts/autoexec/EnableLogs.cs b/Classic/scripts/autoexec/EnableLogs.cs index 462e05f..a63ff64 100644 --- a/Classic/scripts/autoexec/EnableLogs.cs +++ b/Classic/scripts/autoexec/EnableLogs.cs @@ -83,4 +83,39 @@ function voteLog(%client, %typeName, %arg1, %arg2, %arg3, %arg4) export("$VoteLog", %logpath, true); logEcho($VoteLog); } +} + +// 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. + if(strstr(%msg, "~w") != -1) + return; + + switch$(%id) + { + case 0: + %team = "[Global]"; + case 1: + %team = "["@getTaggedString(Game.getTeamName(%team))@"]"; + case 2: + %team = "[Admin]"; + case 3: + %team = "[Bottomprint]"; + case 4: + %team = "[Centerprint]"; + } + + // Make it all uppercase + %team = strupr(%team); + + $ClassicChatLog = "["@formattimestring("H:nn:ss")@"]" SPC %team SPC getTaggedString(%client.name) @": "@%msg; + $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); } \ No newline at end of file diff --git a/Classic/scripts/message.cs b/Classic/scripts/message.cs index c64c3fa..54d7ca6 100644 --- a/Classic/scripts/message.cs +++ b/Classic/scripts/message.cs @@ -266,6 +266,9 @@ function chatMessageTeam( %sender, %team, %msgString, %a1, %a2, %a3, %a4, %a5, % if ( %obj.team == %sender.team ) chatMessageClient( %obj, %sender, %sender.voiceTag, %sender.voicePitch, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10 ); } + + if($Host::ClassicChatLog) + ClassicChatLog(%sender, 1, %sender.team, %a2); } function cannedChatMessageTeam( %sender, %team, %msgString, %name, %string, %keys ) @@ -319,6 +322,9 @@ function chatMessageAll( %sender, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, echo( stripTaggedVar(%sender.name), ": ", %a2 ); } //echo( "SAY: " @ stripchars(detag(gettaggedstring(%sender.name)),"\cp\co\c6\c7\c8\c9") @ " \"" @ %a2 @ "\""); + + if($Host::ClassicChatLog) + ClassicChatLog(%sender, 0, 0, %a2); } function cannedChatMessageAll( %sender, %msgString, %name, %string, %keys ) diff --git a/Classic/scripts/serverDefaults.cs b/Classic/scripts/serverDefaults.cs index 8ee37a7..407721b 100644 --- a/Classic/scripts/serverDefaults.cs +++ b/Classic/scripts/serverDefaults.cs @@ -156,6 +156,8 @@ $Host::LoadScreenMOTD4 = "Big CTF games Fridays, Saturdays, and Sundays!"; //M $Host::ClassicBanlist = "prefs/banlist.cs"; $Host::ClassicAdminLog = 1; $Host::ClassicAdminLogPath = "logs/Admin/log.txt"; +$Host::ClassicChatLog = 1; +$Host::ClassicChatLogPath = "logs/Chat/"; $Host::ClassicConnectLog = 1; $Host::ClassicConnLogPath = "logs/Connect/log.txt"; $Host::ClassicMOTD = "Discord PUB\nServer Hosted/Provided by Branzone/Ravin\nGet Mappacks at https://playt2.com/";