• Welcome to Valhalla Legends Archive.
 

Newb Question

Started by dodge, April 19, 2004, 02:28 PM

Previous topic - Next topic

dodge

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.

Tuberload

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.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

dodge

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.

FuzZ

http://www.google.com < best site on the net for everything you can think of :P


dodge

#5
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

Dyndrilliac

#6
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 :)
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.

FuzZ

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

Fire

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.

iago

#9
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.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Dyndrilliac

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).
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.

Stealth

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.
- Stealth
Author of StealthBot

BinaryzL

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.

dodge

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.

MyndFyre

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.  :(
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.