|
-
May 11th, 2007, 01:29 PM
#1
Thread Starter
New Member
Help me optimize this?
Alright so I've got a program that plays a game for me and moves around the rooms of the city. Sometimes if the server lags it loses track and keeps running. Since it reads where to go from a listbox it just continues on and wastes time.
Code:
Private Sub wbNav_DocumentComplete(ByVal pDisp As Object, URL As Variant)
On Error Resume Next
If (WebPageContains("go to a room not next to it.") = True) Then
Call errorDetected
errorYes = True
ElseIf (URL = GAME+"/world.php" And errorYes = True) Then
Call errorFixer
End If
lblCurrent.Caption = (Replace(URL, GAME, ""))
End Sub
'''''
'Error Fixing and Detection!
'''''
Private Function errorDetected()
tmrInterval.Enabled = False
wbNav.Navigate (GAME+"/world.php")
End Function
Private Function errorFixer()
On Error Resume Next
Dim imagesrc As String, karaOke As Integer, argh As String
argh = wbNav.Document.images(3).src
If (WebPageContains("/images/world/map/")) Then
imagesrc = (wbNav.Document.images(3).src)
If (StrComp(argh, "/images/world/crewadv.jpg", vbTextCompare) = 0) Then
imagesrc = (wbNav.Document.images(4).src)
ElseIf (StrComp(argh, "/images/world/mobtalk.jpg", vbTextCompare) = 0) Then
imagesrc = (wbNav.Document.images(4).src)
End If
If (StrComp(wbNav.Document.images(4).src, "/images/world/crewadv.jpg", vbTextCompare) = 0) Then
imagesrc = (wbNav.Document.images(5).src)
ElseIf (StrComp(wbNav.Document.images(4).src, "/images/world/mobtalk.jpg", vbTextCompare) = 0) Then
imagesrc = (wbNav.Document.images(5).src)
End If
imagesrc = Replace(imagesrc, GAME +"/world/map/", "/world.php?room=")
imagesrc = Replace(imagesrc, ".png", "")
For karaOke = 0 To lstRoutine.ListCount
If (StrComp(imagesrc, lstRoutine.List(karaOke)) = 0) Then
pickle = karaOke
karaOke = lstRoutine.ListCount + 21
End If
Next karaOke
End If
errorYes = False
tmrInterval.Enabled = True
End Function
The reason for all the checks of images is the number of images varies depending on the page. Is there an easier way to find the image I want? (I grab the image since its name=the room number I'm in. then I search the listbox for that and tell the program that's where it is.
Last edited by theuberferret; May 11th, 2007 at 01:34 PM.
-
May 11th, 2007, 06:31 PM
#2
Re: Help me optimize this?
If you want to debug for errors, you might want to get rid of On Error Resume Next so you can see if some other errors arise, ie. make sure the error isn't an error that you've made silent by using On Error Resume Next. At the moment you can't be 100% sure that the error is generated by a server lag.
-
May 11th, 2007, 07:28 PM
#3
Thread Starter
New Member
Re: Help me optimize this?
actually an earlier version of this didn't use that. I'm positive tis server lag. The game experiences random lag spikes.
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
|