Skip to content

Commit

Permalink
Add cvar get5_auto_dump_stats.
Browse files Browse the repository at this point in the history
  • Loading branch information
splewis committed Jun 14, 2016
1 parent ca761d6 commit b43869d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}``)
Expand Down
3 changes: 3 additions & 0 deletions scripting/get5.sp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
***********************/

/** ConVar handles **/
ConVar g_AutoDumpStatsCvar;
ConVar g_AutoLoadConfigCvar;
ConVar g_BackupSystemEnabledCvar;
ConVar g_CheckAuthsCvar;
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions scripting/get5/stats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}

0 comments on commit b43869d

Please sign in to comment.