Code:
Func TownPortalShort()
$gX = 0
$gY = 0
$c = 0
Do
$c += 1
Sleep(100)
If $c > 4 Then return
Until _ImageSearchArea($pngLoc & "TP.png", 1, 600, 200, 1000, 500, $gX, $gY, 40)
$seconds = 2.2
$c = 0
Do
$c += 1
Sleep(100)
If $c > ($seconds * 10) Then ;Make sure we never get stuck here for infinity.
Sleep($tptime - $seconds * 1000 - 1200)
CheckFor("NewTristram", "Area", 0, 0, 0, 0, 4)
sleep(300)
Return
EndIf
Until not _ImageSearchArea($pngLoc & "TP.png", 1, 600, 200, 1000, 500, $gX, $gY, 40)
EndFunc ;==>TownPortalShort
Ok guys I have investigated the Townportal issue and i have found the cause of your troubles.. your pc is slow lol. The townportal function, as Muppel16153 conveniently posted just above has 2 phases, 1st it checks every 100ms for the TP to start for a maximum of 800ms if not assume you were hit and you exit game. If townportal starts it then waits for a maximum of 2.2 seconds (checking every 100ms) for it to finish.
now this works perfectly for me but... if your pc is slow then the constant image check every 100ms will cause this checking to go on longer than 2.2 seconds so the 2.2 seconds actually becomes like 4 seconds, if it goes on this long and the TP ends normally then the loop thinks it has ended early cus its only counted 2 seconds when really its been 3 seconds then your game exits.
Anyway for those that dont understand what im talking about I have released a fix so it checks less frequently (less load on your pc) and there will be a countdown in the GUI, if you see your TP ends normally BEFORE the countdown finishes then you need to reduce the value of $TPProtectTime in the settings at the top OR $seconds in the function (line 1019) so that the countdown ends JUST before a normal TP ends
if its still not working then set line 95 $DetectTPFail = false