diff --git a/RaceTimer/scripting/unloze_racetimer_redux.sp b/RaceTimer/scripting/unloze_racetimer_redux.sp index d2e49585..1c32b9be 100644 --- a/RaceTimer/scripting/unloze_racetimer_redux.sp +++ b/RaceTimer/scripting/unloze_racetimer_redux.sp @@ -54,6 +54,7 @@ public void OnPluginStart() 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"); + RegAdminCmd("sm_cleantime", Cmd_timeReset, ADMFLAG_GENERIC); //hooks HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy); //HUD @@ -776,6 +777,28 @@ public int MenuHandler1(Menu menu, MenuAction action, int param1, int param2) } //---------------------------------------------------------------------------------------------------- // Purpose: +//---------------------------------------------------------------------------------------------------- +public Action Cmd_timeReset(int client, int args) +{ + if (!IsValidClient(client)) + return Plugin_Handled; + if (args != 2) + { + ReplyToCommand(client, "[SM] Usage cleantime "); + return Plugin_Handled; + } + char sTarget[65], steam2[64]; + GetCmdArg(1, sTarget, sizeof(sTarget)); + int targetID = FindTarget(client, sTarget, false); + if(targetID == -1) + return Plugin_Handled; + GetClientAuthId(targetID, AuthId_Steam2, steam2, sizeof(steam2)); + GetCmdArg(2, sTarget, sizeof(sTarget)); + deleteClientTime(steam2, StringToInt(sTarget)); + return Plugin_Handled; +} +//---------------------------------------------------------------------------------------------------- +// Purpose: //---------------------------------------------------------------------------------------------------- public Action cmd_hideTimerHUD(int client, int args) { @@ -878,6 +901,24 @@ public Action cmd_timerCheckSelf(int client, int args) //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- +public void deleteClientTime(char[] steam2, int stage) +{ + char l_cQuery[g_dLength]; + if (stage > 1) + { + Format(l_cQuery, sizeof(l_cQuery), "UPDATE `zetimer_table` SET `%sS%i` = 0.000 WHERE steam_auth = '%s'", g_cMapname, stage, steam2); + } + else + { + Format(l_cQuery, sizeof(l_cQuery), "UPDATE `zetimer_table` SET `%s` = 0.000 WHERE steam_auth = '%s'", g_cMapname, steam2); + SQL_TQuery(g_dDatabase, DummyCallbackSimple, l_cQuery); + Format(l_cQuery, sizeof(l_cQuery), "UPDATE `zetimer_table` SET `%sS1` = 0.000 WHERE steam_auth = '%s'", g_cMapname, steam2); + } + SQL_TQuery(g_dDatabase, DummyCallbackSimple, l_cQuery); +} +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- public void Checkself(int client) { int l_iZoneCount = unloze_zoneCount();