From 58bb1cb4f96b5551f8c22f9ef458c15679ddc556 Mon Sep 17 00:00:00 2001 From: ChocoTaco1 Date: Sat, 4 Apr 2020 13:48:22 -0400 Subject: [PATCH] Proper VoteLogging --- Classic/prefs/serverPrefs.cs | 2 ++ Classic/scripts/autoexec/EnableLogs.cs | 25 +++++++++++++++++++++++-- Classic/scripts/autoexec/VoteMenu.cs | 9 ++++++++- Classic/scripts/serverDefaults.cs | 2 ++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Classic/prefs/serverPrefs.cs b/Classic/prefs/serverPrefs.cs index e43140d..9e17204 100644 --- a/Classic/prefs/serverPrefs.cs +++ b/Classic/prefs/serverPrefs.cs @@ -72,6 +72,8 @@ $Host::ClassicTelnetPort = 666; $Host::ClassicTkLimit = 0; $Host::ClassicUseHighPerformanceCounter = 0; $Host::ClassicViralBanning = 1; +$Host::ClassicVoteLog = 1; +$Host::ClassicVoteLogPath = "logs/Vote/Vote.log"; $Host::ClassicWhitelist = "prefs/whitelist.cs"; $Host::CRCTextures = 0; $Host::Dedicated = 1; diff --git a/Classic/scripts/autoexec/EnableLogs.cs b/Classic/scripts/autoexec/EnableLogs.cs index 8b48083..b36463e 100644 --- a/Classic/scripts/autoexec/EnableLogs.cs +++ b/Classic/scripts/autoexec/EnableLogs.cs @@ -1,5 +1,7 @@ -$Host::ClassicAdminLog = 1; -$Host::ClassicConnectLog = 1; +//$Host::ClassicAdminLog = 1; +//$Host::ClassicConnectLog = 1; +//$Host::ClassicVoteLog = 1; + //exec("scripts/autoexec/EnableLogs.cs"); //Enable Logs @@ -58,4 +60,23 @@ function connectLog(%client, %isDisconnect) logEcho($ConnectLog); echo($ConnectLog); } +} + +// voteLog(%client, %votemsg) +// Info: Logs the vote events +function voteLog(%client, %votemsg) +{ + if($Host::ClassicVoteLog) + { + // get the client info + %authInfo = %client.getAuthInfo(); + %ip = getField(strreplace(%client.getAddress(),":","\t"),1); + + // this is the info that will be logged + $VoteLog = "#P[" @ $HostGamePlayerCount @ "]" SPC formatTimeString("M-d") SPC formatTimeString("[HH:nn]") SPC %client.nameBase @ " (" @ getField(%authInfo, 0) @ "," SPC %client.guid @ ") Initiated a vote:" SPC %votemsg SPC "CM[" @ $CurrentMission @ "]"; + + %logpath = $Host::ClassicVoteLogPath; + export("$VoteLog", %logpath, true); + logEcho($VoteLog); + } } \ No newline at end of file diff --git a/Classic/scripts/autoexec/VoteMenu.cs b/Classic/scripts/autoexec/VoteMenu.cs index 608f405..9ecce60 100644 --- a/Classic/scripts/autoexec/VoteMenu.cs +++ b/Classic/scripts/autoexec/VoteMenu.cs @@ -607,7 +607,14 @@ function playerStartNewVote(%client, %typeName, %arg1, %arg2, %arg3, %arg4, %tea %client.canVote = false; %client.rescheduleVote = schedule(($Host::voteSpread * 1000) + ($Host::voteTime * 1000) , 0, "resetVotePrivs", %client); - echo("Vote Initiated by" SPC %client.nameBase SPC %typeName SPC %arg1 SPC %arg2 SPC %arg3 SPC %arg4); + echo(%msg); + + // Log Vote + if($Host::ClassicVoteLog) + { + %votemsg = %typeName SPC %arg1 SPC %arg2 SPC %arg3 SPC %arg4; + voteLog(%client, %votemsg); + } if($Host::EnableVoteSoundReminders > 0) { diff --git a/Classic/scripts/serverDefaults.cs b/Classic/scripts/serverDefaults.cs index b8e82da..8ee37a7 100644 --- a/Classic/scripts/serverDefaults.cs +++ b/Classic/scripts/serverDefaults.cs @@ -169,6 +169,8 @@ $Host::ClassicViralBanning = 1; $Host::ClassicWhitelist = "prefs/whitelist.cs"; $Host::ClassicSuppressTraversalRootError = 1; $Host::ClassicMaxVotes = 5; +$Host::ClassicVoteLog = 1; +$Host::ClassicVoteLogPath = "logs/Vote/Vote.log"; $Host::ServerRules1 = "\c2if\c4(\c3%client.fun == \c5true \c4&& \c3%client.Llama_Grabs \c4< \c51\c4)"; $Host::ServerRules2 = " \c1Be_Courteous\c4(\c2%client, %game\c4);"; $Host::ServerRules3 = "\c2else if\c4(\c3%client.attitude \c4!$ = \c5%client.fun\c4)";