From 7c39ad97b26743860d9470db5d10bfa1bd70a1d5 Mon Sep 17 00:00:00 2001 From: Bara Date: Thu, 18 Oct 2018 16:42:38 +0200 Subject: [PATCH] Add cvar to change karma file ( Close #377 ) --- addons/sourcemod/scripting/ttt/core/config.sp | 3 ++- .../sourcemod/scripting/ttt/core/globals.sp | 1 + addons/sourcemod/scripting/ttt/ttt.sp | 27 ++++++++++--------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/addons/sourcemod/scripting/ttt/core/config.sp b/addons/sourcemod/scripting/ttt/core/config.sp index 2f76feb1..c0ded684 100644 --- a/addons/sourcemod/scripting/ttt/core/config.sp +++ b/addons/sourcemod/scripting/ttt/core/config.sp @@ -78,7 +78,8 @@ void SetupConfig() g_cEnableDamage = AutoExecConfig_CreateConVar("ttt_prestart_damage", "0", "Enable damage before round start (Default disabled to prevent kills)?", _, true, 0.0, true, 1.0); g_croundendDamage = AutoExecConfig_CreateConVar("ttt_roundend_dm", "0", "Enable damage after a round until round end.", _, true, 0.0, true, 1.0); g_clogFile = AutoExecConfig_CreateConVar("ttt_log_file", "logs/ttt/ttt-.log", "The default file to log TTT data to (including end of round) - DON'T REMOVE \"-\" IF YOU DON'T KNOW WHAT YOU DO."); - g_cerrFile = AutoExecConfig_CreateConVar("ttt_error_file", "logs/ttt/ttt-error-.log", "The default file to log TTT errors/bugs to - DON'T REMOVE \"-\" IF YOU DON'T KNOW WHAT YOU DO."); + g_cerrFile = AutoExecConfig_CreateConVar("ttt_error_file", "logs/ttt/ttt-error-.log", "The default file to log TTT errors/bugs - DON'T REMOVE \"-\" IF YOU DON'T KNOW WHAT YOU DO."); + g_cKarmaFile = AutoExecConfig_CreateConVar("ttt_karma_file", "logs/ttt/ttt-karma-.log", "The default file to log TTT karma changes (Require ttt_debug_mode - 1) - DON'T REMOVE \"-\" IF YOU DON'T KNOW WHAT YOU DO."); g_cdefaultPriD = AutoExecConfig_CreateConVar("ttt_default_primary_d", "weapon_m4a1_silencer", "The default primary gun to give players when they become a Detective (if they have no primary)."); g_cdefaultSec = AutoExecConfig_CreateConVar("ttt_default_secondary", "weapon_glock", "The default secondary gun to give players when they get their role (if they have no secondary)."); g_cRoundStartedFontSize = AutoExecConfig_CreateConVar("ttt_round_started_font_size", "32", "Font size of the text if round started"); diff --git a/addons/sourcemod/scripting/ttt/core/globals.sp b/addons/sourcemod/scripting/ttt/core/globals.sp index 78fe70fc..d94720d9 100644 --- a/addons/sourcemod/scripting/ttt/core/globals.sp +++ b/addons/sourcemod/scripting/ttt/core/globals.sp @@ -212,6 +212,7 @@ ConVar g_cforceTeams = null; ConVar g_crandomWinner = null; ConVar g_clogFile = null; ConVar g_cerrFile = null; +ConVar g_cKarmaFile = null; ConVar g_cdefaultPriD = null; ConVar g_cdefaultSec = null; ConVar g_cendwithD = null; diff --git a/addons/sourcemod/scripting/ttt/ttt.sp b/addons/sourcemod/scripting/ttt/ttt.sp index 7a167185..8bf61ef8 100644 --- a/addons/sourcemod/scripting/ttt/ttt.sp +++ b/addons/sourcemod/scripting/ttt/ttt.sp @@ -198,18 +198,21 @@ public void OnConfigsExecuted() g_clogFile.GetString(g_sLogFile, sizeof(g_sLogFile)); g_cerrFile.GetString(g_sErrorFile, sizeof(g_sErrorFile)); + g_cKarmaFile.GetString(g_sKarmaFile, sizeof(g_sKarmaFile)); ReplaceString(g_sLogFile, sizeof(g_sLogFile), "", sDate, true); ReplaceString(g_sErrorFile, sizeof(g_sErrorFile), "", sDate, true); + ReplaceString(g_sKarmaFile, sizeof(g_sKarmaFile), "", sDate, true); BuildPath(Path_SM, g_sLogFile, sizeof(g_sLogFile), g_sLogFile); BuildPath(Path_SM, g_sErrorFile, sizeof(g_sErrorFile), g_sErrorFile); - BuildPath(Path_SM, g_sKarmaFile, sizeof(g_sKarmaFile), "logs/ttt/ttt-karma-%s.log", sDate); + BuildPath(Path_SM, g_sKarmaFile, sizeof(g_sKarmaFile), g_sKarmaFile); if (g_cDebug.BoolValue) { LogMessage("Log File: \"%s\"", g_sLogFile); LogMessage("Error File :\"%s\"", g_sErrorFile); + LogMessage("Karma File :\"%s\"", g_sKarmaFile); } if (g_cLogButtons.BoolValue) @@ -1661,14 +1664,14 @@ public void OnClientPutInServer(int client) } HookClient(client); - if (g_cDebugMessages.BoolValue) + if (g_cDebug.BoolValue) { LogToFileEx(g_sKarmaFile, "OnClientPutInServer - 1 (%N)", client); } if (g_dDB != null) { - if (g_cDebugMessages.BoolValue) + if (g_cDebug.BoolValue) { LogToFileEx(g_sKarmaFile, "OnClientPutInServer - 2 (%N), Valid Database", client); } @@ -1680,14 +1683,14 @@ void LateLoadClients(bool bHook = false) { LoopValidClients(i) { - if (g_cDebugMessages.BoolValue) + if (g_cDebug.BoolValue) { LogToFileEx(g_sKarmaFile, "LateLoadClients - 1 (%N)", i); } if (g_dDB != null) { - if (g_cDebugMessages.BoolValue) + if (g_cDebug.BoolValue) { LogToFileEx(g_sKarmaFile, "LateLoadClients - 2 (%N), Valid Database", i); } @@ -2135,7 +2138,7 @@ public Action Timer_OnClientPutInServer(Handle timer, any userid) if (TTT_IsClientValid(client)) { - if (g_cDebugMessages.BoolValue) + if (g_cDebug.BoolValue) { LogToFileEx(g_sKarmaFile, "Timer_OnClientPutInServer - 1 (%N)", client); } @@ -4132,7 +4135,7 @@ public Action Timer_5(Handle timer) iKarma *= -1; } - if (g_cDebugMessages.BoolValue) + if (g_cDebug.BoolValue) { LogToFileEx(g_sKarmaFile, "(Timer_5) - 1 Client: \"%L\", g_bKarma: %d, g_cKarmaBan: %d, iKarma: %d (g_iKarma: %d)", i, g_bKarma[i], g_ckarmaBan.IntValue, iKarma, g_iKarma[i]); } @@ -4418,7 +4421,7 @@ void LoadClientKarma(int userid) if (!IsFakeClient(client)) { - if (g_cDebugMessages.BoolValue) + if (g_cDebug.BoolValue) { LogToFileEx(g_sKarmaFile, "(LoadClientKarma) - 1 Client: \"%L\"", client); } @@ -4427,7 +4430,7 @@ void LoadClientKarma(int userid) if (!GetClientAuthId(client, AuthId_SteamID64, sCommunityID, sizeof(sCommunityID))) { - if (g_cDebugMessages.BoolValue) + if (g_cDebug.BoolValue) { LogToFileEx(g_sKarmaFile, "(LoadClientKarma) - 1.1 Client: \"%L\"", client); } @@ -4437,19 +4440,19 @@ void LoadClientKarma(int userid) char sQuery[2048]; Format(sQuery, sizeof(sQuery), "SELECT `karma` FROM `ttt` WHERE `communityid`= \"%s\";", sCommunityID); - if (g_cDebugMessages.BoolValue) + if (g_cDebug.BoolValue) { LogToFileEx(g_sKarmaFile, "(LoadClientKarma) - 2 Client: \"%L\", Query: \"%s\"", client, sQuery); } - if (g_cDebugMessages.BoolValue) + if (g_cDebug.BoolValue) { LogToFileEx(g_sLogFile, sQuery); } if (g_dDB != null) { - if (g_cDebugMessages.BoolValue) + if (g_cDebug.BoolValue) { LogToFileEx(g_sKarmaFile, "(LoadClientKarma) - 3 Client: \"%L\", Valid Database", client); }