Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: phvckmeh on August 01, 2004, 04:22 AM

Title: Converting 1B to 27... how??? (solved)
Post by: phvckmeh on August 01, 2004, 04:22 AM
ok this may seem stupid, but im receving 0x7d and im parsing the number of users in the clan, it says the number of users is 1B which i know converts to 27, although i just dont know how to convert it... thanks...

Edit: Please don't remove your topic title
Title: Re:Converting 1B to 27... how???
Post by: Banana fanna fo fanna on August 01, 2004, 08:22 AM
11 * 16 ^ 0 + 1 * 16 ^ 1

A = 10
B = 11
C = 12
D = 13
E = 14
F = 15
Title: Re:Converting 1B to 27... how???
Post by: TheMinistered on August 01, 2004, 10:09 AM
That equation seems to me to be a bit redundant... could simplify it a bit:  11 * 16 ^ 0 + 16
Title: Re:Converting 1B to 27... how???
Post by: CrAz3D on August 01, 2004, 10:11 AM
Why not just put 16?
Title: Re:Converting 1B to 27... how???
Post by: Banana fanna fo fanna on August 01, 2004, 10:25 AM
Because you compute it like this...


value = 0;
for each digit in the number, right to left {
value += digitvalue * 16 ^ (num_digits - digit_position)
}
Title: Re:Converting 1B to 27... how???
Post by: Eli_1 on August 01, 2004, 11:56 AM
I must of been doing it the hard way all this time.  :-\


                               1B
                               /   \
                            0001   1011
                               \   /
                               11011
                                 |
             (2^4) + (2^3) + (2^1) + (2^0)
                                 |
                               
                                 27
                               
Title: Re:Converting 1B to 27... how???
Post by: phvckmeh on August 01, 2004, 12:08 PM
anyone able to put this in a function? like

public sub convertbyte(data as string)

whatever...

end funtion
Title: Re:Converting 1B to 27... how???
Post by: Eli_1 on August 01, 2004, 12:10 PM
Quote from: phvckmeh on August 01, 2004, 12:08 PM
anyone able to put this in a function? like

public sub convertbyte(data as string)

whatever...

end funtion

Storm gave you psuedo-code.

Edit:
You do realize there's a Val() function right?

Val(&HB1)

Title: Re:Converting 1B to 27... how???
Post by: K on August 01, 2004, 12:23 PM
and you do realize that you can compare a hexadecimal value to a base10 value?


For I = 1 To &HB1
  // parse data or whatever :P
End For


Hope I got the syntax right.
Title: Re:Converting 1B to 27... how???
Post by: ChR0NiC on August 01, 2004, 01:09 PM
Quote from: Eli_1 on August 01, 2004, 12:10 PM
Quote from: phvckmeh on August 01, 2004, 12:08 PM
anyone able to put this in a function? like

public sub convertbyte(data as string)

whatever...

end funtion

Storm gave you psuedo-code.

Edit:
You do realize there's a Val() function right?

Val(&HB1)




keep in mind he just switched over from CleanSlateBot to regular packet parsing. Which is funny that he claims he is parsing 0x7D yet he can't figure out how to use the "Asc" or "Val" statement. I guess we know how he is getting his code :-\
Title: Re:Converting 1B to 27... how???
Post by: phvckmeh on August 01, 2004, 01:36 PM
Quote from: ChR0NiC on August 01, 2004, 01:09 PM
Quote from: Eli_1 on August 01, 2004, 12:10 PM
Quote from: phvckmeh on August 01, 2004, 12:08 PM
anyone able to put this in a function? like

public sub convertbyte(data as string)

whatever...

end funtion

Storm gave you psuedo-code.

Edit:
You do realize there's a Val() function right?

Val(&HB1)




keep in mind he just switched over from CleanSlateBot to regular packet parsing. Which is funny that he claims he is parsing 0x7D yet he can't figure out how to use the "Asc" or "Val" statement. I guess we know how he is getting his code :-\

yes, i am writing it.


If "0x0" & Hex(PacketId) = "0x075" Then
           Dim temp As String
           Dim rank As String
           temp = Right(StrToHex(data), 14)
               Select Case Right(temp, 2)
                   Case "00": rank = "Peon, for less than one week"
                   Case "01": rank = "Peon, for over one week"
                   Case "02": rank = "Grunt"
                   Case "03": rank = "Shaman"
                   Case "04": rank = "Chieftain"
               End Select
               AddChat "You are a " & rank & " in Clan " & ReverseString(HexToStr(Left(temp, 11))), vbYellow
               Exit Sub
           End If
           
           If "0x0" & Hex(PacketId) = "0x077" Then
               Dim reason As String
               Select Case Right(StrToHex(data), 2)
                   Case "00": reason = "Invitation accepted"
                   Case "04": reason = "Invitation declined"
                   Case "05": reason = "Cannot contact(not in channel screen) or already in clan"
                   Case "07": reason = "No privilege to invitation"
                   Case "08": reason = "Cannot invitation"
                   Case "09": reason = "Clan is full"
               End Select
               AddChat "Response to clan invite: " & reason, &H80FF&
               Exit Sub


this is all i got on parsing the members in clan, maybe im doin it wrong. I understand parsing the offline state or username, just  this one throws me.

If "0x0" & Hex(PacketId) = "0x07D" Then
           Dim temp
           temp = Split(StrToHex(data))
           AddChat StrToHex(temp(9)), vbgreen

