Valhalla Legends Forums Archive | Visual Basic Programming | Backwards Split

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

[code]splt = Split(Form1.lvChannel.SelectedItem.Text, " ")
Form1.lvChannel.SelectedItem.Text = Replace(Form1.lvChannel.SelectedItem.Text, splt(1), "")[/code]

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

[code]splt = Split(" ", Form1.lvChannel.SelectedItem.Text)[/code]

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?
November 17, 2004, 8:19 PM
HdxBmx27
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)"
[code]
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[/code]

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

Or you can do this,
[code]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[/code]

That'll  Put the name In 'Name' and Everytthing else in 'Rest'
~-~(HDX)~-~
November 17, 2004, 8:54 PM
Yegg
hmm, im not sur if thats exactly wut im looking for. lemme show u exactly wut i have.
[code]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[/code]

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.
November 17, 2004, 8:57 PM
HdxBmx27
[code]Name = Split(Form1.lvChannel.SelectedItem.Text, Space(1))(0)[/code]
~-~(HDX)~-~
November 17, 2004, 8:59 PM
Yegg
r u referring Name to wut i used as splt?
so
[code]lstQueue.AddItem "/w " & splt(1) & " " & Form1.txtSend.Text[/code]
should be changed to
[code]lstQueue.AddItem "/w " & Name & " " & Form1.txtSend.Text[/code]
?
November 17, 2004, 9:00 PM
HdxBmx27
Yes. I'll show you how it should look:
[code]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[/code]

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

Asuming you use 'Prod' for your product code and you use the prod code not somkethign like "Diablo II: Lord of Destruction"
Anywho..
~-~(HDX)~-~
November 17, 2004, 9:07 PM
Yegg
hehe, ty so much! the code works great.
November 17, 2004, 9:14 PM
HdxBmx27
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)~-~
November 17, 2004, 9:15 PM
Yegg
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.

[code]    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)[/code]

all of this code is under [code]Public Sub parsep(ByVal data As String)[/code]
all i need 2 know if the proper code in creating an account and how 2 do it.
November 17, 2004, 9:24 PM
HdxBmx27
[code]    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[/code]
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
[code]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[/code]
~-~(HDX)~-~
November 17, 2004, 9:36 PM
Yegg
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?
November 17, 2004, 10:05 PM
HdxBmx27
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)~-~
November 17, 2004, 11:45 PM
Dyndrilliac
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.
November 18, 2004, 12:13 AM
LivedKrad
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.
November 18, 2004, 1:03 PM
Yegg
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?
November 18, 2004, 8:56 PM
LivedKrad
[quote author=Yegg link=topic=9585.msg89286#msg89286 date=1100811377]
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?
[/quote]

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
November 18, 2004, 11:57 PM
HdxBmx27
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)~-~
November 19, 2004, 12:02 AM
Yegg
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.
November 19, 2004, 10:46 PM
LivedKrad
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]
November 20, 2004, 1:58 PM
Yegg
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
[code]  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[/code]

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.
November 20, 2004, 5:24 PM
Ban
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...
November 22, 2004, 9:24 PM
Yegg
i know a lot of the language its just that the battle.net packets r confusing me.
November 22, 2004, 9:46 PM
LivedKrad
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]
November 23, 2004, 1:44 AM

Search