Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Yegg on November 17, 2004, 02:19 PM

Title: Backwards Split
Post by: Yegg on November 17, 2004, 02:19 PM
Im sure that every1 knows how to do Split, like Split(message, " ") or something like this? well i am trying 2 use this on my channellist, when i use the following code, after right clicking on a username, half of the name gets cut off.

splt = Split(Form1.lvChannel.SelectedItem.Text, " ")
Form1.lvChannel.SelectedItem.Text = Replace(Form1.lvChannel.SelectedItem.Text, splt(1), "")


now this code would go under whisper or something for the menu when u right click a users name. iw as wondering if i would be able to do something like

splt = Split(" ", Form1.lvChannel.SelectedItem.Text)

im not sur if thats the proper code but would this create a backwards split?
the reason im doing this is because i wanted my bot to show a users ping in parenthesis 1 space after their name. and if i could get split to work backwards when right clicking instead of including their ping in w/e the bot is going 2 send. it would send w/e is to the left of that 1 space. is this the proper code to make a backwards split?
Title: Re: Backwards Split
Post by: Hdx on November 17, 2004, 02:54 PM
I don't quite get what you are trying to do, BUt I *think* you want something like this:
Form1.lvChannel.SelectedItem.Text = "Hdx (666)"

Private Sub cmdMnuWhisper_Click()
Dim Name as string, Ping as string
Name = Split(Form1.lvChannel.SelectedItem.Text, Space(1))(0)
Form1.lvChannel.SelectedItem.Text = Mid(Form1.lvChannel.SelectedItem.Text, Len(Name) + 1)
End Sub


Umm that would take out the name from the listview, and put it into the Vareable 'Name'

Or you can do this,
Private Sub cmdMnuWhisper_Click()
Dim Name as string, Rest as string
Name = Split(Form1.lvChannel.SelectedItem.Text, Space(1))(0)
Rest = Mid(Form1.lvChannel.SelectedItem.Text, Len(Name) + 1)
End Sub


That'll  Put the name In 'Name' and Everytthing else in 'Rest'
~-~(HDX)~-~
Title: Re: Backwards Split
Post by: Yegg on November 17, 2004, 02:57 PM
hmm, im not sur if thats exactly wut im looking for. lemme show u exactly wut i have.
Private Sub mnuWhisper_Click()
On Error Resume Next
splt = Split(" ", Form1.lvChannel.SelectedItem.Text)
lstQueue.AddItem "/w " & splt(1) & " " & Form1.txtSend.Text
Form1.tmrQueue.Interval = "1000"
Form1.tmrQueue.Enabled = True
Form1.txtSend.Text = ""
End Sub


in my channel list lets say Yegg wus in there, it would say.
Yegg (5645)
5645 being my ping, i want the bot to send the whisper message. if all i did wus a normal whisper message the bot would type /m Yegg (5645) message
i want the bot to send the message and to not include the users ping.
Title: Re: Backwards Split
Post by: Hdx on November 17, 2004, 02:59 PM
Name = Split(Form1.lvChannel.SelectedItem.Text, Space(1))(0)
~-~(HDX)~-~
Title: Re: Backwards Split
Post by: Yegg on November 17, 2004, 03:00 PM
r u referring Name to wut i used as splt?
so
lstQueue.AddItem "/w " & splt(1) & " " & Form1.txtSend.Text
should be changed to
lstQueue.AddItem "/w " & Name & " " & Form1.txtSend.Text
?
Title: Re: Backwards Split
Post by: Hdx on November 17, 2004, 03:07 PM
Yes. I'll show you how it should look:
Private Sub mnuWhisper_Click()
Dim Name as string,
Name = Split(Form1.lvChannel.SelectedItem.Text, Space(1))(0)
lstQueue.AddItem "/w " & Name & " " & Form1.txtSend.Text
Form1.tmrQueue.Interval = "1000"
Form1.tmrQueue.Enabled = True
Form1.txtSend.Text = vbNullString
End Sub


Also you might want to use tit IIF() function, For the "*" for D2 and D2LOD
So you would change
lstQueue.AddItem "/w " & Name & " " & Form1.txtSend.Text
to
lstQueue.AddItem "/w "  & IIF(UCase(Prod) = "D2DV" or UCase(Prod) = "D2XP", "*", vbNullstring) & Name & " " & Form1.txtSend.Text

