Valhalla Legends Forums Archive | Battle.net Bot Development | [VB6] Help?

AuthorMessageTime
Pedlar
Ok, I load up Visual Basic 6.0 and i click to add an ActiveX control, when i lock on the RichText one, and click apply a Msg box comes up and says "Object Library not registerd.", what can i do to fix this?
April 22, 2005, 12:05 AM
shout
Try re-installing VB6.
April 22, 2005, 12:41 AM
Quarantine
GAH I forgot how I fixed this. I used to get it a lot.
April 22, 2005, 12:42 AM
Pedlar
I got it fixed, but now i have a new problem with AddChat,  I have rtbChat, and i goto to do Len(rtbChat.Text) and it wont compile that it says Method or data not there
April 22, 2005, 12:55 AM
Quarantine
Make sure you are including the Form prefix if you're in a module or class. (Or other form but not practical)
April 22, 2005, 12:56 AM
KkBlazekK
Make sure when your setting rtbchat to a richtextbox, that richtextbox actually exists.
April 22, 2005, 1:14 AM
Pedlar
Ok, I got abit of the stufff working, now im having trouble connecting to BNET, im using CleanSlateBot2.OCX for it. Heres my code.

[code]

Sub Connect()
    Const f As String = "Main", p As String = "config.ini"
        Close #1
    'Vars
        Dim strUsername As String
    Dim strNewPassword As String, strProduct As String
    Dim strRealmName As String, strRealmChar As String, booRealm As Boolean, booConnecting As Boolean
    Dim strNewPW As String, strIdles As String, strRealms As String, strLODKey As String
    Dim strAutoban As String, strTagban As String, strsafelist As String
    Dim strCDKey As String, strPassword As String, UDP As String
   
    If booConnected = True Then
        Access.Disconnect
    End If
    booConnected = False
    'CONNECTION CODE
    booConnecting = False
    strUsername = ReadINI(f, "Username", p)
    strPassword = ReadINI(f, "Password", p)
    strCDKey = ReadINI(f, "CDKey", p)
    strLODKey = ReadINI(f, "LODKey", p)
    strServer = ReadINI(f, "Server", p)
    strHomeChannel = ReadINI(f, "HomeChan", p)
    strProduct = ReadINI(f, "Product", p)
    strRealmName = ReadINI(f, "Realm", p)
    Trigger = ReadINI(f, "Trigger", p)
    strIdles = ReadINI(f, "Idles", p)
    IdleWait = ReadINI(f, "IdleWait", p)
    IdleMsg = ReadINI(f, "IdleMsg", p)
    strTagban = ReadINI(f, "Tagbans", p)
    strAutoban = ReadINI(f, "Autobans", p)
    strsafelist = ReadINI(f, "Safelist", p)
    strRealms = ReadINI(f, "UseRealm", p)
    UDP = ReadINI(f, "UDP", p)
       
    If strUsername = "" Or strPassword = "" Or strCDKey = "" Or strServer = "" Or strHomeChannel = "" _
    Or strProduct = "" Or Trigger = "" Then
        MsgBox "Configuration file error. Please fix your configuration file using the bot's Setup dialog."
        Exit Sub
    End If
    If strIdles = "Y" Then
        Idles = True
    Else
        Idles = False
    End If
    If strTagban = "Y" Then
        Tagbans = True
    Else
        Tagbans = False
    End If
    If strAutoban = "Y" Then
        Autobans = True
    Else
        Autobans = False
    End If
    If strsafelist = "Y" Then
        Safelist = True
    Else
        Safelist = False
    End If
    If UDP = "Y" Then
        Access.UseUDP = False
    Else
        Access.UseUDP = True
    End If
    If StrComp(strProduct, "PX2D", vbTextCompare) = 0 Or StrComp(strProduct, "VD2D", vbTextCompare) = 0 Then
        Dii = True
    Else
        Dii = False
    End If
    Access.BNLSBotID = ""
    Access.BNLSBotPassword = ""
    Access.CDKey = strCDKey
    Access.Product = strProduct
    If StrComp(strProduct, "PX2D", vbTextCompare) = 0 Then
        Access.LODKey = strLODKey
    End If
    If strRealms = "Y" Then
        Access.Realm = strRealmName
        Access.Character = strRealmChar
        Access.UseRealm = True
    Else
        Access.UseRealm = False
    End If
    strTime = "[" & Time & "] "
    Access.HomeChannel = strHomeChannel
    Access.Password = strPassword
    Access.Username = strUsername
    Access.ChangePassword = False
    Access.Server = strServer
    Access.Accept = 579728
    booConnecting = True
    Access.Connect
error:
    IAm = strCDKey
    SB14 = strPassword
    If booConnecting = True Then
        Exit Sub
    Else
        MsgBox "Configuration file error. Please re-write your configuration file using the Setup dialog.", vbCritical, "Error"
        Exit Sub
    End If
