$campX = 1170
$campY = 595
$firstButtonX[0] = 1500
$firstButtonY[0] = 435
$firstButtonY[1] = 635
$firstButtonY[2] = 835
$secondButtonX[1] = 1820
$secondButtonY[0] = 135
$secondButtonY[1] = 325
$secondButtonY[2] = 515
$thirdButtonX[2] = 1510
$thirdButtonY[0] = 240
$thirdButtonY[1] = 435
$thirdButtonY[2] = 630
$isScoutAvailable[0] = 0
$isScoutAvailable[1] = 0
$isScoutAvailable[2] = 0
SUB(checkScout, $i, $x, $y)
GETSCREEN
IF(PXL($x,$y) = 48895)
$isScoutAvailable[$i] = 1
ELSE
$isScoutAvailable[$i] = 0
END_IF
END_SUB
SUB(clickButton, $x, $y)
LCLICK($x,$y)
WAIT(2)
END_SUB
clickButton($campX, $campY)
clickButton($campX+200, $campY+160)
WHILE($isScoutAvailable[0] = 0 & $isScoutAvailable[1] = 0 & $isScoutAvailable[2] = 0)
checkScout(0, $firstButtonX[0], $firstButtonY[0])
checkScout(1, $firstButtonX[0], $firstButtonY[1])
checkScout(2, $firstButtonX[0], $firstButtonY[2])
END_CYC
$selectedScout = 0
FOR($i, $i < ARRSIZE($isScoutAvailable))
IF($isScoutAvailable[$i] = 1)
$selectedScout = $i
END_IF
END_CYC
clickButton($firstButtonX[$selectedScout], $firstButtonY[$selectedScout])
Errorlog: Thread _MAIN(0) raise exception