From 3a3d649b63f1262f5f0b3ccedbad0752c175c813 Mon Sep 17 00:00:00 2001 From: Dogan Date: Sun, 29 Dec 2019 14:48:47 +0100 Subject: [PATCH] PlaytimeStats: hey look a commit by me switch from Minutes to Day/Hours in topplaytime display --- PlaytimeStats/scripting/PlaytimeStats.sp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/PlaytimeStats/scripting/PlaytimeStats.sp b/PlaytimeStats/scripting/PlaytimeStats.sp index 81fc1608..7176a68d 100644 --- a/PlaytimeStats/scripting/PlaytimeStats.sp +++ b/PlaytimeStats/scripting/PlaytimeStats.sp @@ -163,7 +163,7 @@ public void SQL_OnQueryCompletedTime(Database db, DBResultSet results, const cha } char sTime[64]; - int iDays = (iTime/ 86400); + int iDays = (iTime / 86400); int iHours = (iTime / 3600) % 24; int iMinutes = (iTime / 60) % 60; int iSeconds = (iTime % 60); @@ -214,7 +214,10 @@ public void SQL_OnQueryCompletedTopTime(Database db, DBResultSet results, const char sName[12][32]; int iTime[12]; - char sBuffer[12][128]; + int iDays[12]; + int iHours[12]; + char sTime[12][32]; + char sBuffer[12][256]; Panel mSayPanel = new Panel(GetMenuStyleHandle(MenuStyle_Radio)); @@ -235,12 +238,17 @@ public void SQL_OnQueryCompletedTopTime(Database db, DBResultSet results, const results.FieldNameToNum("name", iFieldNum); results.FetchString(iFieldNum, sName[i - 1], 32); - results.FieldNameToNum("time", iFieldNum); iTime[i - 1] = results.FetchInt(iFieldNum); - iTime[i - 1] = iTime[i - 1] / 60; + iDays[i - 1] = (iTime[i - 1] / 86400); + iHours[i - 1] = (iTime[i - 1] / 3600) % 24; - Format(sBuffer[i - 1], 128, "%d. %s - %d Minutes", i, sName[i - 1], iTime[i - 1]); + if (iDays[i - 1]) + Format(sTime[i - 1], 32, "%d Days %d Hours", iDays[i - 1], iHours[i - 1]); + else if (iHours[i - 1]) + Format(sTime[i - 1], 32, "%d Hours", iHours[i - 1]); + + Format(sBuffer[i - 1], 128, "%d. %s - %s", i, sName[i - 1], sTime[i - 1]); mSayPanel.DrawText(sBuffer[i - 1]); }