End Sub

'BNLS EVENTS
Private Sub Access_BnetConnected()
    strTime = "[" & Time & "]"
    AddChat vbWhite, strTime & " ", vbGreen, "BNET: Connected!"
End Sub

Private Sub Access_BnetConnecting()
        strTime = "[" & Time & "]"
    AddChat vbWhite, strTime & " ", vbYellow, "BNET: Connecting..."
End Sub

Private Sub Access_BnetDisconnected()
    Access.Disconnect
    booConnected = False
    AddChat vbWhite, strTime & " ", vbRed, "BNET: Disconnected."
    frmChat.Caption = ":: StealthBot v1.39 Test Edition :: Disconnected ::"
    lblCurrentChannel.Caption = ""
    lvChannel.ListItems.Clear
    lbPing.Clear
    lbPing.AddItem " "
    lvChannel.ListItems.Add , , " "
    If Me.WindowState <> vbMinimized Then
    cboSend.SetFocus
    End If
    AddChat vbWhite, strTime & " ", vbRed, "BNET: Attempting to reconnect, please wait..."
    Pause 2, False
strTime = "[" & Time & "]"
        AddChat vbWhite, strTime & " ", vbGreen, "Connection initialized."
    If Me.WindowState <> vbMinimized Then
    cboSend.SetFocus
    End If
    Call Connect
    'timer
    If Idles = True Then
            lngTimerID = KillTimer(0, lngTimerID)
           
    ElseIf Idles = False Then
            Exit Sub
    End If

End Sub

Private Sub Access_BnetError(ErrorNumber As Integer, Description As String)
        strTime = "[" & Time & "]"
    AddChat vbWhite, strTime & " ", vbRed, "BNET:" & ErrorNumber & " -- " & Description
    If ErrorNumber = 10053 Then
        AddChat vbWhite, strTime & " ", vbRed, "BNET: Disconnected."
        AddChat vbWhite, strTime & " ", vbRed, "BNET: Attempting to reconnect..."
        Access.Disconnect
        booConnected = False
        lblCurrentChannel.Caption = ""
        lvChannel.ListItems.Clear
        lbPing.Clear
        lbPing.AddItem " "
        lvChannel.ListItems.Add , , " "
            If Me.WindowState <> vbMinimized Then
            cboSend.SetFocus
            End If
        Pause 1, False
        Call Connect
    ElseIf ErrorNumber = 10061 Then
        AddChat vbWhite, strTime & " ", vbRed, "BNET: Disconnected."
        AddChat vbWhite, strTime & " ", vbRed, "BNET: Attempting to reconnect..."
        Access.Disconnect
        booConnected = False
        lblCurrentChannel.Caption = ""
        lvChannel.ListItems.Clear
        lbPing.Clear
        lbPing.AddItem " "
        lvChannel.ListItems.Add , , " "
            If Me.WindowState <> vbMinimized Then
            cboSend.SetFocus
            End If
        Pause 1, False
        Call Connect
    End If
End Sub

Private Sub Access_BNLSAuthEvent(Success As Boolean)
        strTime = "[" & Time & "]"
    If Success = True Then
    AddChat vbWhite, strTime & " ", vbGreen, "BNLS: Authorized!"
    Else
    AddChat vbWhite, strTime & " ", vbRed, "BNLS: Authorization failed!"
    End If
End Sub

Private Sub Access_BNLSConnected()
        strTime = "[" & Time & "]"
    AddChat vbWhite, strTime & " ", vbGreen, "BNLS: Connected!"
End Sub

Private Sub Access_BNLSConnecting()
        strTime = "[" & Time & "]"
    AddChat vbWhite, strTime & " ", vbYellow, "BNLS: Connecting..."
End Sub

Private Sub Access_BNLSDataError(Message As Byte)
    strTime = "[" & Time & "]"
    If Message = 1 Then
        AddChat vbWhite, strTime & " ", vbRed, "BNLS: Error! Bad CDKey."
    ElseIf Message = 2 Then
        AddChat vbWhite, strTime & " ", vbRed, "BNLS: Error! Bad product version."
    ElseIf Message = 3 Then
        AddChat vbWhite, strTime & " ", vbRed, "BNLS: Error! Bad NLS revision."
    End If
End Sub

Private Sub Access_BNLSDisconnected()
    'empty
End Sub

Private Sub Access_BNLSError(ErrorNumber As Integer, Description As String)
        strTime = "[" & Time & "]"
    AddChat vbWhite, strTime & " ", vbRed, "BNLS: Error " & ErrorNumber & ": " & Description
End Sub
[/code]

