Jump to content

I can't put a certain code outside of my funcs?


BuddyBoy
 Share

Recommended Posts

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 0)
Opt("PixelCoordMode", 0)
#include <GUIConstants.au3>

HotKeySet("{F5}", "On")
HotKeySet("{ESC}", "Terminate")
HotKeySet("^p", "_ToggleRun")

Global $Running = 0, $MPos, $PixelColor
Dim $SearchMob=0
GUICreate("TUL- The Ultimate Leveler",150,100,100,100)
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")

$Label=GUICtrlCreateLabel("F5 to turn on bot.",10,5,130,15)
$Radio1=GUICtrlCreateRadio("Warrior/Trojan",10,35,130,15)
$Radio2=GUICtrlCreateRadio("Archer",10,65,130,15)
GUICtrlSetState ($Radio1, $GUI_CHECKED)
GUISetState()





While 1
    If $SearchMob Then Attack()
    Sleep(1000)
WEnd


Func _ToggleRun()
    $Running = NOT $Running
    If $Running Then
            $MPos = MouseGetPos()
            $PixelColor = PixelGetColor($MPos[0], $MPos[1])
        EndIf
EndFunc



Func On()
    $SearchMob=NOT $SearchMob
    If $SearchMob Then
        GUICtrlSetData($Label,"F5 to turn off bot.")
    Else
        GUICtrlSetData($Label,"F5 to turn on bot.")
    EndIf
EndFunc 


Func Jump()
    $x=Random(0,1024,1)
    $y=Random(0,690,1)
    MouseMove($x,$y,0)
    Send("{CTRLDOWN}")
    MouseClick("Left")
    Send("{CTRLUP}")
    Sleep(900)
EndFunc

Func Attack()
    $Coords=PixelSearch(200,100,825,600,12059395,5)
    If NOT @error Then
        If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = $GUI_CHECKED then
        MouseClick("left",$Coords[0]+10,$Coords[1]+20,1,0)
        Sleep(2200)
                If $Running Then
                    If $PixelColor <> PixelGetColor($MPos[0], $MPos[1]) Then
                        Send("{F2}")
                        Sleep(1000)
                    EndIf
                EndIf
            Sleep(50)
            Else
        MouseClick("right",$Coords[0]+10,$Coords[1]+20,1,0)
        Sleep(2200)
            If $Running Then
                If $PixelColor <> PixelGetColor($MPos[0], $MPos[1]) Then
                    Send("{F2}")
                    Sleep(1000)
                EndIf
            EndIf
      EndIf
    Else
        Jump()
    EndIf
EndFunc

Func Terminate()
    Exit
EndFunc;==> Terminate()

Ok theres my coding... Works perfectly fine... But this is where I'm having problems.

MouseClick("left",$Coords[0]+10,$Coords[1]+20,1,0)
        Sleep(2200)
                If $Running Then
                    If $PixelColor <> PixelGetColor($MPos[0], $MPos[1]) Then
                        Send("{F2}")
                        Sleep(1000)
                    EndIf
                EndIf
            Sleep(50)
            Else
        MouseClick("right",$Coords[0]+10,$Coords[1]+20,1,0)
        Sleep(2200)
            If $Running Then
                If $PixelColor <> PixelGetColor($MPos[0], $MPos[1]) Then
                    Send("{F2}")
                    Sleep(1000)
                EndIf
            EndIf
      EndIf

I need the "If $Running Then..." to let the user have time to pick there color... I tried putting it out of the func, so they could press ctrl+p before starting the bot, but it didn't work...

I have 2 options (possibly more but this is what I thought could work)

1. Somehow put it outside the func so the user could press ctrl+p whenever they want before the bot starts up. (would prefer this one more)

2. Once F5 is pressed have it wait 10 seconds to give the user time to press ctrl+p and then go on with the bot... But I don't want it in a loop so that EVERYTIME it attacks a monster it has to wait 5-10 seconds... Could you just relay that 5-10 seconds ONE time and then it never happens again?

Like I said there could be more possible ways, I just hope you guys can help me figure it out.

(I'd prefer number 1 because then they wouldn't have to press ctrl+p everytime they press F5 to start the bot, instead they could just do it once, and it holds that in memory the whole time while the bot is or isnt running)

Thanks for the help if you can figure out a way. :P

*Hope you understood all that lol*

Link to comment
Share on other sites

I dont understand your needs.

If you want the user to 'pick up a color' why not asking him at the start of your prog ?

(like with an inputbox ?)

hope it helps.

regards.

--EDIT

Or add an inputbox in your gui (GUICtrlCreateEdit) ?

so that the user can change it any time he wants.

Edited by Iklim

Iklim

Link to comment
Share on other sites

I dont understand your needs.

If you want the user to 'pick up a color' why not asking him at the start of your prog ?

(like with an inputbox ?)

hope it helps.

regards.

--EDIT

Or add an inputbox in your gui (GUICtrlCreateEdit) ?

so that the user can change it any time he wants.

Sorry if I wasn't clear.. but thats exactly what I want, but I can't figure out WHERE to put it at the beginning of the program, everywhere I tried, it didn't work...

Thanks if you can help me :P

Link to comment
Share on other sites

Add the include, and try the following..see if it works for you

#include<misc.au3>
Func _ToggleRun()
    Local $Pos, $PixelColor
    While Not _IsPressed("01")
        $Pos = MouseGetPos()
        $PixelColor = PixelGetColor($Pos[0], $Pos[1])
        ToolTip("Press left mouse button to set color",$Pos[0],$Pos[1],"Capturing",0,0)
    WEnd
    If _IsPressed("01") Then
        $Picked=PixelGetColor($Pos[0], $Pos[1])
        Return $Picked
    EndIf
EndFunc
Edited by Generator
Link to comment
Share on other sites

I'm a bit confused on your script there. I don't have an _IfPressed variable...?

And where do I put that code in, and do I take my code out from my script as well?

I put that in my ToggleRun() and it says If _IfPressed() must have a Then statement...

Could you explain your script a little bit more, that would be great!

Thank you very much :P

Link to comment
Share on other sites

I'm a bit confused on your script there. I don't have an _IfPressed variable...?

And where do I put that code in, and do I take my code out from my script as well?

I put that in my ToggleRun() and it says If _IfPressed() must have a Then statement...

Could you explain your script a little bit more, that would be great!

Thank you very much :P

Put the include at very top, and replace your _ToggleRun(), and change the variable name.
Link to comment
Share on other sites

I know what to do with the code... But how does that solve my ctrl+p problem? I'm a bit confused, I'm not criticizing you, I'm just asking, how that can do with my ctrl+p anytime problem xD

Thanks, Buddyboy

Edited by BuddyBoy
Link to comment
Share on other sites

I know what to do with the code... But how does that solve my ctrl+p problem? I'm a bit confused, I'm not criticizing you, I'm just asking, how that can do with my ctrl+p anytime problem xD

Thanks, Buddyboy

I just realized the function's purpose is to ToggleRun, looked through your code, you can do this.

Add a variable name and make the $variable=0

In the _ToggleRun function, make an if statement.

If Not $variable then

;The loop i posted to select color, use your own way if you prefer

$variable=1

EndIf

This way, the color check will only be toggled once, and if you want to reselect color, just change the $variable to 0
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...