Valhalla Legends Forums Archive | Battle.net Bot Development | Bnet connection uptime...

AuthorMessageTime
Jaquio
Uhh, Yea im back for more help because I know I can find it here err... atleast I hope. I was wondering how I would make it tell how long you are connected to bnet for I finally figured out System Uptime after 1 hour -_-, But Connection uptime is bothering me so I came here. I think im going to add everyone who helped me in the special thanks section of the bot. So... If anyone could please help me on how to do this that would be great.
January 19, 2004, 7:43 PM
K
Suppose you know the time that you first connected to battle.net, and you also know the current time. You now know how long you have been connected. This question really shouldn't be that stupifying.
January 19, 2004, 7:49 PM
Jaquio
[quote author=K link=board=17;threadid=4799;start=0#msg40169 date=1074541788]
Suppose you know the time that you first connected to battle.net, and you also know the current time. You now know how long you have been connected. This question really shouldn't be that stupifying.
[/quote]

But how would I get it to say how long they are connected for really... I don't get it...
January 19, 2004, 7:57 PM
UserLoser.
Assuming your using Visual Basic, here's a simple way (hopefully someone doesn't respond with the high res uptime bs) using GetTickCount:

[code]
Global WhenIConnected as Long
[/code]

When you first connected to Battle.net:

[code]
WhenIConnected = GetTickCount
[/code]

When you want to see your connection uptime

[code]
Dim ReturnValue as Long
ReturnValue = GetTickCount - WhenIConnected
[/code]

