Hello,
im new to this im trying to build a script for fishing for GTA, there is a worm which moves and a green bar and the green bar gets up by pushing space and gets down by releasing space, I defined the coordinated of the whole location and also defined the colour of the worm and the bar so that it press the bar until it reaches the worm and push the space or release it that the bar stays with the fish.
![Image]()
but somehow it doesnt trigger right. Anyone has some tips how to fix it:
[Mod edit: Moved topic from AHK v2 help since this is v1 code.]
im new to this im trying to build a script for fishing for GTA, there is a worm which moves and a green bar and the green bar gets up by pushing space and gets down by releasing space, I defined the coordinated of the whole location and also defined the colour of the worm and the bar so that it press the bar until it reaches the worm and push the space or release it that the bar stays with the fish.

but somehow it doesnt trigger right. Anyone has some tips how to fix it:
CODE:
CoordMode, Pixel, Screen
; Definition of the coordinates of the box
Box_Left := 395
Box_Right := 434
Box_Top := 352
Box_Bottom := 730
; colourcode
Worm_Color := 0xC87BCB
Bar_Color := 0x289117
; Function for checking whether a pixel has the color of a specific color code
HasColor(x, y, color) {
PixelGetColor, current_color, %x%, %y%
return current_color = color
}
;
PressSpace() {
Send {Space down}
Sleep 50 ; delay for stability
}
;
ReleaseSpace() {
Send {Space up}
Sleep 50 ; delay for stability
}
; Main function that checks the worm and the bar and acts accordingly
CheckAndAct() {
; Checking the worm
if HasColor(Worm_X, Worm_Y, Worm_Color) {
; Checking the bar below the worm
if HasColor(Worm_X, Bar_Y, Bar_Color) {
PressSpace() ; Press the space bar when the bar is below the worm
} else {
ReleaseSpace() ; Release the space bar when the bar is above the worm
}
} else {
ReleaseSpace() ; Release the space bar if the worm was not found
}
}
; Function for ending the script with the ESC key
OnExit("ExitScript")
ExitScript() {
ExitApp
}
; Endless loop for continuous checking and action
Loop {
; Updating the worm coordinates
Worm_X := (Box_Left + Box_Right) // 2
Worm_Y := (Box_Top + Box_Bottom) // 2
; Updating the bar coordinates
Bar_Y := Box_Bottom + 5 ; Assumption: The bar is located 5 pixels below the worm
CheckAndAct() ; Call up the function to check the worm and the bar and act accordingly
Sleep 100 ; Short delay for the update frequency
}
[Mod edit: Moved topic from AHK v2 help since this is v1 code.]
Statistics: Posted by desaster — 14 minutes ago