Sign in to follow this  
Followers 0
Sardith

Script help

6 posts in this topic

;Global Commands
Global $Paused = 0


;Hotkeys
HotKeySet("{F2}", "form")
HotKeySet("{F3}", "Stop")
HotKeySet("{F4}", "Terminate")


;Run Method
While 1
    If $Paused = 1 Then
     Exist()
        sleep(100)
    EndIf
    
 
ToolTip("")   
WEnd

;Main Program Funcations
Func Exist()
    If WinActive("Counter-Strike") Then
    Box1()
Else
    ToolTip("Counter-Strike not active.", 0, 0)
Sleep(2000)
ToolTip("", 0, 0)
EndIf
EndFunc

Func Box1()
   Send("2")
   $search = PixelGetColor(542, 730)
If $search = "11468800" Then
    sleep(100)
    Box2()
Else
    Box1()
EndIf
EndFunc

Func Box2()
   Send("2")
   $search = PixelGetColor(562, 730)
If $search = "11468800" Then
    Send("2")
    sleep(100)
    Box3()
Else
    Box2()
EndIf
EndFunc

Func Box3()
  Send("2")
  $search = PixelGetColor(581, 730)
If $search = "11468800" Then
    Send("2")
    sleep(100)
    Box4()
Else
    Box3()
EndIf
EndFunc

Func Box4()
  Send("2")
  $search = PixelGetColor(602, 730)
If $search = "11468800" Then
    Send("2")
    sleep(100)
    Finisher()
Else
    Box4()
EndIf
EndFunc

Func Finisher()
  $search = PixelGetColor(622, 730)
If $search <> "11468800" Then
    Sleep(100)
    Send("2")
Else
    Send("4")
    Finisher()
EndIf
EndFunc

;Exit Hotkey loop
Func Stop()
Sleep(1000)
$Paused = 0
Sleep(1000)
EndFunc

;Activates form Macro
Func form()
    If $Paused = 0 Then
        $Paused = 1
    Else
        $Paused = 0
    EndIf
EndFunc

;Hotkey exit
Func Terminate()
    Exit 0
EndFunc

I can't get this script to pause with another hotkey, or the same hot that I used. My Guess is, that the loop for finisher keeps going. This is the only real method that seemed to work for me. Searching for the different boxes.

If anyone could help me with a better way of attempting the 5 box searchs, or pausing this current configuration, that would be great.


[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Share this post


Link to post
Share on other sites



Well, this code:

;Exit Hotkey loop
Func Stop()
Sleep(1000)
$Paused = 0
Sleep(1000)
EndFunc

isn't going to stop the script, it will only pause it for 2 seconds.

Nomad :D


Share this post


Link to post
Share on other sites

Try looking at that, when

$Paused = 1 it runs,

if $Paused = 0 then it shouldn't run the funcations.


[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try looking at that, when

$Paused = 1 it runs,

if $Paused = 0 then it shouldn't run the funcations.

Since you are using recursive functions, calling functions from within a function, it will not stop running unless it returns to Exist() and returns. The $Pause will only stop it from entering the Exist() function, it will not interrupt the script once the script has started.

Understand?

Edit: Also, from the way it looks it is possible for this script to loop into infinity, meaning it may never return to the beginning.

Edited by Nomad

Share this post


Link to post
Share on other sites

Yep, I understand. Thank you.


[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Share this post


Link to post
Share on other sites

Global $Paused = 0
Global $pause


;Hotkeys
HotKeySet("{F2}", "form")
HotKeySet("{F3}", "Stop")
HotKeySet("{F4}", "Terminate")


;Run Method
While 1
    If $Paused = 1 Then
     Exist()
        sleep(100)
    EndIf
    

ToolTip("")  
WEnd

;Main Program Funcations
Func Exist()
    If WinActive("Counter-Strike") Then
    Box1()
Else
    ToolTip("Counter-Strike not active.", 0, 0)
Sleep(2000)
ToolTip("", 0, 0)
EndIf
EndFunc

Func Box1()
   Send("2")
   $search = PixelGetColor(542, 730)
If $search = "11468800" Then
    sleep(100)
    Box2()
Else
    Box1()
EndIf
EndFunc

Func Box2()
   Send("2")
   $search = PixelGetColor(562, 730)
If $search = "11468800" Then
    Send("2")
    sleep(100)
    Box3()
Else
    Box2()
EndIf
EndFunc

Func Box3()
  Send("2")
  $search = PixelGetColor(581, 730)
If $search = "11468800" Then
    Send("2")
    sleep(100)
    Box4()
Else
    Box3()
EndIf
EndFunc

Func Box4()
  Send("2")
  $search = PixelGetColor(602, 730)
If $search = "11468800" Then
    Send("2")
    sleep(100)
    Finisher()
Else
    Box4()
EndIf
EndFunc

Func Finisher()
  $search = PixelGetColor(622, 730)
If $search <> "11468800" Then
    Sleep(100)
    Send("2")
Else
    Send("4")
    Finisher()
EndIf
EndFunc

;Exit Hotkey loop
Func Stop()
$pause = Not $pause
While $pause
    Msgbox(0,"Pause","Pause")
    SleeP(300)
WEnd
EndFunc


Func form()
    If $Paused = 0 Then
        $Paused = 1
    Else
        $Paused = 0
    EndIf
EndFunc

;Hotkey exit
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