Sign in to follow this  
Followers 0
darkxraver

Need Help With Pausing A Script

10 posts in this topic

hey all i need some help with a script.

its an auto-buff script for a game called silkroad online. what it does is it switches the weapon to cast a protective skill then switches back to the fighting weapon. everything works great. but my problem here is that every once in a while my char has to teleport back to town to get new stocks of hp, mp and bolts and if it interacts with the npc while the script is running then it gets screwed up. so what i did is getting the pixelcolor of the teleportbar in the center middle of the screen (that indicates how long it takes till i finally teleport) to pause/freeze the script for a few minutes but its not working out that well. heres the code

#RequireAdmin
Global $UnPaused
HotKeySet("{PGDN}", "TogglePause")
HotKeySet("{END}", "Terminate")

While 1
    Sleep(100)
    ToolTip("abuff OFF/On = [PAGE DN]",415,695)
WEnd


Func TogglePause()
    $UnPaused = NOT $UnPaused
    While $UnPaused
        
        While PixelGetColor(641, 990) = 0x00E794
            ExitLoop
            Sleep(420000)
            ContinueLoop
        WEnd
        
        ToolTip("abuff ON/Off = [PAGE DN]",415,695)
        sleep(1000)
        BlockInput(1)
        Tooltip("   Changing Weapon:   " & @CRLF & " " & @CRLF & "       Cleric Rod      ",0,716)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        sleep(1000)
        
        Tooltip("       Casting Skill:     " & @CRLF & " " & @CRLF & "        Bless Skill           ",0,716)
        Send("7"); Bless
        Opt("SendKeyDelay", 300)
        Send("7"); Bless
        Sleep(3000)
        
        Tooltip("                " & @CRLF & "      Using MP Pot        " & @CRLF & "              ",0,716)
        Send("2"); Use Mp Potion
        Sleep(3000)
        
        
        Tooltip("       Casting Skill:     " & @CRLF & " " & @CRLF & "  Recovery Division   ",0,716)
        Send("8"); Recovery Division
        Opt("SendKeyDelay", 300)
        Send("8"); Recovery Division
        Opt("SendKeyDelay", 300)
        Sleep(5000)
        
        Tooltip("   Changing Weapon:   " & @CRLF & " " & @CRLF & "           xBow            ",0,716)
        Send("9"); Xbow
        Opt("SendKeyDelay", 300)
        Send("9"); Xbow
        BlockInput(0)
        Sleep(3000)
        WinActivate ("Pluto (NEW) - xxxxxx")
                                Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 10sec      ",0,716)
        Sleep(1000)
                    Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 09sec      ",0,716)
        Sleep(1000)
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 08sec      ",0,716)
        Sleep(1000)
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 07sec      ",0,716) 
        Sleep(1000)
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 06sec      ",0,716) 
        Sleep(1000)
        WinActivate("Pluto (NEW) - xxxxxx")
        BlockInput(1)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              5sec               ",0,716)
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              4sec               ",0,716)
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              3sec               ",0,716)
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              2sec               ",0,716) 
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              1sec               ",0,716) 
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "               NOW               ",0,716)
    WEnd


    While 1
        Sleep(100)
        ToolTip("abuff OFF/On = [PAGE DN]",415,695)
    WEnd
    
EndFunc


Func Terminate()
    Exit 0
EndFunc

i need it to somehow loop the buffing until it finds the color of the teleportbar and then stops the script for like 7 minutes and after that it should start over again. i.e

switch to weapon 2

use skill

use other skill

switch to weapon 1

[buffing in 10sec]

[buffing in 9sec]

[buffing in 8sec]

[buffing in 7sec]

[buffing in 6sec]

[buffing in 5sec]

[buffing in 4sec]

[buffing in 3sec]

[buffing in 2sec]

[buffing in 1sec]

[buffing now]

switch to weapon 2

use skill

use other skill

switch to weapon 1

[buffing in 10sec]

[buffing in 9sec]

[buffing in 8sec]

[buffing in 7sec]

