Sign in to follow this  
Followers 0
Defiance

Multipe loops

7 posts in this topic

#1 ·  Posted (edited)

I am quite new at script programming and i want to make a bot for a game. My problem is that if i enable any one feature of it the script works fine but if i enable more than one then i get into trouble :)

Below is a script i wrote using the same principles as the functions in the bot only that this script is sending a and b 's not checking pixels and such. Can someone tell me how to enable my script to run multiple loops at the same time?

HotKeySet("{F10}", "talk1")
HotKeySet("{F9}", "talk2")

$a = 0
$b = 0

While (1)
    Sleep(100)
WEnd

Func talk1()
    If $b = 0 Then
        $b = 1
        left()
    ElseIf $b = 1 Then
        $b = 0
    EndIf
EndFunc

Func talk2()
    If $a = 0 Then
        $a = 1
        right()
    ElseIf $a = 1 Then
        $a = 0
    EndIf
EndFunc

Func left()
    While $a = 1
        Send("a")
    WEnd
EndFunc

Func right()
    While $a = 1
        Send("b")
    WEnd
EndFunc
Edited by Defiance

Share this post


Link to post
Share on other sites



I am quite new at script programming and i want to make a bot for a game. My problem is that if i enable any one feature of it the script works fine but if i enable more than one then i get into trouble :)

Below is a script i wrote using the same principles as the functions in the bot only that this script is sending a and b 's not checking pixels and such. Can someone tell me how to enable my script to run multiple loops at the same time?

HotKeySet("{F10}", "talk1")
HotKeySet("{F9}", "talk2")

$a = 0
$b = 0

While (1)
    Sleep(100)
WEnd

Func talk1()
    If $b = 0 Then
        $b = 1
        left()
    ElseIf $b = 1 Then
        $b = 0
    EndIf
EndFunc

Func talk2()
    If $a = 0 Then
        $a = 1
        right()
    ElseIf $a = 1 Then
        $a = 0
    EndIf
EndFunc

Func left()
    While $a = 1
        Send("a")
    WEnd
EndFunc

Func right()
    While $a = 1
        Send("b")
    WEnd
EndFunc

Not sure what you mean by running multiple loops at th esame time. You can run some in sequence in your while/wend loop, and you can call one every so many mSusing AdlibEnable.

BTW, assuming $a is only ever 1 or 0 then a shorter way to write

If $a = 0 Then
        $a = 1
        right()
    ElseIf $a = 1 Then
        $a = 0
    EndIf

is

$a = 1 - $a
 if $a then right()

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.

Share this post


Link to post
Share on other sites

I think hes tring to make this....basically something i made...for Diablo II and it types different stuff like if you type h it might change it into |-| or l-l or H...but im not 100% sure how to get a hotkey for that...because of the so many functions you need :)...heres my script if you want it...

For $sethotkey = 97 to 122
    HotKeySet(Chr($sethotkey),"_"&Chr($sethotkey))
Next

Global $Newletter

While 1
    Sleep(1000)
WEnd

Func _a()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "A"
        Case $Int = 2
            $NewLetter = "4"
        Case $Int = 3
            $NewLetter = "a"
    EndSelect
    Send($NewLetter)
EndFunc

Func _b()
    $Int = Random(1,2,1)
    Select
        Case $Int = 1
            $NewLetter = "B"
        Case $Int = 2
            $NewLetter = "8"
    EndSelect
    Send($NewLetter)
EndFunc

Func _c()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "C"
        Case $Int = 2
            $NewLetter = "("
        Case $Int = 3
            $NewLetter = "["
    EndSelect
    Send($NewLetter)
EndFunc

Func _d()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "|)"
        Case $Int = 2
            $NewLetter = "])"
        Case $Int = 3
            $NewLetter = "D"
    EndSelect
    Send($NewLetter)
EndFunc

Func _e()
    $Int = Random(1,2,1)
    Select
        Case $Int = 1
            $NewLetter = "3"
        Case $Int = 2
            $NewLetter = "E"
    EndSelect
    Send($NewLetter)
EndFunc

Func _f()
    $Int = Random(1,2,1)
    Select
        Case $Int = 1
            $NewLetter = "-F"
        Case $Int = 2
            $NewLetter = "F"
    EndSelect
    Send($NewLetter)
EndFunc

Func _g()
    $Int = Random(1,2,1)
    Select
        Case $Int = 1
            $NewLetter = "G"
        Case $Int = 2
            $NewLetter = "g"
    EndSelect
    Send($NewLetter)
EndFunc

Func _h()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "H"
        Case $Int = 2
            $NewLetter = "h"
        Case $Int = 3
            $NewLetter = "|-|"
    EndSelect
    Send($NewLetter)
EndFunc

Func _i()
    $Int = Random(1,2,1)
    Select
        Case $Int = 1
            $NewLetter = "I"
        Case $Int = 2
            $NewLetter = "i"
    EndSelect
    Send($NewLetter)
EndFunc

Func _j()
    $Int = Random(1,2,1)
    Select
        Case $Int = 1
            $NewLetter = "J"
        Case $Int = 2
            $NewLetter = "j"
    EndSelect
    Send($NewLetter)
EndFunc

Func _k()
    $Int = Random(1,2,1)
    Select
        Case $Int = 1
            $NewLetter = "K"
        Case $Int = 2
            $NewLetter = "K"
    EndSelect
    Send($NewLetter)
EndFunc

