• Welcome to Valhalla Legends Archive.
 

Converting 1B to 27... how??? (solved)

Started by phvckmeh, August 01, 2004, 04:22 AM

Previous topic - Next topic

phvckmeh

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

Banana fanna fo fanna

11 * 16 ^ 0 + 1 * 16 ^ 1

A = 10
B = 11
C = 12
D = 13
E = 14
F = 15

TheMinistered

#2
That equation seems to me to be a bit redundant... could simplify it a bit:  11 * 16 ^ 0 + 16

CrAz3D

rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Banana fanna fo fanna

Because you compute it like this...


value = 0;
for each digit in the number, right to left {
value += digitvalue * 16 ^ (num_digits - digit_position)
}

Eli_1

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
                               

phvckmeh

anyone able to put this in a function? like

public sub convertbyte(data as string)

whatever...

end funtion

Eli_1

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


K

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.

ChR0NiC

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 :-\

phvckmeh

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


phvckmeh

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


ChR0NiC

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

Negotiable

System.out.println(Integer.parseInt(num, 16));

phvckmeh