|
-
Jun 2nd, 2007, 07:49 AM
#1
Thread Starter
Junior Member
Lots of If Then Parses
Ive been working on a very large "bot" for a game that I play. Basically all it does is parse two log files that alternate as the logs are being used by the game you cant parse them while its being written to.
Anyhow my code is starting to get very bulky and starting to take more time to process than I would lilke. So if anybody is good at stuff like this any suggestions would be apreciated.
Here is the bulk of the processing
Code:
Private Sub Sendmessage(msg As String)
Dim lHwnd As Long
Dim lRetVal As Long
Dim i As Integer
Dim character As String
lHwnd = FindWindow("HGClass", "NODBOT V1.53 Beta")
If lHwnd Then
lRetVal = PostMessage(lHwnd, WM_KEYDOWN, VK_RETURN, &H1)
For i = 1 To Len(msg)
character = Mid$(msg, i, 1)
lRetVal = PostMessage(lHwnd, WM_CHAR, ByVal Asc(character), 0&)
Next
lRetVal = PostMessage(lHwnd, WM_KEYDOWN, VK_RETURN, &H1)
End If
End Sub
Private Sub findword2()
Dim parse() As String
Dim temp As String
Dim Entering() As String
Dim killed() As String
Dim killed2() As String
Dim i As Integer
Dim re As New RegExp, m As Match
Dim t As String
Dim JoinInv() As String
Dim JInv As String
Dim x As Integer
Dim killbox() As String
Dim item_index As Long
Open "C:\Program Files\Sony\Station\Infantry\nodbot\bhl\bhl2.log" For Input As #1
Do Until EOF(1)
Line Input #1, temp
parse = Split(temp, vbTab)
'0 = message type'
'1 = sent to'
'2 = sender'
'3 = message'
Entering = Split(parse(3), "Entering: ")
If InStr(parse(0), "8") > 0 Then
killed = Split(parse(3), " killed by ")
t = killed(0)
re.Pattern = "\(*\d\d*\)$"
re.Global = True
For Each m In re.Execute(t)
killed2 = Split(killed(0), m.Value)
item_index = SendMessage2(List1.hwnd, LB_FINDSTRING, -1, killed2(0))
Next
If item_index > 0 Then
killbox = Split(List1.List(item_index), " ::: ")
List1.List(item_index) = killbox(0) & " ::: " & killbox(1) + 1
Else
List1.AddItem killed2(0) + " ::: " + "1"
End If
End If
If playd.Value = 1 And InStr(parse(0), "8") > 0 Then
killed = Split(parse(3), " killed by ")
t = killed(0)
re.Pattern = "\(*\d\d*\)$"
re.Global = True
For Each m In re.Execute(t)
killed2 = Split(killed(0), m.Value)
Sendmessage ":" + killed2(0) + ": " + pdmes.Text
Next
End If
If joinkeyon.Value = True And InStr(parse(0), "2") > 0 And InStr(parse(3), joinkey.Text) > 0 Then
Sendmessage ":" + parse(2) + ":*unspec"
End If
If joininvon.Value = True And InStr(parse(0), "2") > 0 And InStr(parse(3), joinkey.Text) > 0 Then
JInv = one.Text
JoinInv = Split(JInv, ",")
For x = 0 To UBound(JoinInv)
Sendmessage ":" + parse(2) + ":" + "*prize " + JoinInv(x)
Next
End If
If ent1e.Value = 1 And InStr(parse(0), "9") > 0 Then
Sendmessage ":" + Entering(1) + ": " + ent1.Text
End If
If ent2e.Value = 1 And InStr(parse(0), "9") > 0 Then
Sendmessage ":" + Entering(1) + ": " + ent2.Text
End If
If ent3e.Value = 1 And InStr(parse(0), "9") > 0 Then
Sendmessage ":" + Entering(1) + ": " + ent3.Text
End If
If ent4e.Value = 1 And InStr(parse(0), "9") > 0 Then
Sendmessage ":" + Entering(1) + ": " + ent4.Text
End If
If InStr(parse(0), "2") > 0 And InStr(parse(3), key1.Text) > 0 Then
Sendmessage key1t.Text
End If
If InStr(parse(0), "2") > 0 And InStr(parse(3), key2.Text) > 0 Then
Sendmessage key2t.Text
End If
If InStr(parse(0), "2") > 0 And InStr(parse(3), key3.Text) > 0 Then
Sendmessage key3t.Text
End If
Loop
Close #1
End Sub
-
Jun 2nd, 2007, 09:49 AM
#2
Re: Lots of If Then Parses
I'm afraid we do not support cheating in online games, from our Acceptable Use Policy (link at the bottom of all VBF pages):
You will not use these Forums for the purposes of sharing or distributing viruses, licenses, registration information, software keys, "cracks," or other information designed to do harm to or allow unlawful access to any computer hardware, software, networks, or any other systems.
This thread is now closed - if you have any comments about this, feel free to PM me or any other moderator (but this thread will not be unlocked).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|