• Welcome to Valhalla Legends Archive.
 

[VB6]Bot wont join channels & nothin shows up on sceen.

Started by Learn, May 03, 2004, 03:11 PM

Previous topic - Next topic

Learn

Ok is this fine? :

Dim ChannelVariableNameHere As String
sckBNET.SendData "/join " & ChannelVariableNameHere & vbCrLf
DoEvents

Eli_1

No. The channelname string needs to contain some channel name. That right there would send:
"/join " & vbCrLf.
Before you send it you need to set ChannelVariableNameHere to something.


ChannelVariableNameHere = "Public Chat Drop"

Learn

Oh yea, forgot that.

Dim Channel As String
Channel = Public_Chat_John
sckBNET.SendData "/join " & Channel & vbCrLf
DoEvents


Is that ok?

Eli_1

No man. Public_Chat_John is undefined. You need to use quotes. Use "Public Chat Drop".

Learn

Ok, sorry if I'm annoying you, but where does the Dim ChannelNameVariable as String blah blah blah go?

And i keep getting "Next without for" error with this codPrivate Sub txtSend_KeyPress(KeyAscii As Integer)
   If KeyAscii = 13 Then
       KeyAscii = 0 'No Beep
       sckBNET.SendData txtSend.Text & vbCrLf
       txtSend.Text = ""

Const VK_RETURN = 13
   If KeyAscii = VK_RETURN Then
       Winsock.SendData txtSend.Text & vbCrLf
       '/* Notice I'm putting vbCrLf on the end of the text :O */
       DoEvents
       '/* DoEvents isn't needed. I use it
       '** because on one of my really old
       '** computers it won't send if I leave DoEvents
       '** out. Btw, these are all comments, learn. */
       End If
   Next i
End Sub

Eli_1

Quote from: Learn on May 04, 2004, 04:53 PM
Ok, sorry if I'm annoying you, but where does the Dim ChannelNameVariable as String blah blah blah go?

And i keep getting "Next without for" error with this codPrivate Sub txtSend_KeyPress(KeyAscii As Integer)
   If KeyAscii = 13 Then
       KeyAscii = 0 'No Beep
       sckBNET.SendData txtSend.Text & vbCrLf
       txtSend.Text = ""

Const VK_RETURN = 13
   If KeyAscii = VK_RETURN Then
       Winsock.SendData txtSend.Text & vbCrLf
       '/* Notice I'm putting vbCrLf on the end of the text :O */
       DoEvents
       '/* DoEvents isn't needed. I use it
       '** because on one of my really old
       '** computers it won't send if I leave DoEvents
       '** out. Btw, these are all comments, learn. */
       End If
   Next i
End Sub


1.) You have code that does the same thing twice.
2.) You have Next i, when there is no For loop starting it (delete Next i).
3.) You're missing an End If.
delete:

If KeyAscii = 13 Then
       KeyAscii = 0 'No Beep
       sckBNET.SendData txtSend.Text & vbCrLf
       txtSend.Text = ""


You put the join channel code anywhere you want. I would put it in the sckBNET_Connect() event so that your bot joins a "home" channel when it logs on.

Learn

DAMMIT!!!!!!!! SO CONFUSED

Private Sub mnuFileConnect_Click()
       sckBNET.Connect "useast.battle.net", 6112
       AddChat vbYellow, "Connecting..."
   Next i
       Dim Channel As String
           Channel = "Public Chat John"
           sckBNET.SendData "/join " & Channel & vbCrLf
           DoEvents
End Sub


"Next without for" error

Jesus christ, could you explain to me where/when i put "End If" and "Next i"

Eli_1

You only need an End If if you have an if statement.
Example:

If Username = "asdfasdf" Then
'do stuff
End if


You only need a Next i if you have a for loop that uses the variable i.
Example:

Dim i as integer
for i = 1 to 10
msgbox "MerF?!", vbOKOnly, "NerFFF?!"
next i


And you can't join a channel untill you log in. There should be a function called sckBNET_Connect(). That function is called when the socket connects to the server. Similar to how sckBNET_Close() and sckBNET_Error() will be called when you are disconnected.

In sckBNET_Connect() you would put your log in code and the join channel code.
Example:

