diff --git a/misc/import_stats.sql b/misc/import_stats.sql index ca5d9ec41..3c5263dff 100644 --- a/misc/import_stats.sql +++ b/misc/import_stats.sql @@ -13,14 +13,16 @@ CREATE TABLE `get5_stats_matches` `team1_score` smallint(5) unsigned NOT NULL DEFAULT '0', `team2_name` varchar(64) NOT NULL DEFAULT '', `team2_score` smallint(5) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`matchid`) + `server_id` int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`matchid`), + KEY `server_id` (`server_id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; CREATE TABLE `get5_stats_maps` ( `matchid` int(10) unsigned NOT NULL, - `mapnumber` smallint(5) unsigned NOT NULL, + `mapnumber` tinyint(3) unsigned NOT NULL, `start_time` datetime NOT NULL, `end_time` datetime NULL DEFAULT NULL, `winner` varchar(16) NOT NULL DEFAULT '', @@ -35,8 +37,8 @@ CREATE TABLE `get5_stats_maps` CREATE TABLE `get5_stats_players` ( `matchid` int(10) unsigned NOT NULL, - `mapnumber` smallint(5) unsigned NOT NULL, - `steamid64` varchar(32) NOT NULL, + `mapnumber` tinyint(3) unsigned NOT NULL, + `steamid64` bigint(21) unsigned NOT NULL, `team` varchar(16) NOT NULL DEFAULT '', `rounds_played` smallint(5) unsigned NOT NULL, `name` varchar(64) NOT NULL, diff --git a/scripting/get5/natives.sp b/scripting/get5/natives.sp index 0e83704bc..292644c1f 100644 --- a/scripting/get5/natives.sp +++ b/scripting/get5/natives.sp @@ -16,6 +16,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max CreateNative("Get5_GetTeamScores", Native_GetTeamScores); CreateNative("Get5_GetMatchID", Native_GetMatchID); CreateNative("Get5_SetMatchID", Native_SetMatchID); + CreateNative("Get5_GetServerID", Native_GetServerID); CreateNative("Get5_AddLiveCvar", Native_AddLiveCvar); CreateNative("Get5_IncreasePlayerStat", Native_IncreasePlayerStat); CreateNative("Get5_GetMatchStats", Native_GetMatchStats); @@ -193,6 +194,10 @@ public int Native_SetMatchID(Handle plugin, int numParams) { return 0; } +public int Native_GetServerID(Handle plugin, int numParams) { + return g_ServerIdCvar.IntValue; +} + public int Native_AddLiveCvar(Handle plugin, int numParams) { char cvarName[MAX_CVAR_LENGTH]; char cvarValue[MAX_CVAR_LENGTH]; diff --git a/scripting/get5_mysqlstats.sp b/scripting/get5_mysqlstats.sp index dafd7303e..145d56bb4 100644 --- a/scripting/get5_mysqlstats.sp +++ b/scripting/get5_mysqlstats.sp @@ -78,6 +78,8 @@ public void Get5_OnSeriesInit() { char team1Name[64]; char team2Name[64]; + int serverId = Get5_GetServerID(); + char seriesTypeSz[sizeof(seriesType) * 2 + 1]; char team1NameSz[sizeof(team1Name) * 2 + 1]; char team2NameSz[sizeof(team2Name) * 2 + 1]; @@ -103,9 +105,9 @@ public void Get5_OnSeriesInit() { SetMatchID(g_ForceMatchIDCvar.IntValue); g_ForceMatchIDCvar.IntValue = 0; Format(queryBuffer, sizeof(queryBuffer), "INSERT INTO `get5_stats_matches` \ - (matchid, series_type, team1_name, team2_name, start_time) VALUES \ - (%d, '%s', '%s', '%s', NOW())", - g_MatchID, seriesTypeSz, team1NameSz, team2NameSz); + (matchid, series_type, team1_name, team2_name, start_time, server_id) VALUES \ + (%d, '%s', '%s', '%s', NOW(), %d)", + g_MatchID, seriesTypeSz, team1NameSz, team2NameSz, serverId); LogDebug(queryBuffer); db.Query(SQLErrorCheckCallback, queryBuffer); @@ -114,9 +116,9 @@ public void Get5_OnSeriesInit() { } else { Format(queryBuffer, sizeof(queryBuffer), "INSERT INTO `get5_stats_matches` \ - (series_type, team1_name, team2_name, start_time) VALUES \ - ('%s', '%s', '%s', NOW())", - seriesTypeSz, team1NameSz, team2NameSz); + (series_type, team1_name, team2_name, start_time, server_id) VALUES \ + ('%s', '%s', '%s', NOW(), %d)", + seriesTypeSz, team1NameSz, team2NameSz, serverId); LogDebug(queryBuffer); db.Query(MatchInitCallback, queryBuffer); diff --git a/scripting/include/get5.inc b/scripting/include/get5.inc index fd726179a..47ab007a9 100644 --- a/scripting/include/get5.inc +++ b/scripting/include/get5.inc @@ -136,6 +136,9 @@ native void Get5_GetMatchID(char[] id, int length); // Sets the current matchid. native void Get5_SetMatchID(const char[] id); +// Returns the server ID as defined by get5_server_id. +native int Get5_GetServerID(); + // Adds a cvar to be set when going live. If the cvar is already in the cvars for the match, the new // value will replace the old value if the override parameter is true. // Note: this should only be used when a match config loaded. @@ -224,6 +227,7 @@ public __pl_get5_SetNTVOptional() { MarkNativeAsOptional("Get5_GetTeamScores"); MarkNativeAsOptional("Get5_GetMatchID"); MarkNativeAsOptional("Get5_SetMatchID"); + MarkNativeAsOptional("Get5_GetServerID"); MarkNativeAsOptional("Get5_AddLiveCvar"); MarkNativeAsOptional("Get5_IncreasePlayerStat"); MarkNativeAsOptional("Get5_GetMatchStats");