--teleporting to town cause mp/hp/bolts low--

found color

stop script

--after 7minutes--

start script

switch to weapon 2

use skill

use other skill

switch to weapon 1

[buffing in 10sec]

[buffing in 9sec]

[buffing in 8sec]

[buffing in 7sec]

[buffing in 6sec]

[buffing in 5sec]

[buffing in 4sec]

[buffing in 3sec]

[buffing in 2sec]

[buffing in 1sec]

[buffing now]

switch to weapon 2

use skill

use other skill

switch to weapon 1

[buffing in 10sec]

[buffing in 9sec]

[buffing in 8sec]

[buffing in 7sec]

[buffing in 6sec]

[buffing in 5sec]

[buffing in 4sec]

[buffing in 3sec]

[buffing in 2sec]

[buffing in 1sec]

[buffing now]

switch to weapon 2

use skill

use other skill

switch to weapon 1

...

...

what it does in the script is it loops the buffing maybe pauses the script but it still runs like this i.e

switch to weapon 2

use skill

use other skill

switch to weapon 1

[buffing in 10sec]

[buffing in 9sec]

[buffing in 8sec]

[buffing in 7sec]

[buffing in 6sec]

[buffing in 5sec]

[buffing in 4sec]

[buffing in 3sec]

[buffing in 2sec]

[buffing in 1sec]

[buffing now]

switch to weapon 2

use skill

use other skill

switch to weapon 1

[buffing in 10sec]

[buffing in 9sec]

[buffing in 8sec]

[buffing in 7sec]

--teleporting to town cause mp/hp/bolts low--

[buffing in 6sec]

[buffing in 5sec]

[buffing in 4sec]

[buffing in 3sec]

[buffing in 2sec]

[buffing in 1sec]

[buffing now]

switch to weapon 2

use skill

use other skill

switch to weapon 1

so yeah lol i hope you understand how i mean it and sry for repeating myself but its kinda hard to explain x:

and thx for helping

Share this post


Link to post
Share on other sites



*bump* help please?

Share this post


Link to post
Share on other sites

Well, a lot of things here don't make sense to me... but this piece seems to be the part that you are complaining about:

;
While PixelGetColor(641, 990) = 0x00E794
   ExitLoop
   Sleep(420000)
   ContinueLoop
WEnd
;

The first thing you have is an ExitLoop statement... which IMMEDIATELY exits the loop... the Sleep() function is never executed.

Hope it helps,

cbruce

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Well, a lot of things here don't make sense to me... but this piece seems to be the part that you are complaining about:

;
While PixelGetColor(641, 990) = 0x00E794
   ExitLoop
   Sleep(420000)
   ContinueLoop
WEnd
;

The first thing you have is an ExitLoop statement... which IMMEDIATELY exits the loop... the Sleep() function is never executed.

Hope it helps,

cbruce

yeah i figured that the script stops working after the ExitLoop command...

i also tried to use the hotkey that starts and stops the script as a command - like this

While PixelGetColor(641, 990) = 0x00E794
   Send("{PGDN}")
   Sleep(420000)
   Send("{PGDN}")
WEnd

but i guess the only way to start a script again after it has stopped is to hit the desired hotkey in this case "PGDN" again or?

is there any other way to stop the script for like 7mins and then start it again?

and i dont know why some things dont make sense. ill try to explain it a different way.

#RequireAdmin
Global $UnPaused
HotKeySet("{PGDN}", "TogglePause")
HotKeySet("{END}", "Terminate")

this should be clear -- those are the hotkeys to start/stop and end the script

While 1
    Sleep(100)
    ToolTip("abuff OFF/On = [PAGE DN]",415,695)
WEnd

this part indicates that the script is "OFF" (Stopped/Paused)

Func TogglePause()
    $UnPaused = NOT $UnPaused

that should also be clear -- pauses the script if its running and runs the script if it paused

