From 3a847b973672ceb8de3cf0b53a50de9e11bf8998 Mon Sep 17 00:00:00 2001 From: Walliski Date: Mon, 11 Apr 2022 21:29:05 +0300 Subject: [PATCH 1/2] Add warning message when starting a non-global run In case the map is the wrong version, or the server is not updated the user might not realize that the run will not be saved in the global api. To avoid the confusion, we show them an error message. To prevent spam of the message, we first check if the server is intended to be global, by verifying that the GlobalApi plugin has a key set. Further if the user already has a run going when resetting the timer, they will not get the message again. If they stop the timer and start it again, it will show the message again. --- addons/sourcemod/scripting/gokz-global.sp | 15 +++++++++++++++ .../translations/gokz-global.phrases.txt | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/addons/sourcemod/scripting/gokz-global.sp b/addons/sourcemod/scripting/gokz-global.sp index 82abe48b..67977d84 100644 --- a/addons/sourcemod/scripting/gokz-global.sp +++ b/addons/sourcemod/scripting/gokz-global.sp @@ -259,6 +259,21 @@ public void GlobalAPI_OnInitialized() SetupAPI(); } + +public Action GOKZ_OnTimerStart(int client, int course) +{ + KZPlayer player = KZPlayer(client); + int mode = player.Mode; + + // We check the timer running to prevent spam when standing inside VB. + if (GlobalAPI_HasAPIKey() && !GlobalsEnabled(mode) && !GOKZ_GetTimerRunning(client)) + { + GOKZ_PrintToChat(client, true, "%t", "Warn Player Not Global Run"); + } + + return Plugin_Continue; +} + public void GOKZ_OnTimerStart_Post(int client, int course) { KZPlayer player = KZPlayer(client); diff --git a/addons/sourcemod/translations/gokz-global.phrases.txt b/addons/sourcemod/translations/gokz-global.phrases.txt index a9e07e62..a4e2694e 100644 --- a/addons/sourcemod/translations/gokz-global.phrases.txt +++ b/addons/sourcemod/translations/gokz-global.phrases.txt @@ -200,6 +200,10 @@ "en" "Your m_yaw value must be less or equal to 0.3 to play on this server" "ru" "Ваше значение m_yaw должно быть меньше или равно 0.3 для игры на этом сервере." } + "Warn Player Not Global Run" + { + "en" "{yellow}Warning{grey}: The current map did not pass the Global check. Global times will not save. See {default}!globalcheck{grey} for more information." + } // =====[ GLOBAL TOP MENU ]===== From 0bd0b3cae45b401a161ee800c4a31272153d0bd6 Mon Sep 17 00:00:00 2001 From: Walliski Date: Mon, 11 Apr 2022 21:45:07 +0300 Subject: [PATCH 2/2] Add gokz_warn_for_non_global_map cvar This allows server owners to disable the warnings for non-global maps. This is useful in cases where you host a lot of non-global maps on your server. The default value is to warn users about non-global times, as most servers that have the GlobalAPI Key set mainly host global maps. --- addons/sourcemod/scripting/gokz-global.sp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/sourcemod/scripting/gokz-global.sp b/addons/sourcemod/scripting/gokz-global.sp index 67977d84..c7d6eabc 100644 --- a/addons/sourcemod/scripting/gokz-global.sp +++ b/addons/sourcemod/scripting/gokz-global.sp @@ -54,6 +54,7 @@ int gI_MapFileSize; int gI_MapTier; ConVar gCV_gokz_settings_enforcer; +ConVar gCV_gokz_warn_for_non_global_map; ConVar gCV_EnforcedCVar[ENFORCEDCVAR_COUNT]; #include "gokz-global/api.sp" @@ -266,7 +267,10 @@ public Action GOKZ_OnTimerStart(int client, int course) int mode = player.Mode; // We check the timer running to prevent spam when standing inside VB. - if (GlobalAPI_HasAPIKey() && !GlobalsEnabled(mode) && !GOKZ_GetTimerRunning(client)) + if (gCV_gokz_warn_for_non_global_map.BoolValue + && GlobalAPI_HasAPIKey() + && !GlobalsEnabled(mode) + && !GOKZ_GetTimerRunning(client)) { GOKZ_PrintToChat(client, true, "%t", "Warn Player Not Global Run"); } @@ -527,6 +531,7 @@ static void CreateConVars() AutoExecConfig_SetCreateFile(true); gCV_gokz_settings_enforcer = AutoExecConfig_CreateConVar("gokz_settings_enforcer", "1", "Whether GOKZ enforces convars required for global records.", _, true, 0.0, true, 1.0); + gCV_gokz_warn_for_non_global_map = AutoExecConfig_CreateConVar("gokz_warn_for_non_global_map", "1", "Whether or not GOKZ should warn players if the global check does not pass.", _, true, 0.0, true, 1.0); gCV_gokz_settings_enforcer.AddChangeHook(OnConVarChanged); AutoExecConfig_ExecuteFile();