script for fishing in GTA 5

Ask gaming related questions (AHK v1.1 and older)
desaster
Posts: 1
Joined: 02 Apr 2024, 18:24

script for fishing in GTA 5

02 Apr 2024, 18:37

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.

[Mod edit: Removed broken image link.]


but somehow it doesnt trigger right. Anyone has some tips how to fix it:

Code: Select all

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.]
User avatar
mikeyww
Posts: 27009
Joined: 09 Sep 2014, 18:38

Re: script for fishing in GTA 5

07 Apr 2024, 07:15

Welcome to this AutoHotkey forum!

Debugging 64 lines could take a while. Instead, you could start with about five lines. See if you can get a location's color, and whether it looks like the right color. MouseMove to your coordinates to verify them. By default in AHK v1, colors are in Blue-Green-Red format.

If you are new to AHK, I recommend using its current version, which is v2, instead of this older deprecated version that is no longer developed.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: script for fishing in GTA 5

07 Apr 2024, 12:42

The variables used in the function CheckAndAct() are local and do not see the set variable values outside the function.
Put the word Global as the 1st line in the function and test it. If it still does not work then you need to debug the issue.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: ShatterCoder and 52 guests