Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning message when starting a non-global run #319

Merged
merged 2 commits into from
Apr 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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