Jump to content

Timer sleep until if


Recommended Posts

Hey guys.

Heres my code whats wrong and how do i add to it

Func CreateGame()
    Local $starttime = _Timer_Init()
    If _Timer_Diff($starttime) >= 60000; 60 seconds
        $Message = "were creating a game now!"
    Chat()
    Stats()

    MouseClick("left", 640, 485)
    Sleep($ClickDelay)

    $GameLength = Random(10, 15)
    $PassLength = Random(10, 15)

    For $x2 = 0 To $GameLength
        $Random = Random(97, 122)
        Send(Chr($Random))
    Next

    Sleep($KeyDelay)
    Send("{TAB}")
    Sleep($KeyDelay)

    For $x3 = 0 To $PassLength
        $Random = Random(97, 122)
        Send(Chr($Random))
    Next

    Sleep($KeyDelay)
    Send("{ENTER}")
    Sleep($KeyDelay)

    $GamesMade = $GamesMade + 1
    Stats()
    FileWriteLine($File, "Made Game: " & @HOUR & ":" & @MIN & "." & @MDAY & "/" & @MON & "/" & @YEAR & @LF)
    Sleep(3000)
    CheckIngameact1()
EndFunc  ;==>CreateGame

OK from what i think, i have it to start the timer, then if the timer is 60 seconds, it will start it.

Heres what i need to do

A) Restart the timer every gamecreate

^_^ After it completes its circlet then goes back to Func CreateGame() It will sleep until the timer = 60.

How and whats wrong :S

Link to comment
Share on other sites

What do you want it to do, what is it not doing and what have you tried so far?

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Local variables are destroyed when you exit the function.

Func CreateGame()
    Local $starttime = _Timer_Init()

Try stripping the "local" off of that statement and parking a

Global $starttime

at the top of your script.

Er... You need to move that "TimerInit" or your "TimerDiff" somewhere else.

It's never going to hit 60000 if the preceding statement just set it to 0.

Maybe put...

Global $starttime = _Timer_Init

at the top of your script.

And, have your function begin like...

If _Timer_Diff($starttime) >= 60000 Then; 60 seconds
        $Message = "were creating a game now!"
        $starttime = _Timer_Init
    Endif
Edited by Spiff59
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...