Then you take the ReturnValue, and process it the same way you process your function for computer's uptime
January 19, 2004, 8:06 PM
Tuberload
[quote author=Jaquio link=board=17;threadid=4799;start=0#msg40173 date=1074542229]
[quote author=K link=board=17;threadid=4799;start=0#msg40169 date=1074541788]
Suppose you know the time that you first connected to battle.net, and you also know the current time. You now know how long you have been connected. This question really shouldn't be that stupifying.
[/quote]

But how would I get it to say how long they are connected for really... I don't get it...
[/quote]

Upon connecting to Battle.net, save the current time to a variable. Then whenever you want to know how long you have been connected subtract the variable from the current time producing how long the bot has been connected.

Example:
[code]
connect()
{
... snipped for brevity
if (CONNECTED)
var time_connected = TIME;
}

TIME howLongHaveIBeenOn()
{
return getCurrentTime() - time_connected;
}[/code]

Edit: Userloser posted while I was, sorry for duplicate.
January 19, 2004, 8:06 PM
Adron
[quote author=UserLoser. link=board=17;threadid=4799;start=0#msg40178 date=1074542784]
Assuming your using Visual Basic, here's a simple way (hopefully someone doesn't respond with the high res uptime bs) using GetTickCount:

[/quote]

I'd say your code is bad, because you may get a run-time error running it.
January 19, 2004, 9:18 PM
Kp
[quote author=UserLoser. link=board=17;threadid=4799;start=0#msg40178 date=1074542784]
Assuming your using Visual Basic, here's a simple way (hopefully someone doesn't respond with the high res uptime bs) using GetTickCount:[/quote]

It's unlikely that the high resolution timers are needed here, as there will not be a problem unless your connection is stable for more than 49.7 days (might be less in VB if you don't take into account VB's inability to handle unsigned quantities). Either way, it's pretty rare that you'll be able to hold a BNCS connection long enough for the value to overflow. :)
January 19, 2004, 11:05 PM
R.a.B.B.i.T
[quote author=Kp link=board=17;threadid=4799;start=0#msg40209 date=1074553559]
[quote author=UserLoser. link=board=17;threadid=4799;start=0#msg40178 date=1074542784]
Assuming your using Visual Basic, here's a simple way (hopefully someone doesn't respond with the high res uptime bs) using GetTickCount:[/quote]

It's unlikely that the high resolution timers are needed here, as there will not be a problem unless your connection is stable for more than 49.7 days (might be less in VB if you don't take into account VB's inability to handle unsigned quantities). Either way, it's pretty rare that you'll be able to hold a BNCS connection long enough for the value to overflow. :)
[/quote]

I doubt most users could keep a connection for 49.7 days.
VB also starts going negative after 21 days (IE: -23 days). Simple bug that can be fixed by checking for Time < 0 Then Time * -1. Not hard, but annoying.
January 20, 2004, 12:15 AM
Tuberload
[quote author=Kp link=board=17;threadid=4799;start=0#msg40209 date=1074553559]
[quote author=UserLoser. link=board=17;threadid=4799;start=0#msg40178 date=1074542784]
Assuming your using Visual Basic, here's a simple way (hopefully someone doesn't respond with the high res uptime bs) using GetTickCount:[/quote]

It's unlikely that the high resolution timers are needed here, as there will not be a problem unless your connection is stable for more than 49.7 days (might be less in VB if you don't take into account VB's inability to handle unsigned quantities). Either way, it's pretty rare that you'll be able to hold a BNCS connection long enough for the value to overflow. :)
[/quote]

I will admit I never took that into concideration. You could convert the GetTickCount value into seperate long values (days, hours, minutes, seconds, etc...) and do a little more math to extend the overflow date, but using single variables will always overflow some day. Possibly using an array of integers to represent the time would fix that?
January 20, 2004, 12:31 AM
ChR0NiC
[quote author=Jaquio link=board=17;threadid=4799;start=0#msg40168 date=1074541403]
Uhh, Yea im back for more help because I know I can find it here err... atleast I hope. I was wondering how I would make it tell how long you are connected to bnet for I finally figured out System Uptime after 1 hour -_-, But Connection uptime is bothering me so I came here. I think im going to add everyone who helped me in the special thanks section of the bot. So... If anyone could please help me on how to do this that would be great.
[/quote]

Ok Well I am gonna go straight to the point for you.

[code]

Public Declare Function GetTickCount Lib "kernel32" () As Long

Public ConnectTime As Long

[/code]

These are your Declares.....and Below is when you Declare your ConnectTime

[code]

Private Sub mnuConnect_Click

ConnectTime = GetTickCount

ConnectionStuffDownHere <~ <~ <~

End Sub

[/code]

Then I guess when you are using your uptime......however it is.....I'll just say, let's say you are using a command with a moderation bot

[code]

Dim Command() As String
Command = Split(strText, Chr(32))

Select Case Command(0)

Case "uptime"
Send "System Uptime : " FormatCount(GetTickCount)
Send "Battle.net Uptime : " FormatCount(GetTickCount - ConnectTime)

End Select
[/code]

And the FormatCount is defined below......

[code]
Public Function FormatCount(Count As Long, Optional FormatType As TimeFormatType = 0) As String
Dim Days As Long, Hours As Long, Minutes As Long, Seconds As Long, Miliseconds As Long

Miliseconds = Count Mod 1000
Count = Count \ 1000
Days = Count \ (24& * 3600&)
If Days > 0 Then Count = Count - (24& * 3600& * Days)
Hours = Count \ 3600&
If Hours > 0 Then Count = Count - (3600& * Hours)
Minutes = Count \ 60
Seconds = Count Mod 60
Select Case FormatType
Case 0
FormatCount = Days & " days, " & Hours & " hours, " & _
Minutes & " minutes, " & Seconds & " seconds, " & Miliseconds & _
" milliseconds"
Case 1
FormatCount = Days & " days, " & Hours & " hours, " & _
Minutes & " minutes, " & Seconds & " seconds"
Case 2
FormatCount = Days & ":" & Hours & ":" & _
Minutes & ":" & Seconds & ":" & Miliseconds
Case 3
Dim buffer As String
buffer = Minutes & " minutes"
If Hours >= 1 Then
buffer = Hours & " hours, " & buffer
End If
If Days >= 1 Then
buffer = Days & " days, " & buffer
End If
FormatCount = buffer
End Select
End Function
[/code]

And that should work out for ya........If you need anymore help I'll be glad to help out. And I'm not sure how much you know......but when I do the ConnectTime = GetTickCount that means I am getting the current time and setting it as ConnectTime. Then when I ask for the uptime.....it's Subtracting the current time.....from the time that was declared as ConnectTime....
I hope I'm making sense :-[
January 20, 2004, 12:49 AM
UserLoser.
[quote author=Adron link=board=17;threadid=4799;start=0#msg40198 date=1074547126]
[quote author=UserLoser. link=board=17;threadid=4799;start=0#msg40178 date=1074542784]
Assuming your using Visual Basic, here's a simple way (hopefully someone doesn't respond with the high res uptime bs) using GetTickCount:

[/quote]

I'd say your code is bad, because you may get a run-time error running it.
[/quote]

Explain

Also note my code isn't what I posted
January 20, 2004, 1:10 AM
ChR0NiC
What is it you would like me to explain???
January 20, 2004, 1:11 AM
R.a.B.B.i.T
Those codes work fine.
January 20, 2004, 1:51 AM
Jaquio
Wow, Thank you so much ChR0NiC your code worked others I couldnt get working... maybe it was due my knowledge of vb... but not sure. But thank you again. I have another problem though, In the channels list view when people join channels instead of it going stright down it adds on the the right of it and you can click and drag and rearrange people in the channel anyway I can fix that?
January 20, 2004, 1:54 AM
ChR0NiC
Well.....I am a little confused but......in case you aren't doing the "add" correctly it should look something like this

[code]
frmMain.ChanList.ListItems.Add , , Username, , GetIconCode(message, flags)
[/code]

Make sure you have a List View that is setup with 1 column or 2 if you have lag bars/plugs.
January 22, 2004, 12:11 AM

Search