diff --git a/RaceTimer/scripting/unloze_racetimer_redux.sp b/RaceTimer/scripting/unloze_racetimer_redux.sp index d7391ebd..d452a98f 100755 --- a/RaceTimer/scripting/unloze_racetimer_redux.sp +++ b/RaceTimer/scripting/unloze_racetimer_redux.sp @@ -27,6 +27,7 @@ float g_fClient_End_time[MAXPLAYERS + 1]; int g_iClientFrames[MAXPLAYERS + 1]; int g_iClientSpeedInterval[MAXPLAYERS + 1]; int g_iClientChecking[MAXPLAYERS + 1]; +bool g_bClientsIgnoring[MAXPLAYERS + 1]; bool g_bDisplaySpecial; bool g_bHumansAllowedTime[MAXPLAYERS + 1]; bool g_bhumans_finished[MAXPLAYERS + 1]; @@ -56,6 +57,8 @@ public void OnPluginStart() { //cmds RegConsoleCmd("sm_toptime", cmd_timerCheckTop, "checking top 10"); + RegConsoleCmd("sm_ignoretimer", cmd_timerIgnoreTime, "All racetimer will be ignored for you"); + RegConsoleCmd("sm_ignoretime", cmd_timerIgnoreTime, "All racetimer will be ignored for you"); RegConsoleCmd("sm_mytime", cmd_timerCheckSelf, "checking your personal time"); RegConsoleCmd("sm_stages", cmd_timerCheckStage, "Checking race stages"); RegConsoleCmd("sm_hidetimer", cmd_hideTimerHUD, "Hides timer HUD"); @@ -401,8 +404,36 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast //---------------------------------------------------------------------------------------------------- public void OnClientPostAdminCheck(int client) { - resetClient(client); - insertPlayerMYSQL(client); + resetClient(client); + insertPlayerMYSQL(client); + client_ignoring_racetimer(client); +} + +public void client_ignoring_racetimer(int client) +{ + char query[g_dLength]; + char steam_auth[g_dIndex]; + GetClientAuthId(client, AuthId_Steam2, steam_auth, sizeof(steam_auth)); + Format(query, sizeof(query), "SELECT is_ignoring FROM `zetimer_table_new_ignoring` where steam_auth = '%s'", steam_auth); + g_dDatabase.Query(SQL_OnQueryCompleted_ignoring, query, client); +} + +public void SQL_OnQueryCompleted_ignoring(Database db, DBResultSet results, const char[] error, int client) +{ + if (!db) + { + return; + } + if (!IsValidClient(client)) + return; + int val = 0; + if (results.RowCount && results.FetchRow()) + val = results.FetchInt(0); + g_bClientsIgnoring[client] = false; + if (val == 1) + { + g_bClientsIgnoring[client] = true; + } } //---------------------------------------------------------------------------------------------------- // Purpose: @@ -428,6 +459,7 @@ public void resetClient(int client) if (0 < client <= MaxClients) { g_iClientChecking[client] = 0; + g_bClientsIgnoring[client] = false; g_bHumansAllowedTime[client] = false; g_bhumans_finished[client] = false; g_fClient_End_time[client] = 0.0; @@ -603,6 +635,10 @@ public bool checkClientOrigin(float oldVals[3], float newVals[3], int client) //---------------------------------------------------------------------------------------------------- public void unloze_zoneEntry(int client, char[] zone) { + if (g_bClientsIgnoring[client]) + { + return; + } int zoneIndex = RetrieveZoneIndex(zone); int race_zone_count = GetTotalRaceZones(); if (!(StrEqual(zone, g_cSpecialMapEnd)) && !race_zone_count) @@ -630,6 +666,10 @@ public void unloze_zoneEntry(int client, char[] zone) public void unloze_zoneLeave(int client, char[] zone) { //only maps with multiple zones need ZONE_PREFIX_START + if (g_bClientsIgnoring[client]) + { + return; + } int race_zone_count = GetTotalRaceZones(); if (!(StrEqual(zone, g_cSpecialMapStart)) && !race_zone_count) return; @@ -875,6 +915,47 @@ public void insertPlayerMYSQL(int client) //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- +public Action cmd_timerIgnoreTime(int client, int args) +{ + insert_client_ignoring_racetimer(client); + return Plugin_Handled; +} +public void insert_client_ignoring_racetimer(int client) +{ + if (!IsValidClient(client)) + return; + if (g_bClientsIgnoring[client]) + { + g_bClientsIgnoring[client] = false; + g_bHideTimer[client] = false; + SetClientCookie(client, g_hClientCookie, "0"); + PrintToChat(client, "You are now not ignoring the racetimer"); + } + else + { + g_bClientsIgnoring[client] = true; + g_bHideTimer[client] = true; + SetClientCookie(client, g_hClientCookie, "1"); + PrintToChat(client, "You are now ignoring the racetimer"); + } + char sSID[g_dIndex]; + char sQuery[g_dLength]; + GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID)); + if (!g_dDatabase) + { + Database.Connect(SQL_OnDatabaseConnect, "racetimercss"); + return; + } + if (StrEqual(sSID, "STEAM_ID_STOP_IGNORING_RETVALS") || StrEqual(sSID, "STEAM_ID_PENDING")) + { + PrintToChat(client, "Your steam ID is not working, not updating timer"); + return; + } + Format(sQuery, sizeof(sQuery), "INSERT INTO `zetimer_table_new_ignoring` (`steam_auth`, `is_ignoring`) VALUES ('%s', '%i') ON DUPLICATE KEY UPDATE `is_ignoring` = '%i'", sSID, g_bClientsIgnoring[client], g_bClientsIgnoring[client]); + DataPack hDataPack = new DataPack(); + hDataPack.WriteString(sQuery); + g_dDatabase.Query(SQL_FinishedQuery, sQuery, hDataPack, DBPrio_Normal); +} public Action cmd_timerCheckTop(int client, int args) { CheckTop(client, 0, 0);