Skip to content

Commit

Permalink
Consider "scrim" and "manual" matchID to be the same as no match ID i…
Browse files Browse the repository at this point in the history
…n MySQL context (#795)
  • Loading branch information
nickdnk committed Jul 31, 2022
1 parent b1eb636 commit 744af48
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion documentation/docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ 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`](../commands/#get5_scrim) or [`get5_creatematch`](../commands/#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`.
Expand Down
6 changes: 4 additions & 2 deletions documentation/docs/match_schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`**
Expand Down
11 changes: 6 additions & 5 deletions documentation/docs/stats_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
1 change: 1 addition & 0 deletions scripting/get5/natives.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 4 additions & 1 deletion scripting/get5_mysqlstats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ 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) {
// We also consider "scrim" and "manual" candidates for auto-increment, as those are the fixed
// strings used for get5_scrim and get5_creatematch, so without that condition, those would break
// the default mysql as only integers are accepted.
if (strlen(matchId) > 0 && !StrEqual(matchId, "scrim") && !StrEqual(matchId, "manual")) {
char matchIdSz[64];
db.Escape(matchId, matchIdSz, sizeof(matchIdSz));

Expand Down

0 comments on commit 744af48

Please sign in to comment.