Title: Re:Converting 1B to 27... how???
Post by: phvckmeh on August 01, 2004, 01:58 PM
well i got it working...


but.....

lol look at this code..  :'(

Public Function MemberCount(data As String)
If Len(data) = 2 Then
Dim i As Integer
Dim x As Integer
x = Left(data, 1) * 16

Select Case UCase(Right(data, 1))
   Case "A": i = 1
   Case "B": i = 2
   Case "C": i = 3
   Case "D": i = 4
   Case "E": i = 5
   Case "F": i = 6
   Case "G": i = 7
   Case "H": i = 8
   Case "I": i = 9
   Case "J": i = 10
   Case "K": i = 11
   Case "L": i = 12
   Case "M": i = 13
   Case "N": i = 14
   Case "O": i = 15
   Case "P": i = 16
   Case "Q": i = 17
   Case "R": i = 18
   Case "S": i = 19
   Case "T": i = 20
   Case "U": i = 21
   Case "V": i = 22
   Case "W": i = 23
   Case "X": i = 24
   Case "Y": i = 25
   Case "Z": i = 26
   Case "1": i = 1
   Case "2": i = 2
   Case "3": i = 3
   Case "4": i = 4
   Case "5": i = 5
   Case "6": i = 6
   Case "7": i = 7
   Case "8": i = 8
   Case "9": i = 9
End Select

MemberCount = x + i

End If
End Function

Title: Re:Converting 1B to 27... how???
Post by: ChR0NiC on August 01, 2004, 02:08 PM
All you need to do to get the number of members is


Asc(Mid(Data, 9, 1))


Because it's located after the [DWORD]Cookie. You don't need to write some waste of memory function......
Title: Re:Converting 1B to 27... how???
Post by: Negotiable on August 01, 2004, 02:44 PM
System.out.println(Integer.parseInt(num, 16));
Title: Re:Converting 1B to 27... how???
Post by: phvckmeh on August 01, 2004, 02:45 PM
Thats what i needed, thanks!
Title: Re:Converting 1B to 27... how???
Post by: ChR0NiC on August 01, 2004, 03:17 PM
Quote from: phvckmeh on August 01, 2004, 02:45 PM
Thats what i needed, thanks!

Were you referring to my code or the other guy's code.
Title: Re:Converting 1B to 27... how???
Post by: phvckmeh on August 01, 2004, 04:25 PM
Quote from: ChR0NiC on August 01, 2004, 02:08 PM
All you need to do to get the number of members is


Asc(Mid(Data, 9, 1))


Because it's located after the [DWORD]Cookie. You don't need to write some waste of memory function......

this one!
Title: Re:Converting 1B to 27... how??? (solved)
Post by: Blaze on August 11, 2004, 11:56 PM
Trust gave me this...


Function HexToDec(HexStr As String) As Long
Dim strlen As Integer
Dim Ctr As Integer
Dim Word As String * 1
Dim lngTemp As Long

   strlen = Len(HexStr)
   
   HexStr = UCase(HexStr)
   
   For Ctr = strlen To 1 Step -1
       
       Word = Left$(HexStr, 1)
       
       HexStr = Mid(HexStr, 2, Len(HexStr) - 1)
       
       Select Case Word
           
           Case "0"
               lngTemp = lngTemp
           Case "1"
               lngTemp = (16 ^ (Ctr - 1)) * 1 + lngTemp
           Case "2"
               lngTemp = (16 ^ (Ctr - 1)) * 2 + lngTemp
           Case "3"
               lngTemp = (16 ^ (Ctr - 1)) * 3 + lngTemp
           Case "4"
               lngTemp = (16 ^ (Ctr - 1)) * 4 + lngTemp
           Case "5"
               lngTemp = (16 ^ (Ctr - 1)) * 5 + lngTemp
           Case "6"
               lngTemp = (16 ^ (Ctr - 1)) * 6 + lngTemp
           Case "7"
               lngTemp = (16 ^ (Ctr - 1)) * 7 + lngTemp
           Case "8"
               lngTemp = (16 ^ (Ctr - 1)) * 8 + lngTemp
           Case "9"
               lngTemp = (16 ^ (Ctr - 1)) * 9 + lngTemp
           Case "A"
               lngTemp = (16 ^ (Ctr - 1)) * 10 + lngTemp
           Case "B"
               lngTemp = (16 ^ (Ctr - 1)) * 11 + lngTemp
           Case "C"
               lngTemp = (16 ^ (Ctr - 1)) * 12 + lngTemp
           Case "D"
               lngTemp = (16 ^ (Ctr - 1)) * 13 + lngTemp
           Case "E"
               lngTemp = (16 ^ (Ctr - 1)) * 14 + lngTemp
           Case "F"
               lngTemp = (16 ^ (Ctr - 1)) * 15 + lngTemp
           
           Case Else
       End Select
       
   Next
   HexToDec = lngTemp
   
End Function
Title: Re:Converting 1B to 27... how??? (solved)
Post by: hismajesty on August 12, 2004, 01:00 AM
Yea but I didn't write that nor do I use it. It was part of a module I found somewhere a while ago and uploaded for my friend. You should have just pasted the whole link. :P

http://www.digitaldoozie.net/HexWorks.bas
Title: Re:Converting 1B to 27... how??? (solved)
Post by: Blaze on August 12, 2004, 12:22 PM
If they don't know how to operate a function as easy as that, they have bad chance of succesfully making a non-csb, non-chat bot.