Asuming you use 'Prod' for your product code and you use the prod code not somkethign like "Diablo II: Lord of Destruction"
Anywho..
~-~(HDX)~-~
Title: Re: Backwards Split
Post by: Yegg on November 17, 2004, 03:14 PM
hehe, ty so much! the code works great.
Title: Re: Backwards Split
Post by: Hdx on November 17, 2004, 03:15 PM
NP any other questions you have about VB? I got to skip school for the doctors today so i got alot of free time to help ppl out.
~-~(HDX)~-~
Title: Re: Backwards Split
Post by: Yegg on November 17, 2004, 03:24 PM
well since u asked, the only other thing i;ve been trying 2 fix on my bot is to create accounts. it currently connects to hashes using checkrevision.dll and hash.dll, im not sur wut the proper code is to create an account if it doesn't alrdy exist, or if i need bnetauth.dll to do this. here the code i have for Logon Reply.

     If Mid(data, 5, 1) = Chr(1) Then
           
            AddChat "Passed!" & vbNewLine, vbGreen
            connected1 = True
pbuffer.InsertNTString varUser
pbuffer.InsertBYTE 0
pbuffer.SendPacket &HA
pbuffer.InsertDWORD 2
pbuffer.InsertNTString VarHome
pbuffer.SendPacket &HC
     Else
           
            AddChat "Failed!" & vbNewLine, vbRed
            Open "badaccounts.txt" For Append As #1
            Print #1, "lstUser.List(namesnow) & " / " & lstPass.List(namesnow)"
            Close #1
            wsBNET.Close
            wsBNET.Connect VarServer, "6112"
    End If
    Case &HA
   Dim spltn() As String
spltn() = Split(data, Chr(0), 5)
AddChat "Logged on as " & spltn(1) & vbNewLine, vbGreen
varUser = spltn(1)


all of this code is under Public Sub parsep(ByVal data As String)
all i need 2 know if the proper code in creating an account and how 2 do it.
Title: Re: Backwards Split
Post by: Hdx on November 17, 2004, 03:36 PM
    Case &H3A
        Select Case Asc(Mid(Data, 5, 1))
            Case &H1
                 AddChat Index, vbRed, "[BNET] Login Failed!, Account dosen't exists."
                 AddChat Index, vbGreen, "[BNET] Attempting to make account."
                Dim Res As Boolean
                Hash = String(5 * 4, vbNullChar)
                Res = x(Hash, password)
                If Res = True Then
                    PBuffer.InsertNonNTString Hash
                    PBuffer.InsertNTString Username
                    PBuffer.SendPacket Index, &H3D
                    AddChat Index, vbYellow, "[BNET] Account Created"
                Else
                    AddChat Index, vbRed, "[BNET] Account Creation Failed"
                End If
            Case &H2: AddChat Index, vbRed, "[BNET] Login Failed!, Invalid password."
            Case &H0: AddChat Index, vbGreen, "[BNET] Login Passed!"
            Case Else: AddChat Index, vbRed, "[BNET] Unknown Login error."
        End Select

This is using BNetAuth.dll, It has the same functions as both hash.dll and CheckRevision.dll I strongly recomend switching to it.
Here are some APIs
Public Declare Function z Lib "bnetauth.dll" Alias "Z" _
    (ByVal FileExe As String, _
    ByVal FileStormDll As String, _
    ByVal FileBnetDll As String, _
    ByVal HashText As String, _
    ByRef Version As Long, _
    ByRef CheckSum As Long, _
    ByVal EXEInfo As String, _
    ByVal MPQName As String) As Long
       
Public Declare Function A Lib "bnetauth.dll" _
    (ByVal outbuf As String, _
    ByVal ServerKey As Long, _
    ByVal password As String) As Long
   
Public Declare Function x Lib "bnetauth.dll" Alias "X" _
    (ByVal outbuf As String, _
    ByVal password As String) As Long
   
Public Declare Function A2 Lib "bnetauth.dll" _
    (ByVal outbuf As String, _
    ByVal Key As Long) As Long
   
Public Declare Function G Lib "bnetauth.dll" _
    (ByVal outbuf As String) As Long
   
Public Declare Function c Lib "bnetauth.dll" Alias "C" _
    (ByVal outbuf As String, _
    ByVal serverhash As Long, _
    ByVal prodid As Long, _
    ByVal val1 As Long, _
    ByVal val2 As Long, _
    ByVal seed As Long) As Long