While $UnPaused
ToolTip("abuff ON/Off = [PAGE DN]",415,695)
        sleep(1000)
        BlockInput(1)
        Tooltip("   Changing Weapon:   " & @CRLF & " " & @CRLF & "       Cleric Rod      ",0,716)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        sleep(1000)

this is where its starting to loop till i stop the script with the hotkey.

i believe that i can delete this command "ToolTip("abuff ON/Off = [page DN]",415,695)" since it just flics up for a second.

"BlockInput(1)" is to block every keyboard input, not that i accidentaly click on the ingame chat and it enters the send commands

then it tells me in a tooltip what its doing - in this case switches to the desired weapon by trying to send the "0" key a few times because if hes fighting against some monsters and uses skills it could be that he wont switch the weapon so you could say several attempts ("0" here is the slot where i have the weapon at)

Tooltip("       Casting Skill:     " & @CRLF & " " & @CRLF & "        Bless Skill           ",0,716)
        Send("7"); Bless
        Opt("SendKeyDelay", 300)
        Send("7"); Bless
        Sleep(3000)

tells me that its now casting the skill called "Bless" 2 times with a delay of 300ms

"7" is the slot where i got the skill at

Tooltip("                " & @CRLF & "      Using MP Pot        " & @CRLF & "              ",0,716)
        Send("2"); Use Mp Potion
        Sleep(3000)

tells me in a tooltip that its using a mp potion

"2" is the slot where i got the mp potions at

Tooltip("       Casting Skill:     " & @CRLF & " " & @CRLF & "  Recovery Division   ",0,716)
        Send("8"); Recovery Division
        Opt("SendKeyDelay", 300)
        Send("8"); Recovery Division
        Opt("SendKeyDelay", 300)
        Sleep(5000)

tells me in a tooltip that its now trying to cast the skill called "Recovery Division" 2 times with a delay of 300ms

"8" is the slot where i got the skill at

Tooltip("   Changing Weapon:   " & @CRLF & " " & @CRLF & "           xBow            ",0,716)
        Send("9"); Xbow
        Opt("SendKeyDelay", 300)
        Send("9"); Xbow
        BlockInput(0)
        Sleep(3000)
        WinActivate ("Pluto (NEW) - xxxxxx")

again tells me in a tooltip that its changing the weapon. 2 attempts with a delay of 300ms

"9" is the slot where i got my fighting weapon at

"BlockInput(0)" is so i can now do other stuff again

"WinActivate ("Pluto (NEW) - xxxxxx")" is to switch to the second client (sometimes i have more than 1 client open)

Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 10sec      ",0,716)
        Sleep(1000)
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 09sec      ",0,716)
        Sleep(1000)
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 08sec      ",0,716)
        Sleep(1000)
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 07sec      ",0,716) 
        Sleep(1000)
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 06sec      ",0,716) 
        Sleep(1000)
        WinActivate("Pluto (NEW) - xxxxxx")
        BlockInput(1)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              5sec               ",0,716)
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              4sec               ",0,716)
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              3sec               ",0,716)
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              2sec               ",0,716) 
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              1sec               ",0,716) 
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "               NOW               ",0,716)
    WEnd

tells me in a tooltip how much time i got left befor it starts to buffing again (originaly it counts down from 5minutes but i made it short cause its the same progress only displays other minutes and seconds)

in the last 5 seconds it activates the first client again with "WinActivate("Pluto (NEW) - xxxxxx")"

and blocks the input of the keyboard again with "BlockInput(1)" and continues to count down

"WEnd" here is the end of the loop - so it starts again with

ToolTip("abuff ON/Off = [PAGE DN]",415,695)
        sleep(1000)
        BlockInput(1)
        Tooltip("   Changing Weapon:   " & @CRLF & " " & @CRLF & "       Cleric Rod      ",0,716)

While 1
        Sleep(100)
        ToolTip("abuff OFF/On = [PAGE DN]",415,695)
    WEnd
    
EndFunc

i think i got that in to pause/stop the script no matter where the loop is at - but looking at it now it doesnt seem to be the right command since it only tells me in a tooltip that the script is "OFF" but without it i dont think that i can pause/stop the script whenever i want to

