From 0bd1bcd40f4a25c55cbffc8038925b6450b222af Mon Sep 17 00:00:00 2001 From: Nicolai Cornelis Date: Thu, 28 Jul 2022 00:04:18 +0200 Subject: [PATCH] Consider "scrim" and "manual" matchID to be the same as no match ID in MySQL context --- documentation/docs/commands.md | 2 +- documentation/docs/match_schema.md | 6 ++++-- documentation/docs/stats_system.md | 11 ++++++----- scripting/get5/natives.sp | 1 + scripting/get5_mysqlstats.sp | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/documentation/docs/commands.md b/documentation/docs/commands.md index 9d222c33a..a122eb5d0 100644 --- a/documentation/docs/commands.md +++ b/documentation/docs/commands.md @@ -157,7 +157,7 @@ name. 2. The current state of the game. The definition lists them in the order they occur. 3. Whether the game is currently paused. 4. The match configuration file currently loaded. `Example: "addons/sourcemod/configs/get5/match_config.json"`. - 5. The current match ID. Empty string if not defined. + 5. The current match ID. Empty string if not defined or `scrim` or `manual` if using `get5_scrim` or `get5_creatematch`. 6. The current map number, starting at `0`. You can use this to determine the current map by looking at the `maps` array. 7. The current round number, starting at `0`. `-1` if `gamestate` is not `live`. diff --git a/documentation/docs/match_schema.md b/documentation/docs/match_schema.md index b42ada450..4dae8207c 100644 --- a/documentation/docs/match_schema.md +++ b/documentation/docs/match_schema.md @@ -58,8 +58,10 @@ interface Get5Match { } ``` -1. _Optional_ - The ID of the match. This determines the `matchid` parameter in all the forwards and events. - **`Default: ""`** +1. _Optional_ - The ID of the match. This determines the `matchid` parameter in all the forwards and events. If you use +the [MySQL extension](../stats_system/#mysql), you should leave this field blank (or omit it), as match IDs will be +assigned automatically. If you do want to assign match IDs from another source, they **must** be integers (in a string) +and must increment between matches. **`Default: ""`** 2. _Optional_ - The number of maps to play in the series. **`Default: 3`** 3. _Optional_ - The number of players per team. **`Default: 5`** 4. _Optional_ - The maximum number of coaches per team. **`Default: 2`** diff --git a/documentation/docs/stats_system.md b/documentation/docs/stats_system.md index ce3742053..e9105cdc8 100644 --- a/documentation/docs/stats_system.md +++ b/documentation/docs/stats_system.md @@ -57,10 +57,10 @@ Partial Example: ## What Stats Are Collected -See the [get5 include](https://github.com/splewis/get5/blob/master/scripting/include/get5.inc#L171) for what stats will -be recorded and what their key in the keyvalues structure is. +See the [get5 include](https://github.com/splewis/get5/blob/master/scripting/include/get5.inc#L1769) for what stats will +be recorded and what their key in the KeyValue structure is. -## MySQL Statistics +## MySQL Statistics {: #mysql } Get5 ships with a (disabled by default) plugin called `get5_mysqlstats` that will save many of the stats to a MySQL database. To use this: @@ -72,8 +72,9 @@ database. To use this: directory). **Note**: If you use this module, you can force the match ID used by setting it in your match config -(the [Match Schema](./match_schema/#optional-values) section). If you don't do this, the match ID will be set to the -auto-incrementing integer (cast to a string) returned by inserting into the `get5_stats_matches` table. +(the [Match Schema](../match_schema/#optional-values) section). If you don't do this, the match ID will be set to the +auto-incrementing integer (cast to a string) returned by inserting into the `get5_stats_matches` table. It is strongly +recommended that you always leave the `matchid` blank, as MySQL will then manage the IDs for you. If you are using an external web panel, **this plugin is not needed** as most external applications record to their own match tables. diff --git a/scripting/get5/natives.sp b/scripting/get5/natives.sp index 2a93960aa..683a29f2f 100644 --- a/scripting/get5/natives.sp +++ b/scripting/get5/natives.sp @@ -192,6 +192,7 @@ public int Native_GetMatchID(Handle plugin, int numParams) { public int Native_SetMatchID(Handle plugin, int numParams) { GetNativeString(1, g_MatchID, sizeof(g_MatchID)); + WriteBackup(); return 0; } diff --git a/scripting/get5_mysqlstats.sp b/scripting/get5_mysqlstats.sp index ee2c82e76..26dea7ce4 100644 --- a/scripting/get5_mysqlstats.sp +++ b/scripting/get5_mysqlstats.sp @@ -91,7 +91,7 @@ public void Get5_OnSeriesInit(const Get5SeriesStartedEvent event) { delete tmpStats; // Match ID defaults to an empty string, so if it's empty we use auto-increment from MySQL. - if (strlen(matchId) > 0) { + if (strlen(matchId) > 0 && !StrEqual(matchId, "scrim") && !StrEqual(matchId, "manual")) { char matchIdSz[64]; db.Escape(matchId, matchIdSz, sizeof(matchIdSz));