• Welcome to Valhalla Legends Archive.
 

Help Me With GetTickCount

Started by ChR0NiC, December 13, 2003, 12:07 AM

Previous topic - Next topic

ChR0NiC

Ok I want to use GetTickCount to calculate how long someone has been in the channel for unless they were already there when I was joined. But I can't seem to get it to work for each individual user. Only join/leave to do with everyone.

I am using VB.


Private Sub Event_Join
JoinTime = GetTickCount
End If

Private Sub Event_Leave
addC vbGreen, strUser has left the channel after " & FormatCount(GetTickCount - JoinTime)
End Sub


That is basically what I am trying to do. If anyone can help me out...please do. Thanks alot guys ^^

Soul Taker

That will only work if no one joins between each user joining and leaving.

Adron

Unless JoinTime is a member variable of a class?

iago

You should also note that GetTickCount isn't completely reliable for a couple reasons.  The only one I know is overflow problems if your computer is on for a very long time.  

Also note that GetTickCount is milliseconds, not seconds.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Spht

Quote from: iago on December 13, 2003, 07:47 AM
You should also note that GetTickCount isn't completely reliable for a couple reasons.  The only one I know is overflow problems if your computer is on for a very long time.  

That can easily be worked around with something like a GetDifference function which can safely calculate GetTickCount differences from positive to positive, negative to positive, negative to negative, and positive to negative.

iago

What if it resets?  Like, they join at 0xFFFFFFF8, and they leave at 15?  Or what if they stay in the channel more than 28 days?
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Spht

Quote from: iago on December 13, 2003, 09:14 AM
What if it resets?  Like, they join at 0xFFFFFFF8, and they leave at 15?

Would return 0x0100000007 (Double).

Quote from: iago on December 13, 2003, 09:14 AM
Or what if they stay in the channel more than 28 days?

What if? Then I'd be checking a negative with a positive (which is what the function is prepared to handle).

Adron

#7
All of this works much better in C/C++, where you just do the subtraction, get the overflow (which is ignored), and get the correct value. It will work fine as long as the user hasn't been there more than 2**32-1 milliseconds.


edit: -1 milliseconds

iago

Quote from: Spht on December 13, 2003, 09:26 AM
Would return 0x0100000007 (Double).

GetTickCount returns a DWORD, which will never pass 0xFFFFFFFF.

How do you get 0x100000007?
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Spht

Quote from: iago on December 13, 2003, 09:37 AM
Quote from: Spht on December 13, 2003, 09:26 AM
Would return 0x0100000007 (Double).

GetTickCount returns a DWORD, which will never pass 0xFFFFFFFF.

How do you get 0x100000007?

You gave me two numbers to find difference of, so can go over 0xFFFFFFFF... 0xFFFFFFFF*2 == 0x1FFFFFFFE for example.

Adron

Quote from: Spht on December 13, 2003, 10:12 AM
Quote from: iago on December 13, 2003, 09:37 AM
Quote from: Spht on December 13, 2003, 09:26 AM
Would return 0x0100000007 (Double).

GetTickCount returns a DWORD, which will never pass 0xFFFFFFFF.

How do you get 0x100000007?

You gave me two numbers to find difference of, so can go over 0xFFFFFFFF... 0xFFFFFFFF*2 == 0x1FFFFFFFE for example.

What you did was find the sum though...