From ee95d3582e7a028789c042f8c884e01797a8aedc Mon Sep 17 00:00:00 2001 From: christian Date: Wed, 30 Jun 2021 17:42:45 +0200 Subject: [PATCH] changed how to evaluate if time is better --- RaceTimer/scripting/unloze_racetimer_redux.sp | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/RaceTimer/scripting/unloze_racetimer_redux.sp b/RaceTimer/scripting/unloze_racetimer_redux.sp index bfb99388..9ec015e7 100644 --- a/RaceTimer/scripting/unloze_racetimer_redux.sp +++ b/RaceTimer/scripting/unloze_racetimer_redux.sp @@ -576,21 +576,34 @@ public void FinishedStageRaceZone(int client) CPrintToChat(client, "{green}[UNLOZE] Client: %N Time: %s", client, sTime); int stage = player_stage[client]; char sQuery[g_dLength]; - if (l_iZoneCount < 2) - Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table` SET `%s` = '%s', name = '%s' WHERE steam_auth = '%s' and LENGTH(`%s`) >= LENGTH('%s') and STRCMP(`%s`, '%s') > 0", g_cMapname, sTime, sEscapedName, sSID, g_cMapname, sTime, g_cMapname, sTime); - else - Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table` SET `%sS%i` = '%s', name = '%s' WHERE steam_auth = '%s' and LENGTH(`%sS%i`) >= LENGTH('%s') and STRCMP(`%sS%i`, '%s') > 0", g_cMapname, stage, sTime, sEscapedName, sSID, g_cMapname, stage, sTime, g_cMapname, stage, sTime); - if (StrEqual(g_csTime_record[client], "0.000")) { CPrintToChat(client, "Your record: None yet\nCommand: !toptime !mytime !stages"); - if (l_iZoneCount < 2) - Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table` SET `%s` = '%s', name = '%s' WHERE steam_auth = '%s'", g_cMapname, sTime, sEscapedName, sSID); - else - Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table` SET `%sS%i` = '%s', name = '%s' WHERE steam_auth = '%s'", g_cMapname, stage, sTime, sEscapedName, sSID); } else + { CPrintToChat(client, "Your record: %s\nCommand: !toptime !mytime !stages", g_csTime_record[client]); + } + if (l_iZoneCount < 2) + Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table` SET `%s` = '%s', name = '%s' WHERE steam_auth = '%s'", g_cMapname, sTime, sEscapedName, sSID); + else + Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table` SET `%sS%i` = '%s', name = '%s' WHERE steam_auth = '%s'", g_cMapname, stage, sTime, sEscapedName, sSID); + int generic_length = 32; + char[][] sPart = new char[2][generic_length]; + float old_client_time = 0.0; + if (StrContains(g_csTime_record[client], ":") != -1) + { + ExplodeString(g_csTime_record[client], ":", sPart, 2, generic_length); + old_client_time = (StringToFloat(sPart[0]) * 60) + StringToFloat(sPart[1]); + } + else + { + old_client_time = StringToFloat(g_csTime_record[client]); + } + if (client_time >= old_client_time) + { + return; + } DataPack hDataPack = new DataPack(); hDataPack.WriteString(sQuery); g_dDatabase.Query(SQL_FinishedQuery, sQuery, hDataPack, DBPrio_High);