~-~(HDX)~-~
Title: Re: Backwards Split
Post by: Yegg on November 17, 2004, 04:05 PM
um, if i were to switch to bnetauth.dll, would all of my code in module1 (where i hav all the sendcdkey, send1e etc.) hav to be changed as well? and also, my Public Sub parsep, im not sur wut i would have 2 change for it. and the last thing, is there any wat at all to create accounts with just checkrevision.dll and hash.dll?
Title: Re: Backwards Split
Post by: Hdx on November 17, 2004, 05:45 PM
Umm, you shouldnt have to modify to mmuch stuff, just a few of your API calls to do checkZRev an crap, And I don't know of any way to just use those two.
~-~(HDX)~-~
Title: Re: Backwards Split
Post by: Dyndrilliac on November 17, 2004, 06:13 PM
Your question has already been answered, but if you wanted to truly do a "Backwards" split, just use StrReverse(), split it, then reverse the pieces.
Title: Re: Backwards Split
Post by: LivedKrad on November 18, 2004, 07:03 AM
Creating accounts is done with packets, not your version/hash retrieval method. I don't see why a parsing sub would have to be changed to incoporate a different DLL that does the same versioning. The only thing you would have to change is the function name(s)/declaration(s)/function syntax(es) that deal with versioning.
Title: Re: Backwards Split
Post by: Yegg on November 18, 2004, 02:56 PM
so if i changed the proper code i could create accounts using checkrevision.dll and hash.dll and not needing bnetauth.dll?
also, do u know the proper code i need for creating accounts?
Title: Re: Backwards Split
Post by: LivedKrad on November 18, 2004, 05:57 PM
Quote from: Yegg on November 18, 2004, 02:56 PM
so if i changed the proper code i could create accounts using checkrevision.dll and hash.dll and not needing bnetauth.dll?
also, do u know the proper code i need for creating accounts?

You don't seem to grasp the concept: it does not matter what you use to creating the version hash! You don't use checkrevision.dll or bnetauth.dll to create accounts, you just use the proper packet and packet structure to do it. I believe bnetdocs has a well documented and informative section on the create account packet.

http://bnetdocs.valhallalegends.com/content.php?Code=29
Title: Re: Backwards Split
Post by: Hdx on November 18, 2004, 06:02 PM
I beleave you do not under stand him, He I beleave, Is talking about the function you use to hash the password when making an account. The password must be hashed, And it must be done correctly or it will result in 1) creation failure 2) created with wrong password.
And You could prolly use Hash.dll for this, but I would HIGHLY recommened changeing the few function that you have using the two .dlls and switch to BnetAuth.dll
~-~(HDX)~-~
Title: Re: Backwards Split
Post by: Yegg on November 19, 2004, 04:46 PM
Well, i was thinking about changing to bnetauth.dll which i might end of doing, but I just can't seem to figure out the proper create account code. Im gonna go check the battle.net documents and see if that helps at all.
Title: Re: Backwards Split
Post by: LivedKrad on November 20, 2004, 07:58 AM
If you know the language and went to the link I posted, you should have no problem. BTW, why did you say "im gonna go to bnet docs and check it out"? I posted the direct link right on front of you!

Edit: I'd be more than happy to help as long as you posted your problems/inquiries here. [Try and make them as detailed as possible]
Title: Re: Backwards Split
Post by: Yegg on November 20, 2004, 11:24 AM
I said i was going to go to bnetdocs right now because you gave me the link to go there. When I went there, i went to SID_CREATEACCOUNT and it shows that packet, direction, and format. My only problem is that im not sure how to set up this code. Im planning on continuing to use CheckRevision.dll and Hash.dll, but under Public Sub parsep(ByVal Data As String) where I have
  Case &H29
     If Mid(Data, 5, 1) = Chr(1) Then
           
            AddChat "Passed!" & vbNewLine, vbGreen
            Connected = True
pbuffer.InsertNTString varUser
pbuffer.InsertBYTE 0
pbuffer.SendPacket &HA
pbuffer.InsertDWORD 2
pbuffer.InsertNTString VarHome
pbuffer.SendPacket &HC
     Else
           
            AddChat "Failed!" & vbNewLine, vbRed
            wsBNET.Close
            End If


do I send the packets right after AddChat "Failed!" or does it go somewhere else?
And i also need the proper code to send. Sorry if I'm taking up your time.
Title: Re: Backwards Split
Post by: Ban on November 22, 2004, 03:24 PM
Yegg, do you auctually know the language you are attempting to program in? It would appear to me that you have absolutly no clue as to what you are doing...
Title: Re: Backwards Split
Post by: Yegg on November 22, 2004, 03:46 PM
i know a lot of the language its just that the battle.net packets r confusing me.
Title: Re: Backwards Split
Post by: LivedKrad on November 22, 2004, 07:44 PM
It looks to me like you are using DarkMinion's packet buffer class. While this is perfectly OK it being open source, you should learn exactly what it does first before using its functions. The purpose of the class is to create a buffer - or a sort of in-between "container" for the data. The functions add data into this container, like picking up different items off of a floor and putting it inside a box. The different functions would be like using different methods to pick items up off the floor. Entire hand for a larger object, two fingers for a small object, two hands for a very large object, etc. The data sent through these functions is represented by the different objects you pick up off the floor, and then they are added to the box - buffer. You then take this newly made buffer and send it on its way to Battle.net. Kind of like picking up the container and carrying it downstairs.
Now, this being said, when all of the packet buffer adding functions are done - i.e. you're done picking things up off the floor and they're all in the box - you then prepare to send the box away. This is when you add the function to send the data - right after you're done filling the box.

Hope that helps, :p

[EDIT: Fixed grammar and forgot-to-proofread mistakes]