Skip to content

Commit

Permalink
Merge pull request #319 from walliski/warn-non-global
Browse files Browse the repository at this point in the history
Add warning message when starting a non-global run
  • Loading branch information
zealain committed Apr 23, 2022
2 parents bdefa3d + 0bd0b3c commit 96021c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
20 changes: 20 additions & 0 deletions addons/sourcemod/scripting/gokz-global.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -259,6 +260,24 @@ 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 (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");
}

return Plugin_Continue;
}

public void GOKZ_OnTimerStart_Post(int client, int course)
{
KZPlayer player = KZPlayer(client);
Expand Down Expand Up @@ -512,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();
Expand Down
4 changes: 4 additions & 0 deletions addons/sourcemod/translations/gokz-global.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]=====
Expand Down

0 comments on commit 96021c9

Please sign in to comment.