From c4f31e542f2973ead9b7f914cea3b9961db26cde Mon Sep 17 00:00:00 2001 From: hubdom <26039831+hubdom@users.noreply.github.com> Date: Sun, 26 Sep 2021 20:31:23 +0200 Subject: [PATCH] new discord webhook for admin-logs + less precision for console timer --- .../scripting/unloze_ConsoleMessages.sp | 37 +++++-------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/unloze_ConsoleMessages/scripting/unloze_ConsoleMessages.sp b/unloze_ConsoleMessages/scripting/unloze_ConsoleMessages.sp index a54b3551..b5430713 100644 --- a/unloze_ConsoleMessages/scripting/unloze_ConsoleMessages.sp +++ b/unloze_ConsoleMessages/scripting/unloze_ConsoleMessages.sp @@ -151,7 +151,7 @@ public Action PointServerCommandForward(const char[] sCommand) { float client_time = GetRoundTimeAtTimerEnd(number); char sTime[32]; - FormatPlayerTime(client_time, sTime, sizeof(sTime), false, 1); + FormatPlayerTime(client_time, sTime, sizeof(sTime)); Format(sSecondsAppend, sizeof(sSecondsAppend), " {green}@ %s", sTime); } } @@ -197,33 +197,14 @@ public Action PointServerCommandForward(const char[] sCommand) return Plugin_Continue; } -stock void FormatPlayerTime(float Time, char[] result, int maxlength, bool showDash, int precision) +stock void FormatPlayerTime(float fTime, char[] sResult, int iMaxlength) { - if(Time <= 0.0 && showDash == true) - { - Format(result, maxlength, "-"); - return; - } - int hours = RoundToFloor(Time/3600); - Time -= hours*3600; - int minutes = RoundToFloor(Time/60); - Time -= minutes*60; - float seconds = Time; + int iMinutes = RoundToFloor(fTime / 60); + fTime -= iMinutes * 60; + int iSeconds = RoundToFloor(fTime); - char sPrecision[16]; - - if(precision == 0) - Format(sPrecision, sizeof(sPrecision), (hours > 0 || minutes > 0)?"%04.1f":"%.1f", seconds); - else if(precision == 1) - Format(sPrecision, sizeof(sPrecision), (hours > 0 || minutes > 0)?"%06.3f":"%.3f", seconds); - else if(precision == 2) - Format(sPrecision, sizeof(sPrecision), (hours > 0 || minutes > 0)?"%09.6f":"%.6f", seconds); - - if(hours > 0) - Format(result, maxlength, "%d:%02d:%s", hours, minutes, sPrecision); - else if(minutes > 0) - Format(result, maxlength, "%d:%s", minutes, sPrecision); - else - Format(result, maxlength, "%s", sPrecision); + if(iMinutes) + Format(sResult, iMaxlength, "%d:%02d", iMinutes, iSeconds); + else + Format(sResult, iMaxlength, "%d", iSeconds); } -