All i get is
[code]
[9:49:25 AM] BNLS: Connecting...
[9:49:26 AM] BNLS: Connected!
[9:49:26 AM] BNLS: Authorized!
[9:49:27 AM] BNET: Connecting...
[9:49:33 AM] BNET:10061 -- Connection is forcefully rejected
[9:49:33 AM] BNET: Disconnected.
[9:49:33 AM] BNET: Attempting to reconnect...
[/code]
April 22, 2005, 1:49 PM
KkBlazekK
[quote]
    frmChat.Caption = ":: StealthBot v1.39 Test Edition :: Disconnected ::"
[/quote]
Nope, doesn't look like you learned much.

What server are you connecting to?  Try connecting to another one.
April 22, 2005, 1:56 PM
Pedlar
I was using the old SB code to see how to work it so i could do it myself. And  I got it to connect, but now i get a error "ImageList must be initalized before it can be used." and clicking Debug takes me to line ChanList.ListItems.Add , , Username, , 1
Whats that mean?
April 22, 2005, 3:37 PM
Stealth
My God, you're using that code?! It's terrible!!

I highly recommend learning Visual Basic and rewriting it yourself using better conventions. I've rewritten every single line of what you see there since that code was produced.
April 22, 2005, 3:53 PM
Pedlar
I jus needed something to connect to BNET for an Ops bot, and wanted to make my own Commands for it
April 22, 2005, 4:15 PM
KkBlazekK
[quote author=Pedlar link=topic=11344.msg109415#msg109415 date=1114184251]
I was using the old SB code to see how to work it so i could do it myself. And I got it to connect, but now i get a error "ImageList must be initalized before it can be used." and clicking Debug takes me to line ChanList.ListItems.Add , , Username, , 1
Whats that mean?
[/quote]
When a vb project fails to load a control it usually makes that object a picturebox. Try replacing that with the proper control.
April 22, 2005, 4:18 PM
Pedlar
Its a ListBox object
April 22, 2005, 4:20 PM
Quarantine
Haha, I thought that code was leaked :p. Try setting the image list to point to the one in your list view
April 22, 2005, 5:23 PM
HdxBmx27
Removed, Question got answered.

Now to answer the man's problem:
You need to assighn a ImageList to the ListView, As follows:

Right click and select properties (making sure you ahve a ImageList on the form already):
[img]http://hdx.no-ip.org/imgs/imglst1.GIF[/img]

Then select the Image Lists tab and set the property to the image list you want:
[img]http://hdx.no-ip.org/imgs/imglst2.GIF[/img]
~-~(HDX)~-~
April 23, 2005, 5:41 AM
Pedlar
I got another quick question.  How would i go abou retrieveing a string from a URL and puting it through AddChat?  I was thinking do Open("http://URL/news.txt") and parsing it that way. But it didnt quite work :(
April 23, 2005, 4:05 PM
Yegg
I don't use VB6 all that often (I use Python), but doesn't VB6 have a way to read the text stored in a text document from the internet? I think you might be able to use Inet for this task. I can't really go into detail on that for you though.
April 23, 2005, 7:27 PM
HdxBmx27
Yes, Simply using an Inet control will allow you to access any publically web-based text doccument.
[code]Dim FileData as string
FileData = Inet1.OpenURL("Http://URL/File.txt")[/code]
~-~(HDX)~-~
April 23, 2005, 10:39 PM
Archangel
[quote author=HdxBmx27 link=topic=11371.msg109630#msg109630 date=1114295980]
Yes, Simply using an Inet control will allow you to access any publically web-based text doccument.
[code]Dim FileData as string
FileData = Inet1.OpenURL("Http://URL/File.txt")[/code]
~-~(HDX)~-~
[/quote]

You can also split the data by character 10 (Chr(10)),
and then add it to chat.
April 23, 2005, 11:14 PM
Pedlar
What obj is Inet?
April 23, 2005, 11:44 PM
Pedlar
Ok, I found the dll with Inet :D, But now i have a not so easy question, How would i  do the Url so in the txt file i can have [code]AddChat "Blah"[/code] and when i load the file have it do whats in the file? so i could do say [code]Inet1.openURL("http://LovelyUrl/News.txt")[/code] then it call the functions inside the file?

Edit: I can elaborate abit more if this question confuses someone.
April 23, 2005, 11:59 PM
HdxBmx27
Umm, Elaborate please You need to simply put the results of OpenURL() into a vareable, Like ArchAngel you can split it by Chr(&HA) witch would return all the line breaks.

Are you refering to VB code in the file, if so then youll have to look into the Scripting object control. If your jsut making a file where you can have news, simply so the AddChat with the data you get, Even make some special charecters for yourself to tell you how it should be displayed (bold, italic, underline, red, blue, clear, etc....)
~-~(HDX)~-~
April 24, 2005, 12:04 AM
Pedlar
yea what im asking is basicly a Remote VBScript
April 24, 2005, 12:06 AM
Pedlar
Edit: I ask for help to be pushed in the right direction, Ive never realy used VB before. Im more C, So dont think im jus building my bot off of what you all are telling me.

With help from HDX i was able to get what i needed, but now when i do ScriptSupportClass.AddChat vbCyan, "Hi" it shows it in black instead of Cyan, this is what i have for AddChat inside of the script suport class
Edit: Changed the AddChat
[code]
Public Sub AddChat(ParamArray saElements() As Variant)
    Dim i As Integer
    For i = LBound(saElements) To UBound(saElements) Step 2
        With frmChat.rtbChat
        .SelStart = Len(.text)
        .SelLength = 0
        .SelColor = saElements(i)
        .SelText = saElements(i + 1) & Left$(vbCrLf, -2 * CLng((i + 1) = UBound(saElements)))
        .SelStart = Len(.text)
        End With
    Next i
End Sub
[/code]
and in form_load i have
[code]
    Dim NewsData As String
    Set ScriptSupportClass = New ScriptSupportClass
    NewsData = Inet1.OpenURL("Http://Url/canews.txt")
    caScript.AddCode (NewsData)
    caScript.Run ("News")
[/code]
and last but not least in canews.txt i have
[code]
Public Sub News()
ScriptSupportClass.AddChat vbWhite, "[" & Time & "] ", vbcyan , "Hi"
End Sub
[/code]
April 24, 2005, 3:51 AM
QwertyMonster
Perhaps this could help you? Look at it and compare and see what your doing wrong.
[code]

Public Function Display(ByVal TextObject As RichTextBox, ByVal NewLine As Boolean, ByVal TimeStamp As Boolean, ByVal TextColor As Long, ByVal Text As String)

    TextObject.SelStart = Len(TextObject.Text)
       
    If NewLine = True And TextObject.Text <> "" Then TextObject.SelText = TextObject.SelText & vbCrLf
       
    If TimeStamp = True Then
       
        TextObject.SelColor = &H8000000F
        TextObject.SelText = TextObject.SelText & "[" & Time & "] "
           
    End If
       
    TextObject.SelColor = TextColor
    TextObject.SelText = TextObject.SelText & Text
    TextObject.SelStart = Len(TextObject.Text)
   
End Function
[/code]

Edit: Forgot to say how its used. Its used like this.

[code]
Display MyRTB, true, true, vbGreen, "Wee"

1st true = NewLine.
2nd true = Timestamp.
[/code]
Put both to false if want  to stay on same line, with no timestamp but change colour writing.

Hope this helps!
April 24, 2005, 11:02 AM
Pedlar
When i pass stuff through the script support class it removes there color...i can do AddChat Blah, and have color and do ScriptSupportClass..AddChat blah and it jus turned it black.
April 24, 2005, 2:17 PM
R.a.B.B.i.T
You really should use a socket, not INet, because INet sucks and often errors itself to death.
April 24, 2005, 7:28 PM
Archangel
TIPS:

- Connect socket!
- On Connect:
[code]
Winsock1.SendData "GET http://yoursite/news.txt HTTP/1.0" & vbCrLf & _
                  "Connection: Keep-Alive" & vbCrLf & _
                  "Accept: */*" & vbCrLf & _
                  "Accept-Language: en" & vbCrLf & vbCrLf
[/code]
- Data Arrives, and you parse data.
April 24, 2005, 9:02 PM
Pedlar
im not having a problem retriveing the info or even having the script work, the only thing thats wrong is that the AddChat in the ScriptSupportClass wont call color, but its identicle to the AddChat in frmChat whcih does show color. So any help with why puting something through the scriptsupportclass wonr show color is well apreciated.

[Edit]: Spelling.
April 24, 2005, 9:49 PM
R.a.B.B.i.T
[quote author=Archangel link=topic=11371.msg109750#msg109750 date=1114376561]
TIPS:

- Connect socket!
- On Connect:
[code]
Winsock1.SendData "GET http://yoursite/news.txt HTTP/1.0" & vbCrLf & _
                  "Connection: Keep-Alive" & vbCrLf & _
                  "Accept: */*" & vbCrLf & _
                  "Accept-Language: en" & vbCrLf & vbCrLf
[/code]
- Data Arrives, and you parse data.
[/quote]That won't work :'(
[code]
        Sock.SendData "GET /news.txt HTTP/1.1" & vbCrLf & _
                  "Host: www.site.com" & vbCrLf & _
                  "Accept: */*" & vbCrLf & _
                  "Accept-language: en" & vbrclf & vbCrLf[/code]
April 25, 2005, 1:23 AM
Archangel
Did you connected the socker to the server ip?
April 25, 2005, 1:41 AM

Search