Func Terminate()
    Exit 0
EndFunc

should be clear - if i hit the hotkey "End" it exits the script

so yeah hope its kinda clear now :S

thx for helping

Edited by darkxraver

Share this post


Link to post
Share on other sites

=(

Share this post


Link to post
Share on other sites

For $100 I will send you my buffbot.

It looks like all this does is just buff. How do you attack do you have a bot or are you hand grinding? If you are using a bot it will send you back to town every time you switch weapons using a crossbow.

Share this post


Link to post
Share on other sites

lol

yeah i use agbot and it doesnt send me back to town if i switch weapons.

it only sends me back if i die, hp/mp/bolts are low or my durability of my weapon/gear is low

and i know that in future agbot will have a autobuff option with weapon switching but it doesnt seem that a new version will come out soon

cause hes now doing stuff with agbot and multiclient (redconnector) and the news with weapon switching and buffing is now over 2 weeks old =/

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Since you dont play on the same server as me I will help you out. ;)

How does this line switch you from one client to another? It looks as if youre trying to activate the same window.

WinActivate("Pluto (NEW) - xxxxxx")

I dont use the agbot. But, you are correct. I should have been more specific if you have the go back town when no arrows checked then you will go back to town when you switch weapons. Dont you also have to also call your bolts when you change back to your xbow? I know on my xbow char I have to put the xbow and bolts in the belt.

As cbruce said take the exitloop out. What happens then?

Edited by Smiley357

Share this post


Link to post
Share on other sites

Since you dont play on the same server as me I will help you out. ;)

How does this line switch you from one client to another? It looks as if youre trying to activate the same window.

WinActivate("Pluto (NEW) - xxxxxx")

I dont use the agbot. But, you are correct. I should have been more specific if you have the go back town when no arrows checked then you will go back to town when you switch weapons. Dont you also have to also call your bolts when you change back to your xbow? I know on my xbow char I have to put the xbow and bolts in the belt.

As cbruce said take the exitloop out. What happens then?

well like i said before i sometimes use the loader (testosteron) to open up several clients so i can stall stuff or plvl other chars of mine so in order to switch fast between the clients i use the command

WinActivate("Pluto (NEW) - xxxxxx")

and yeah sry i should have been more specific here.

i didnt wanted to give my account name price so i just replaced my name with some "x's"

i only have the crossbow and the cleric rod in my belt i dont need a pack of bolts in my belt cause as soon as it changes to the xbow it automatically takes a pack of bolt from my inventory and equpits them.

and no it will not teleport back to town if it switches weapons because i still have enough bolts in my inventory

it would teleport to town if i first put the crossbow in my inventory (so that i dont have any weapons equipped) and then equip the cleric rod because then agbot would see it in that short time as "weapon durability = 0" and with "return to town if weapon durability = < 2" checked it will teleport back to town but since i switch the weapons directly by using the belt (without putting the crossbow first in my inventory) agbot still sees that i have a weapon euipped and wont port to town -- i hope you understand how i mean it :S

if i take out the exitloop then the script wont start. it will start if it finds the pixel - so that didnt work =/

i now changed the script a bit so it looks like this now

#RequireAdmin
Global $UnPaused
HotKeySet("{PGDN}", "TogglePause")
HotKeySet("{END}", "Terminate")

While 1
    Sleep(100)
    ToolTip("abuff OFF/On = [PAGE DN]",415,695)
WEnd


