• Welcome to Valhalla Legends Archive.
 

Bot Uptime

Started by OcTaViuS, May 10, 2003, 11:52 PM

Previous topic - Next topic

MrRaza

im surprized that he created his own function, did he?

Camel

Public Function UpTime() As String
   Dim ticks As Long
   ticks = GetTickCount
   UpTime = "Computer on for " & GetTime(ticks) & _
            ", running for " & GetTime(ticks - StartTime) & _
            ", logged on for " & GetTime(ticks - LogTime)
End Function

Public Function Zero(str As String, Count As Long, Optional Char As Byte = "0") As String
   Zero = String(Count - Len(str), CStr(Char)) & str
End Function

Public Function GetTime(ByVal ticks As Long, Optional ShowDecimals As Boolean = False) As String
   Dim TS As Long, TM As Long, TH As Long, TD As Long, TW As Long

   TS = ticks \ 1000: ticks = ticks - TS * 1000
   TM = TS \ 60:            TS = TS - TM * 60
   TH = TM \ 60:            TM = TM - TH * 60
   TD = TH \ 24:            TH = TH - TD * 24
   TW = TD \ 7:             TD = TD - TW * 7
   
   GetTime = Zero(CStr(TS), 2) & IIf(ShowDecimals, "." & Zero(CStr(ticks), 3), "") & "s"
   If TM + TH + TD + TW > 0 Then GetTime = Zero(CStr(TM), 2) & "m " & GetTime
   If TH + TD + TW > 0 Then GetTime = Zero(CStr(TH), 2) & "h " & GetTime
   If TD + TW > 0 Then GetTime = CStr(TD) & "d " & GetTime
   If TW > 0 Then GetTime = CStr(TW) & "w " & GetTime
End Function


?UpTime
Computer on for 1w 2d 23h 03m 30s, running for 22h 04m 08s, logged on for 22h 04m 07s

OcTaViuS

camel u r god  :o. not only did u successfully answer my bot uptime question without making me guess on how to fix the code, but u also gave me the code for cpu uptime and connection uptime, the two uptimes i was about to try and figure out during the weekend.

gj & ty  8)

Kp

Quote from: OcTaViuS on May 23, 2003, 07:42 PM
camel u r god  :o. not only did u successfully answer my bot uptime question without making me guess on how to fix the code, but u also gave me the code for cpu uptime and connection uptime, the two uptimes i was about to try and figure out during the weekend.
gj & ty  8)
However, the code as provided won't properly render typical service uptimes.  You need a higher resolution solution.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

OcTaViuS

Quote from: Kp on May 23, 2003, 11:44 PM
However, the code as provided won't properly render typical service uptimes.  You need a higher resolution solution.

way to spoil the mood.

MrRaza

It's really not that hard. I'm sure that there is an example on pscode.com

OcTaViuS

mr. raza, camels method works perfectly...

MrRaza

I was regarding to the High Resolution solution kp was talking about.

Camel

Quote from: MrRaza on May 25, 2003, 04:25 PM
I was regarding to the High Resolution solution kp was talking about.

use quotes, fooligan

OcTaViuS

betcha cant say "Resolution Solution" 10x fast  :o good one KP  ::)