• Welcome to Valhalla Legends Archive.
 

Backwards Split

Started by Yegg, November 17, 2004, 02:19 PM

Previous topic - Next topic

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.

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?

Hdx

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

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Yegg

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.

Hdx

Name = Split(Form1.lvChannel.SelectedItem.Text, Space(1))(0)
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Yegg

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
?

Hdx

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

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Yegg

hehe, ty so much! the code works great.

Hdx

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

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

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.

     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.

Hdx

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

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

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?

Hdx

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

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

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.
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

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.

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?