Jump to content

Need help with PixelSearch Timeout


Recommended Posts

What I am doing is checking for white text on the character select screen after I login to a game. This is the only constant color on this particular screen. This works perfectly as a timer for load time variation. The problem is sometimes I get a server full try again message. So my script is searching for a color in an infinite loop. All the while the game is waiting for relog.

How can I make this loop timeout after 30 seconds?

func chardetect()
do
 sleep (10)
PixelSearch( 671, 71, 736, 137, 0xfefefe, 10);search for white on char screen
 $err2 = @error
until $err2 < 1
ToolTip("Login Succesful", 0, 0)
endfunc
Edited by mithandir1
Link to comment
Share on other sites

func chardetect()
    Local $login = True
    Local $time = 30 ;sec
    $timer = TimerInit()
    do
        sleep (10)
        PixelSearch( 671, 71, 736, 137, 0xfefefe, 10);search for white on char screen
        $err2 = @error
        if TimerDiff($timer) >= $time*1000 Then
            $login = False
            ExitLoop
        EndIf
    until $err2 < 1
    if $login = True Then
        ToolTip("Login Succesful", 0, 0, "GameName bot:", 1)
    Else
        ToolTip("Character wasn't detected within 30 sec.", 0, 0, "GameName bot:", 3)
    EndIf
endfunc

Edited by sandin
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...