Func TogglePause()
    $UnPaused = NOT $UnPaused
    While $UnPaused
        
        Do 
        ToolTip("abuff ON/Off = [PAGE DN]",415,695)
        sleep(1000)
        BlockInput(1)
        Tooltip("   Changing Weapon:   " & @CRLF & " " & @CRLF & "       Cleric Rod      ",0,716)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        Opt("SendKeyDelay", 300)
        Send("0"); Cleric Rod
        sleep(1000)
        
        Tooltip("       Casting Skill:     " & @CRLF & " " & @CRLF & "        Bless Skill           ",0,716)
        Send("7"); Bless
        Opt("SendKeyDelay", 300)
        Send("7"); Bless
        Sleep(3000)
        
        Tooltip("                " & @CRLF & "      Using MP Pot        " & @CRLF & "              ",0,716)
        Send("2"); Use Mp Potion
        Sleep(3000)
        
        Tooltip("       Casting Skill:     " & @CRLF & " " & @CRLF & "  Recovery Division   ",0,716)
        Send("8"); Recovery Division
        Opt("SendKeyDelay", 300)
        Send("8"); Recovery Division
        Opt("SendKeyDelay", 300)
        Sleep(5000)
        
        Tooltip("   Changing Weapon:   " & @CRLF & " " & @CRLF & "           xBow            ",0,716)
        Send("9"); Xbow
        Opt("SendKeyDelay", 300)
        Send("9"); Xbow
        BlockInput(0)
        Sleep(3000)
        WinActivate ("Pluto (NEW) - Client 2")
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 10sec      ",0,716)
        Sleep(1000)
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 09sec      ",0,716)
        Sleep(1000)
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 08sec      ",0,716)
        Sleep(1000)
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 07sec      ",0,716) 
        Sleep(1000)
        Tooltip("     abuff Starts In:    " & @CRLF & " " & @CRLF & "     0h 00min 06sec      ",0,716) 
        Sleep(1000)
        WinActivate("Pluto (NEW) - Client 1")
        BlockInput(1)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              5sec               ",0,716)
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              4sec               ",0,716)
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              3sec               ",0,716)
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              2sec               ",0,716) 
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "              1sec               ",0,716) 
        Sleep(1000)
        Tooltip("           BUFFING        " & @CRLF & " " & @CRLF & "               NOW               ",0,716)
        Until PixelGetColor(641, 990) = 0x00E794
    
            If PixelGetColor(641, 990) = 0x00E794 Then
                Sleep(420000)
            EndIf
    
    WEnd


    While 1
        Sleep(100)
        ToolTip("abuff OFF/On = [PAGE DN]",415,695)
    WEnd
    
EndFunc


Func Terminate()
    Exit 0
EndFunc

made a do-loop until it finds the pixel color im looking for and if it finds it then it pauses the script for 7minutes after it counts down to 0 (reaches the end of the loop)

but the problem here now is that it only pauses the script if the pixel color exists the whole time - if you know what i mean :D

since the teleport-bar only exists for a few seconds it wont find it and wont pause the script

so what i need it to do is to search for the pixel color if it finds it, it should memorize that it found it (something like PixelGetColor(641, 990) = 0x00E794 = 1), do the sleep for 7minutes and start the script from the beginning

its just this little thing to make the script work like i want it to

i hope you understand what i mean

and thx for helping out =)

Share this post


Link to post
Share on other sites

Here is some code that you can test with. It works and should answer all your questions. Just remove the notepad start up and add buff stuff to it. If you have any questions just let me know.

Global $UnPaused
HotKeySet("{PGDN}", "TogglePause")
HotKeySet("{END}", "Terminate")

Run("Notepad.exe", "", @SW_MAXIMIZE)

While 1
    Sleep(100)
    ToolTip("abuff OFF/On = [PAGE DN]",415,695)
WEnd


Func TogglePause()
    $UnPaused = NOT $UnPaused
    While $UnPaused
    ToolTip("abuff ON = [PAGE DN] to pause",415,695)
    $var = PixelGetColor( 700 , 550 )
     If $var = 0xFFFFFF Then
        MsgBox(4096, "Test", "it is white", 10)
        Sleep(4000)
    EndIf
    MsgBox(4096, "Test", "im in toggle func", 10)
    WEnd

    While 1
        Sleep(100)
        ToolTip("abuff OFF = [PAGE DN] to unpause",415,695)
    WEnd
    
EndFunc


Func Terminate()
    Exit 0
EndFunc

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