diff --git a/README.md b/README.md index d33b90534..16eb5e56a 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ Note: these are auto-executed on plugin start by the auto-generated (the 1st tim You should either set these in the above file, or in the match config's ``cvars`` section. +- ``get5_auto_dump_stats``: whether match stats keyvalues files are saved to a get5_matchstats_matchid.cfg file (updated each map end) - ``get5_autoload_config``: a config file to autoload on map starts if no match is loaded - ``get5_check_auths``: whether the steamids from a "players" section are used to force players onto teams (default 1) - ``get5_demo_name_format``: format to name demo files in (default ``{MATCHID}_map{MAPNUMBER}_{MAPNAME}``) diff --git a/scripting/get5.sp b/scripting/get5.sp index 1eef07ed5..ae61de25e 100644 --- a/scripting/get5.sp +++ b/scripting/get5.sp @@ -39,6 +39,7 @@ ***********************/ /** ConVar handles **/ +ConVar g_AutoDumpStatsCvar; ConVar g_AutoLoadConfigCvar; ConVar g_BackupSystemEnabledCvar; ConVar g_CheckAuthsCvar; @@ -167,6 +168,8 @@ public void OnPluginStart() { InitDebugLog(DEBUG_CVAR, "get5"); /** ConVars **/ + g_AutoDumpStatsCvar = CreateConVar("get5_auto_dump_stats", "0", + "Whether match stats keyvalues files are saved to a get5_matchstats_matchid.cfg file (updated each map end)"); g_AutoLoadConfigCvar = CreateConVar("get5_autoload_config", "", "Name of a match config file to automatically load when the server loads"); g_BackupSystemEnabledCvar = CreateConVar("get5_backup_system_enabled", "1", diff --git a/scripting/get5/stats.sp b/scripting/get5/stats.sp index 7c8f3c310..29464222b 100644 --- a/scripting/get5/stats.sp +++ b/scripting/get5/stats.sp @@ -21,6 +21,7 @@ public void Stats_InitSeries() { g_StatsKv.SetString(STAT_SERIESTYPE, seriesType); g_StatsKv.SetString(STAT_SERIES_TEAM1NAME, g_TeamNames[MatchTeam_Team1]); g_StatsKv.SetString(STAT_SERIES_TEAM2NAME, g_TeamNames[MatchTeam_Team2]); + DumpToFile(); } public void Stats_ResetRoundValues() { @@ -116,12 +117,15 @@ public void Stats_UpdateMapScore(MatchTeam winner) { g_StatsKv.SetString(STAT_DEMOFILENAME, g_DemoFileName); GoBackFromMap(); + + DumpToFile(); } public void Stats_SeriesEnd(MatchTeam winner) { char winnerString[16]; GetTeamString(winner, winnerString, sizeof(winnerString)); g_StatsKv.SetString(STAT_SERIESWINNER, winnerString); + DumpToFile(); } public Action Stats_PlayerDeathEvent(Event event, const char[] name, bool dontBroadcast) { @@ -367,3 +371,11 @@ static int GetClutchingClient(int csTeam) { return -1; } } + +public void DumpToFile() { + if (g_AutoDumpStatsCvar.IntValue != 0) { + char path[PLATFORM_MAX_PATH]; + Format(path, sizeof(path), "get5_matchstats_%s", g_MatchID); + g_StatsKv.ExportToFile(path); + } +}