Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Vague on March 27, 2005, 08:02 PM

Title: 0x72 problem
Post by: Vague on March 27, 2005, 08:02 PM
I have successfully added full clan support to a personal chat bot of mine, however I'm stuck at 0x72. According to bnetdocs it comes in this manner..

DWORD: Token
DWORD: Tag
STRING: Clan Name
ect...

and the rest isn't needed to reply.
I don't know where the problem is really....

The tag comes in reversed, so I don't know if I have to reverse it to send it out, or leave it as it is. (I've tried both) So I'm guessing my problem is with the Token.


Heres some code I used to convert these to a DWORD, any help would be appreciated.

Data = Mid$(Data, 5)
s = Left$(Data, 4)
Do Until s = ""
  i = Asc(Left$(s, 1))
  inviteString(0) = inviteString(0) & Hex(i)
  s = Mid$(s, 2)
Loop
Data = Mid$(Data, 5)
'sets token

Data = Mid$(Data, 5)
s = Left$(Data, 4)
Do Until s = ""
  i = Asc(Left$(s, 1))
  inviteString(1) = inviteString(1) & Hex(i)
  s = Mid$(s, 2)
Loop
Data = Mid$(Data, 5)
'sets tag

inviteString(2) = Left$(Data, InStr(Data, Chr$(0)) - 1)
'sets clan name



then to accept I do...

    PBuffer.InsertDWORD "&H" & inviteString(0)
    PBuffer.InsertDWORD "&H" & inviteString(1)
    PBuffer.InsertNTString inviteString(2)
    PBuffer.InsertBYTE &H6
    PBuffer.sendPacket &H72


I have really tried several times to figure this one out and I can't do so. Bnetdocs has  been a lot of help on the other packets but this one has me.
Title: Re: 0x72 problem
Post by: Newby on March 27, 2005, 08:12 PM
Quote from: Vague on March 27, 2005, 08:02 PM
I have successfully added full clan support to a personal chat bot of mine, however I'm stuck at 0x72.

Apparently you haven't.

Please put your code in code tags.
Title: Re: 0x72 problem
Post by: Hdx on March 27, 2005, 08:48 PM
I would suggest you learn how to deal with DWORDS.
Look into GetDWORD()
Public Function GetDWORD(Data As String) As Long
    Dim lReturn As Long
    Call CopyMemory(lReturn, ByVal Data, 4)
    GetDWORD = lReturn
End Function


Quote
Data = Mid$(Data, 5)
'sets token

Data = Mid$(Data, 5)
That could be our problem.. Your compleetly removing a dword there. Ever tryed looing at the values of your vareables?
Also look into a Packet DEBuffer class,Like this crappy one I wrote: http://hdx.no-ip.org/Files/clsRemoveBuffer.cls
~-~(HDX)~-~
Title: Re: 0x72 problem
Post by: Mephisto on March 27, 2005, 08:50 PM
Quote from: Vague on March 27, 2005, 08:02 PM
I have successfully added full clan support to a personal chat bot of mine, however I'm stuck at 0x72. According to bnetdocs it comes in this manner..

DWORD: Token
DWORD: Tag
STRING: Clan Name
ect...

and the rest isn't needed to reply.
I don't know where the problem is really....

The tag comes in reversed, so I don't know if I have to reverse it to send it out, or leave it as it is. (I've tried both) So I'm guessing my problem is with the Token.


Heres some code I used to convert these to a DWORD, any help would be appreciated.

Data = Mid$(Data, 5)
s = Left$(Data, 4)
Do Until s = ""
  i = Asc(Left$(s, 1))
  inviteString(0) = inviteString(0) & Hex(i)
  s = Mid$(s, 2)
Loop
Data = Mid$(Data, 5)
'sets token

Data = Mid$(Data, 5)
s = Left$(Data, 4)
Do Until s = ""
  i = Asc(Left$(s, 1))
  inviteString(1) = inviteString(1) & Hex(i)
  s = Mid$(s, 2)
Loop
Data = Mid$(Data, 5)
'sets tag

inviteString(2) = Left$(Data, InStr(Data, Chr$(0)) - 1)
'sets clan name



then to accept I do...

    PBuffer.InsertDWORD "&H" & inviteString(0)
    PBuffer.InsertDWORD "&H" & inviteString(1)
    PBuffer.InsertNTString inviteString(2)
    PBuffer.InsertBYTE &H6
    PBuffer.sendPacket &H72


I have really tried several times to figure this one out and I can't do so. Bnetdocs has  been a lot of help on the other packets but this one has me.

I only read the first part of your post, but in regards to the clan tag being reversed is simply because it's a DWORD and when Battle.net sends you a DWORD (I'm assuming they use multi-character literal constants as in 'SEXP' or 'CLANTAG') it is reversed because of endianess.
Title: Re: 0x72 problem
Post by: Warrior on March 27, 2005, 08:51 PM
Quote from: Vague on March 27, 2005, 08:02 PM
So I'm guessing my problem is with the Token.

...

You know you can use GetTickCount() for the token correct?


This packet is sent when a mass invite is performed (I think?) so it will return all the users

(DWORD)       Token
(DWORD)       Clan Tag
(STRING)     Clan Name
(STRING)     Inviter's username
(BYTE)        Number of users being invited
(STRING[])    List of users being invited

The Token isn't of much use to use but you should parse the rest, then loop through the rest using the byte sent to you as a limit extracting each string.

Now that  you have recieved the packet I believe you either send an accept or a decline (clan status codes)

An accept should look like this


With botBuffer
        .addDWORD GetTickCount()
        .addDWORD .getDWORD("ClanTagHere")
        .addString "Clan Name Here"
        .addByte STATUS_ACCEPT
        .sendPacket SID_CLANSENDINVITE, cBNCS
End With


or something.
Title: Re: 0x72 problem
Post by: Vague on March 27, 2005, 11:43 PM
Yeah I'm not fully understanding on the pbuffer, and pdebuffer. I'm still learning, but when I have things explained the first time I don't forget.

ps: Thanks Warrior I understood what you were saying best.
Title: Re: 0x72 problem
Post by: Mephisto on March 28, 2005, 04:54 AM
Quote from: Warrior on March 27, 2005, 08:51 PM
Quote from: Vague on March 27, 2005, 08:02 PM
So I'm guessing my problem is with the Token.

...

You know you can use GetTickCount() for the token correct?


This packet is sent when a mass invite is performed (I think?) so it will return all the users

(DWORD)       Token
(DWORD)       Clan Tag
(STRING)     Clan Name
(STRING)     Inviter's username
(BYTE)        Number of users being invited
(STRING[])    List of users being invited

The Token isn't of much use to use but you should parse the rest, then loop through the rest using the byte sent to you as a limit extracting each string.

Now that  you have recieved the packet I believe you either send an accept or a decline (clan status codes)

An accept should look like this


With botBuffer
        .addDWORD GetTickCount()
        .addDWORD .getDWORD("ClanTagHere")
        .addString "Clan Name Here"
        .addByte STATUS_ACCEPT
        .sendPacket SID_CLANSENDINVITE, cBNCS
End With


or something.

Keep in mind though that the token is important in many of the other clan packets in order for the client to respond to the appropriate request.