# Need help with function

## Recommended Posts

I need help with this function. What I want it to do is check if the pixel color at 171,148 is white,if it is then it will click 585,234. If the pixel is not white I want it to click on 260,276 until the pixel color at 147,230 is white. I also need it to loop over and over until the pixel color at 147,230 is white. Thanks for your help.

```func attack()
mousemove(260,276)
while 1
do
if pixelgetcolor(171,148) = 0xFFFFFF Then
mouseclick("left",585,234,1,\$randomdelay)
else
mouseclick("left",260,276,1,\$randomdelay)
until PixelGetColor(147,230) = 0xFFFFFF
EndIf
wend
endfunc```
Edited by Insaynity

##### Share on other sites

I am still learning myself but try this

```\$randomdelay = Random(100, 1000)

Func attack()
Do
\$atk = PixelGetColor(171, 148, 2)
If \$atk = 0xFFFFFF Then
MouseClick("left", 585, 234, 1, \$randomdelay)
If \$atk <> 0xFFFFFF Then
MouseClick("left", 260, 276, 1, \$randomdelay)
EndIf
EndIf
Until \$atk = 0xFFFFFF
EndFunc  ;==>attack```

##### Share on other sites

I need help with this function. What I want it to do is check if the pixel color at 171,148 is white,if it is then it will click 585,234. If the pixel is not white I want it to click on 260,276 until the pixel color at 147,230 is white. I also need it to loop over and over until the pixel color at 147,230 is white. Thanks for your help.

```func attack()
mousemove(260,276)
while 1
do
if pixelgetcolor(171,148) = 0xFFFFFF Then
mouseclick("left",585,234,1,\$randomdelay)
else
mouseclick("left",260,276,1,\$randomdelay)
until PixelGetColor(147,230) = 0xFFFFFF
EndIf
wend
endfunc```
Edited it a little but got it to work exactly how I wanted. This also helped me with another bit of code I had. Thank you.

##### Share on other sites

Here ya go, Quick 'N Clean muttley

```Func Attack()
While 1
If PixelGetColor(171,148) = 0xFFFFFF Then
MouseClick("left",585,234,1,0)
ElseIf NOT PixelGetColor(147,230) = 0xFFFFFF Then
MouseClick("left",260,276,1,0)
Else
RETURN
EndIf
Sleep(50)
WEnd
EndFunc```

## Create an account

Register a new account