Jump to content

Quick Array Help Please


The713
 Share

Recommended Posts

Alright, Im making a simple aimbot for a net game, then Im gonna see if I can get a better score personally than my bot. My bot is not working well with arrays for some reason. help me out please.

;controls for my bot
HotKeySet("{ESC}", "_Exit")
HotKeySet("{f1}", "_Start")
HotKeySet("{f2}", "_Pause")

;start program in paused state
_Pause()

Func _Start()
    While True
        $coord = PixelSearch(59, 61, 825, 541, 0xB58054) ;Find the pixel Im looking for
        MouseMove( $coord[0], $coord[1], 10) ;Move To Spot
        MouseClick("left")  :click left mouse button to fire on spot
        Sleep(50)
    WEnd
EndFunc

Func _Pause()
    While True
        Sleep(250)
    WEnd
EndFunc

Func _Exit()
    Exit
EndFunc

Program starts up into Pause function fine, but when F1 is pressed I get this error:

C:\Documents and Settings\Chris Grover\Desktop\shmup bot.au3 (10) : ==> Subscript used with non-Array variable.:

MouseMove( $coord[0], $coord[1], 10)

MouseMove( $coord^ ERROR

Please help me. I must be missing something.
Link to comment
Share on other sites

If it doesn't find the pixel, it doesn't create the $coord array. So verify that $coord is an array first:

;controls for my bot
HotKeySet("{ESC}", "_Exit")
HotKeySet("{f1}", "_Start")
HotKeySet("{f2}", "_Pause")

;start program in paused state
_Pause()

Func _Start()
    While True
        $coord = PixelSearch(59, 61, 825, 541, 0xB58054) ;Find the pixel Im looking for
        If IsArray($coord) Then
            MouseMove( $coord[0], $coord[1], 10) ;Move To Spot
            MouseClick("left")  ;click left mouse button to fire on spot
            Sleep(50)
        EndIf
    WEnd
EndFunc

Func _Pause()
    While True
        Sleep(250)
    WEnd
EndFunc

Func _Exit()
    Exit
EndFunc
Link to comment
Share on other sites

Alright, Im making a simple aimbot for a net game, then Im gonna see if I can get a better score personally than my bot. My bot is not working well with arrays for some reason. help me out please.

;controls for my bot
HotKeySet("{ESC}", "_Exit")
HotKeySet("{f1}", "_Start")
HotKeySet("{f2}", "_Pause")

;start program in paused state
_Pause()

Func _Start()
    While True
        $coord = PixelSearch(59, 61, 825, 541, 0xB58054);Find the pixel Im looking for
        MouseMove( $coord[0], $coord[1], 10);Move To Spot
        MouseClick("left")  :click left mouse button to fire on spot
        Sleep(50)
    WEnd
EndFunc

Func _Pause()
    While True
        Sleep(250)
    WEnd
EndFunc

Func _Exit()
    Exit
EndFunc

Program starts up into Pause function fine, but when F1 is pressed I get this error:

Please help me. I must be missing something.

I don't think it's a problem with arrays but you are assuming that pixelsearch will find the pixel you want in the rectangle you specify. If it doesn't @error will be 1 so best to have

If @error = 0 then

MouseMOve(.....

MouseMove(...

endif

I think the idea of using F2 to send the script back to Pause is not so good. The way I understand HotKeySet works is that it will interupt the script, perform the HotKey function then return to where the script was interupted. This will make it difficult to know where the script is and it might not behave the way you expect

My suggestion is that you use F2 to call a new function where a global variable is set, say $Stopit.

[code];controls for my bot
HotKeySet("{ESC}", "_Exit")
HotKeySet("{f1}", "GoOn")
HotKeySet("{f2}", "ThatsEnough")
Global $stopit = true

;start program in paused state
_Pause()

Func _Start()
    While $Stopit = false
        $coord = PixelSearch(59, 61, 825, 541, 0xB58054);Find the pixel Im looking for
        if @error = 0 then
                   MouseMove( $coord[0], $coord[1], 10);Move To Spot
               MouseClick("left")  :click left mouse button to fire on spot
               endif

        Sleep(50)
    WEnd
EndFunc

Func GoOn()
 $Stopit = false
endfunc

Func ThatsEnough()
 $Stopit = true
endfunc


Func _Pause()
    While True
          if not $stopit then _Start()
        Sleep(250)
    WEnd
EndFunc

Fu

Func _Exit()
    Exit
EndFunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...