Func _l()
    $Int = Random(1,4,1)
    Select
        Case $Int = 1
            $NewLetter = "1"
        Case $Int = 2
            $NewLetter = "{!}"
        Case $Int = 3
            $NewLetter = "L"
        Case $Int = 4
            $NewLetter = "l"
    EndSelect
    Send($NewLetter)
EndFunc

Func _m()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "M"
        Case $Int = 2
            $NewLetter = "M"
        Case $Int = 3
            $NewLetter = "/\/\"
    EndSelect
    Send($NewLetter)
EndFunc

Func _n()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "N"
        Case $Int = 2
            $NewLetter = "n"
        Case $Int = 3
            $NewLetter = "|\|"
    EndSelect
    Send($NewLetter)
EndFunc

Func _o()
    $Int = Random(1,5,1)
    Select
        Case $Int = 1
            $NewLetter = "0"
        Case $Int = 2
            $NewLetter = "o"
        Case $Int = 3
            $NewLetter = "O"
        Case $Int = 4
            $NewLetter = "[]"
        Case $Int = 5
            $NewLetter = "()"
    EndSelect
    Send($NewLetter)
EndFunc

Func _p()
    $Int = Random(1,2,1)
    Select
        Case $Int = 1
            $NewLetter = "P"
        Case $Int = 2
            $NewLetter = "p"
    EndSelect
    Send($NewLetter)
EndFunc

Func _q()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "Q"
        Case $Int = 2
            $NewLetter = "q"
    EndSelect
    Send($NewLetter)
EndFunc

Func _r()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "|2"
        Case $Int = 2
            $NewLetter = "R"
        Case $Int = 3
            $NewLetter = "r"
    EndSelect
    Send($NewLetter)
EndFunc

Func _s()
    $Int = Random(1,4,1)
    Select
        Case $Int = 1
            $NewLetter = "s"
        Case $Int = 2
            $NewLetter = "S"
        Case $Int = 3
            $NewLetter = "5"
        Case $Int = 4
            $NewLetter = "$"
    EndSelect
    Send($NewLetter)
EndFunc

Func _t()
    $Int = Random(1,4,1)
    Select
        Case $Int = 1
            $NewLetter = "7"
        Case $Int = 2
            $NewLetter = "t"
        Case $Int = 3
            $NewLetter = "T"
        Case $Int = 4
            $NewLetter = "{+}"
    EndSelect
    Send($NewLetter)
EndFunc

Func _u()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "u"
        Case $Int = 2
            $NewLetter = "U"
        Case $Int = 3
            $NewLetter = "|_|"
    EndSelect
    Send($NewLetter)
EndFunc

Func _v()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "v"
        Case $Int = 2
            $NewLetter = "V"
        Case $Int = 3
            $NewLetter = "\/"
    EndSelect
    Send($NewLetter)
EndFunc

Func _w()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "\/\/"
        Case $Int = 2
            $NewLetter = "w"
        Case $Int = 3
            $NewLetter = "W"
    EndSelect
    Send($NewLetter)
EndFunc

Func _x()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "x"
        Case $Int = 2
            $NewLetter = "><"
        Case $Int = 3
            $NewLetter = "X"
    EndSelect
    Send($NewLetter)
EndFunc

Func _y()
    $Int = Random(1,2,1)
    Select
        Case $Int = 1
            $NewLetter = "y"
        Case $Int = 2
            $NewLetter = "Y"
    EndSelect
    Send($NewLetter)
EndFunc

Func _z()
    $Int = Random(1,3,1)
    Select
        Case $Int = 1
            $NewLetter = "z"
        Case $Int = 2
            $NewLetter = "Z"
        Case $Int = 3
            $NewLetter = "2"
    EndSelect
    Send($NewLetter)
EndFunc

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

First of all thank you for the reply s.

Well the bot will be for MuOnline and it will have simple functions like left clicks/right clicks/auto login/auto party/auto pots etc.

I want to add every function an a single key to enable/disable it (thats why I am using the $a $b with values 1 and 0) but as you can see in the script above if i activate any one single function it works fine but if i activate them both they will not loop at the same time.

For example in the bot i will activate the option for right clicks, auto login and auto party they will not function properly because the last function i enable will be the one in the loop the other ones (also using loops) will be on pause. Is there a way to disable those pauses?

Another example I make a while wend loop that sends right clicks and using the AdlibEnable i make another function execute every 5 minutes.

When the timed function executes the while loop is paused therefore it stops sending right clicks.

So my question is how to execute the timed function and keep sending right clicks without pause?

I thought of making a .exe for each bot option and a main .exe that controls the hotkeys.

So when the right key is pressed the main exe will execute the exe with the function coresponding to the key. But i would like to have only one exe file.

Edited by Defiance

Share this post


Link to post
Share on other sites

can eny1 help me ?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

well.. u can try something like this

CODE
Global $a, $b, $c, $d, ;.... control variables

While 1

mainFunc()

WEnd

Func mainFunc()

If $a Then

;function that shold make when u press a key

EndIf

If $b Then

;the same but with another key

EndIf

;....

; other functions

EndFunc

Func toggle_A()

$a = Not $a

EndFunc

Func toggle_B()

$b = not $b

EndFunc

;... other "toggles"

hope this will help u!

Edited by AnythinG

Share this post


Link to post
Share on other sites

It is useful thank you.

Share this post


Link to post
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
Sign in to follow this  
Followers 0