Private Sub sckBNET_Connect()
   With sckBNET
       .SendData Chr(3) & Chr(4) & "John" & vbCrLf
       '/* This will send the protocol byte 0x03 (CHAT)
       '** It will also send 0x04 with it.
       '** This will disable echo, so the server doesn't
       '** echo back what you send it (for telnet). */

       .SendData "ub3rleet" & vbCrLf
       '/* This will send your password to the server.
       '** which in this example is 'ub3rleet'. */

       Dim HomeChannel as String '// Your home channel
       HomeChannel = "Public Chat Drop" '// Set home channel

       .SendData "/join " & HomeChannel & vbCrLf
       '/* This will send the join command with
       '** with the parameter 'Public Chat Drop' to
       '** the server. You could accomplish the same
       '** thing by simply doing:
       '**
       '** .SendData "/join Public Chat Drop" & vbCrLf
       '*/

   End With
   '/* We need an End With because we used With at the
   '** top. Similar to how we need End Sub, because we
   '** have 'Private Sub ..." at the top. */

End Sub


All the comments might make it look intimidating to you, so I'll take them out so you can see what it looks like w/o them. At least read through them though, because they explain why the code works.

Exact same code without comments:

Private Sub sckBNET_Connect()
   With sckBNET
       .SendData Chr(3) & Chr(4) & "John" & vbCrLf
       .SendData "ub3rleet" & vbCrLf

       Dim HomeChannel as String
       HomeChannel = "Public Chat Drop"
       .SendData "/join " & HomeChannel & vbCrLf
   End With
End Sub

Stealth

Quote from: Learn on May 04, 2004, 04:53 PM
Ok, sorry if I'm annoying you, but where does the Dim ChannelNameVariable as String blah blah blah go?

And i keep getting "Next without for" error with this codPrivate Sub txtSend_KeyPress(KeyAscii As Integer)
   If KeyAscii = 13 Then
       KeyAscii = 0 'No Beep
       sckBNET.SendData txtSend.Text & vbCrLf
       txtSend.Text = ""

Const VK_RETURN = 13
   If KeyAscii = VK_RETURN Then
       Winsock.SendData txtSend.Text & vbCrLf
       '/* Notice I'm putting vbCrLf on the end of the text :O */
       DoEvents
       '/* DoEvents isn't needed. I use it
       '** because on one of my really old
       '** computers it won't send if I leave DoEvents
       '** out. Btw, these are all comments, learn. */
       End If
   Next i
End Sub


I would strongly suggest learning more about VB and how it works before you continue any further. Get a book or visit a few online tutorials.
- Stealth
Author of StealthBot

Learn

Hi, Stealth you make ownage bots.. wanna help me? =]] and Stealth do you know VB? Was Stealthbot programmed with VB? And if you do know VB how did you learn? Trial and Error? Book? Teacher? And do you suggest a book that you know is good?

But Eli_1 i already have a connect command, isnt there i way to join a home channel afer connecting with my mnuFile_Connect thing?

Eli_1

sckBNET_Connect() is not a connect command, god damnit. It is an event winsock calls when it is connected to the server. If you try sending data before your connected, you'll get pretty errors.

I'm trying to be as helpful as I possibly can. But now I'm starting to think you never read anything I took the time to type for you, because if you did, you'd know you can't. And you'd also know before trying to join a channel you need to send the protocol byte for CHAT(3) and then log in.

Anyway, I'm done. Good luck to you.

Dyndrilliac

Quote from: Learn on May 04, 2004, 05:43 PM
Hi, Stealth you make ownage bots.. wanna help me? =]] and Stealth do you know VB? Was Stealthbot programmed with VB? And if you do know VB how did you learn? Trial and Error? Book? Teacher? And do you suggest a book that you know is good?

But Eli_1 i already have a connect command, isnt there i way to join a home channel afer connecting with my mnuFile_Connect thing?

Yes it was and yes he does.

I also suggest you learn the language before writing a bot. Your skipping learning your ABC's to being an english professor at Harvard.
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

Learn

Thanks for all your help Eli_1.

Nice metaphor Dyndrilliac. How do you suggest learning the language? Do you know any good sites? A title to a good book, perhaps? If so any info would be much appreciated.

Also, I've searched for tutorials online, none of the free ones are good, that I've found.

Stealth

Quote from: Learn on May 04, 2004, 05:43 PM
Hi, Stealth you make ownage bots.. wanna help me? =]] and Stealth do you know VB? Was Stealthbot programmed with VB? And if you do know VB how did you learn? Trial and Error? Book? Teacher? And do you suggest a book that you know is good?

But Eli_1 i already have a connect command, isnt there i way to join a home channel afer connecting with my mnuFile_Connect thing?

I took a class last year in school that taught VB. It was based on a book, exactly which one I forget. Grok has posted a link to Bruce McKinney's Hardcore Visual Basic, which looks like a very good source of information. Search the forums Bruce McKinney and see what you find.
- Stealth
Author of StealthBot

Eli_1

I also took Introduction to Programming in 9th grade. The book we used was:

Visual Basic 6 How to Program
Deitel & Deitel T.R. Nieto
www.deitel.com

|