From 24a3a21d55966a52b7860f725dac5d1a3b8928d1 Mon Sep 17 00:00:00 2001 From: jenzur Date: Sun, 4 Aug 2019 12:59:39 +0200 Subject: [PATCH] hud client cookie --- RaceTimer/scripting/unloze_racetimer_redux.sp | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/RaceTimer/scripting/unloze_racetimer_redux.sp b/RaceTimer/scripting/unloze_racetimer_redux.sp index 2f510ca9..6b04341a 100644 --- a/RaceTimer/scripting/unloze_racetimer_redux.sp +++ b/RaceTimer/scripting/unloze_racetimer_redux.sp @@ -6,6 +6,7 @@ #define g_dIndex 65 #include #include +#include #include #include #include @@ -32,6 +33,7 @@ int g_iClientChecking[MAXPLAYERS + 1]; bool g_bDisplaySpecial; bool g_bHumansAllowedTime[MAXPLAYERS + 1]; bool g_bHideTimer[MAXPLAYERS + 1]; +Handle g_hClientCookie = INVALID_HANDLE; Database g_dDatabase; Handle hText; public Plugin myinfo = @@ -56,7 +58,17 @@ public void OnPluginStart() HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy); //HUD hText = CreateHudSynchronizer(); -} + //cookies + g_hClientCookie = RegClientCookie("hide_timer_cookie", "Hides the timer HUD", CookieAccess_Private); + for (int i = MaxClients; i > 0; --i) + { + if (!AreClientCookiesCached(i)) + { + continue; + } + OnClientCookiesCached(i); + } +} //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -132,7 +144,15 @@ public void OnClientPostAdminCheck(int client) resetClient(client); MYSQLCheckRecord(client); g_bHumansAllowedTime[client] = false; - g_bHideTimer[client] = false; +} +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnClientCookiesCached(int client) +{ + char sValue[8]; + GetClientCookie(client, g_hClientCookie, sValue, sizeof(sValue)); + g_bHideTimer[client] = (sValue[0] != '\0' && !!StringToInt(sValue)); } //---------------------------------------------------------------------------------------------------- // Purpose: @@ -152,7 +172,6 @@ public void resetClient(int client) g_iClientStage[client] = 0; g_bHumansAllowedTime[client] = false; resetClientVectors(client); - g_bHideTimer[client] = false; for (int iterator = 0; iterator < 100; iterator++) { g_iRecordMinutes[client][iterator] = 0; @@ -727,8 +746,9 @@ public Action cmd_hideTimerHUD(int client, int args) if (!g_bHideTimer[client]) { g_bHideTimer[client] = true; + SetClientCookie(client, g_hClientCookie, "1"); PrintToChat(client, "Disabled timer HUD"); - } else { g_bHideTimer[client] = false; PrintToChat(client, "Enabled timer HUD"); } + } else { g_bHideTimer[client] = false; PrintToChat(client, "Enabled timer HUD"); SetClientCookie(client, g_hClientCookie, "0"); } } //---------------------------------------------------------------------------------------------------- // Purpose: