Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: dodge on April 19, 2004, 02:28 PM

Title: Newb Question
Post by: dodge on April 19, 2004, 02:28 PM
I'm reading all of this information about packets, I was wondeirng if anyone knew of a good site that was like a tutorial for packets... as you can tell I'm new to this, but I would like to learn.
Title: Re:Newb Question
Post by: Tuberload on April 19, 2004, 02:31 PM
Quote from: dodge on April 19, 2004, 02:28 PM
I'm reading all of this information about packets, I was wondeirng if anyone knew of a good site that was like a tutorial for packets... as you can tell I'm new to this, but I would like to learn.

All it is binary data. Bytes, Words, Dwords, Strings, etc... Words and Dwords are stored in little-endian format. Bytes are 8-bit integers, Words are 16-bit integers, Dwords are 32 bit-integers. Be careful when using languages that use signed integers, i.e. Java. Lookup that information and you should have what you need.
Title: Re:Newb Question
Post by: dodge on April 19, 2004, 02:32 PM
Thanks for the help  :P if anyone can give me a site, I'd still appreicate that heh I'll start looking up information, and I'm programming in VB just fyi.
Title: Re:Newb Question
Post by: FuzZ on April 19, 2004, 02:47 PM
http://www.google.com < best site on the net for everything you can think of :P
Title: Re:Newb Question
Post by: RedPhoenix on April 19, 2004, 03:13 PM

Here ---> http://grc.com/oo/packetsniff.htm

;D  ;D  ;D
Title: Re:Newb Question
Post by: dodge on April 19, 2004, 03:43 PM
LOL! Google is awesome, and I found a site, but I'm also looking at RedPhoenix's site he gave me. Looks fun lol. I think once I get money I'm going to buy a book. I was working on this fun program.. but I need to find out how to enter a line in a Rich Text Box... I'm writng somethign to the screen and I need like a return or something... Currently searching google  :P ;D ;)

EDIT:

I have this thing where you have a textbox, and you press send and you add text to the RTB, I have it so you can continuiously add text to it but its on the same line... this is my code


rtbChat.Text = rtbChat.Text + "Client: " & txtSend.Text


No, it's not for my bot but hey maybe someones like "hey this is easy!" when reading my bot problem lol
Title: Re:Newb Question
Post by: Dyndrilliac on April 19, 2004, 04:04 PM
To add text to an RTB without a fancy addchat function, do:

rtbName.Text = rtbName.Text & "Text Here!" & vbCrLf & "You're on a new line!" & vbCrLf

This will add "Text Here!", then on a seperate line, add "You're on a new line!", then create a new blank line for more additions.

Most of us here use an addchat function written br Grok. Here is the variation I use:

Public Sub AddC(RTB As RichTextBox, ParamArray saElements() As Variant)
   On Error Resume Next
   Dim RTBName As String
       With RTB
           RTBName = .Name
       End With
   Dim i As Integer
       With RTB
           .SelStart = 99999999
           .SelLength = 0
           .SelColor = vbWhite
           .SelText = "[" & Format(Now, "HH:MM:SS AMPM") & "] "
           .SelStart = 99999999
       End With
   For i = LBound(saElements) To UBound(saElements) Step 2
       With RTB
           .SelStart = 99999999
           .SelLength = 0
           .SelColor = saElements(i)
           .SelText = saElements(i + 1) & Left$(vbCrLf, -2 * CLng((i + 1) = UBound(saElements)))
           .SelStart = 99999999
       End With
   Next i
       With RTB
       If Len(.Text) >= 10000 Then
           .SelStart = 0
           .SelLength = 10000
           .SelText = ""
           .SelLength = 10000
           .SelStart = Len(.Text)
       End If
       If Len(.Text) >= 5000 Then
           .SelStart = 0
           .SelLength = 2500
           .SelText = ""
           .SelLength = 5000
           .SelStart = Len(.Text)
       End If
       .Refresh
   End With
End Sub


And you use it by doing:

AddC FormName.rtbName, Color, Text
or
AddC Me.Chat, vbGreen, "Text! Wheeee!"

Edit: Hah! Beat you to it FuzZ :)
Title: Re:Newb Question
Post by: FuzZ on April 19, 2004, 04:05 PM
There's a couple public functions for RTB's

AddChat being the most popular
http://botdev.valhallalegends.com/documents/vbrtbpro.html

I use a modified version of that

Public Sub AddChat(rtb As RichTextBox, ParamArray saElements() As Variant)
   Dim I As Integer
   With rtb
       If Len(.text) >= 10000 And AppData.AutoClear = True Then
           .text = ""
           .SelStart = 0
           .SelLength = 0
           .SelColor = vbGreen
           .SelText = "Auto cleared window." & vbCrLf
           .SelStart = Len(.text)
       ElseIf Len(.text) >= 10000 Then
           .SelStart = 0
           .SelLength = InStr(1, .text, vbCrLf) + 1
           .SelText = ""
           .SelStart = Len(.text)
       End If
       If BNet.TimeStamp = True Then
           .SelStart = Len(.text)
           .SelLength = 0
           .SelColor = vbWhite
           .SelText = TimeStamp & " "
           .SelStart = Len(.text)
       End If
       For I = LBound(saElements) To UBound(saElements) Step 2
               .SelStart = Len(.text)
               .SelLength = 0
               .SelColor = saElements(I)
               .SelText = saElements(I + 1) & Left$(vbCrLf, -2 * CLng((I + 1) = UBound(saElements)))
               .SelStart = Len(.text)
       Next I
       .SelStart = Len(.text)
   End With
End Sub
Title: Re:Newb Question
Post by: Fire on April 24, 2004, 03:45 PM
Using a statement that ignores errors is a novice approach to programming.  I recommend handling the error, if it ever manifests.   Run-time errors could, and usually do lead to malformed data and/or execution.  I reliase that this method simply adds formatted text to visual basic components, nevertheless handling errors is the best approach to good programming practices.
Title: Re:Newb Question
Post by: iago on April 24, 2004, 03:50 PM
Quote from: Fire on April 24, 2004, 03:45 PM
Using a statement that ignores errors is a novice approach to programming.  I recommend handling the error, if it ever manifests.   Run-time errors could, and usually do lead to malformed data and/or execution.  I reliase that this method simply adds formatted text to visual basic components, nevertheless handling errors is the best approach to good programming practices.

Hmm, post #1 for this guy and it's something sensible.  Does he get a prize?

<edit> no, that wasn't sarcasm, but I also couldn't afford the prize.
Title: Re:Newb Question
Post by: Dyndrilliac on April 24, 2004, 04:09 PM
The on error resume next in mine is a left over statement i was using to isolate and fix an error, you can handle the error if you like but i already fixed the one that caused that statement to be put into that procedure to begin with(in my bot anyway).
Title: Re:Newb Question
Post by: Stealth on April 24, 2004, 08:39 PM
Quote from: dodge on April 19, 2004, 03:43 PM

rtbChat.Text = rtbChat.Text + "Client: " & txtSend.Text


Also, you might want to note that + is a numeric operator. While it works in VB with strings (I think this is a throwback to older versions of VB, or a helper for programmers in other languages) it's better form to use the & string concatenation operator.
Title: Re:Newb Question
Post by: BinaryzL on April 24, 2004, 11:28 PM
Quote from: Stealth on April 24, 2004, 08:39 PM
Quote from: dodge on April 19, 2004, 03:43 PM

rtbChat.Text = rtbChat.Text + "Client: " & txtSend.Text


Also, you might want to note that + is a numeric operator. While it works in VB with strings (I think this is a throwback to older versions of VB, or a helper for programmers in other languages) it's better form to use the & string concatenation operator.

Yes, Stealth I think is correct and plus why are you using both + and & like right after one another lol.
Title: Re:Newb Question
Post by: dodge on April 28, 2004, 11:48 AM
Ehh good question, not sure. But this wasnt for my bot although i appreicate the addc code when i get back to my bot. I was making a IP chat thing.. not sure why i used a "+" then "&" but hey... not sure I think I might go back to the bot it was mroe fun.
Title: Re:Newb Question
Post by: MyndFyre on April 28, 2004, 11:53 AM
Quote from: iago on April 24, 2004, 03:50 PM
Quote from: Fire on April 24, 2004, 03:45 PM
Using a statement that ignores errors is a novice approach to programming.  I recommend handling the error, if it ever manifests.   Run-time errors could, and usually do lead to malformed data and/or execution.  I reliase that this method simply adds formatted text to visual basic components, nevertheless handling errors is the best approach to good programming practices.

Hmm, post #1 for this guy and it's something sensible.  Does he get a prize?

<edit> no, that wasn't sarcasm, but I also couldn't afford the prize.

Seriously!  I about urinated my shorts when I saw that.

+1 to karma -- oh yeah, it's gone.  :(
Title: Re:Newb Question
Post by: iago on April 28, 2004, 12:42 PM
Quote from: Myndfyre on April 28, 2004, 11:53 AM
Quote from: iago on April 24, 2004, 03:50 PM
Quote from: Fire on April 24, 2004, 03:45 PM
Using a statement that ignores errors is a novice approach to programming.  I recommend handling the error, if it ever manifests.   Run-time errors could, and usually do lead to malformed data and/or execution.  I reliase that this method simply adds formatted text to visual basic components, nevertheless handling errors is the best approach to good programming practices.

Hmm, post #1 for this guy and it's something sensible.  Does he get a prize?

<edit> no, that wasn't sarcasm, but I also couldn't afford the prize.

Seriously!  I about urinated
my shorts when I saw that.

+1 to karma -- oh yeah, it's gone.  :(

Damnit, I was going for complete soakage.  ohwell :/