Sign in to follow this  
Followers 0
Barks

Help! My script is giving me an error and I don't know why.

3 posts in this topic

Hi, I'm running a modified version of Zarox's facebook pets script. I have it almost in working order but it keeps giving me the same error about one of my arrays and I am not sure why. I am relatively new to scripting so I may just be missing something obvious. If anyone can help me out, I would be most appreciative.

The error I am getting is:

-----

$enemylevel = StringLeft ($array1[3],2)

$enemylevel = StringLeft (^ ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

-----

Here is my code:

HotKeySet("{ESC}", "Terminate")
$PressButton1 = True
$firefox = WinActivate("Pet Me - Mozilla Firefox")
If $firefox = 0 Then
    Exit 0
Else
    While True
        MouseClick("left",392,1032,1)
        If $PressButton1 Then
            MouseClick("left", 570, 295, 1); Click Kill Monsters
            Sleep(2000)
            MouseClick("left", 807, 609, 1); Click Evade
            Sleep(2000)
            $PressButton1 = False;
        EndIf
        ClipPut( "" )
        WinActivate("Pet Me - Mozilla Firefox")
        Sleep(250)
        Send ( "^a" )
        Sleep(250)
        Send ( "^c" )
        $paste = ClipGet ()
        $array1 = StringSplit ($paste,'Level ',1)
        $enemylevel = StringLeft ($array1[3],2)
        $yourlevel = StringLeft ($array1[4],2)
        $almost = StringTrimLeft ($array1[2],3)
        $enemytype = StringLen($almost)
        $enemytype = Int($enemytype)
        $enemylevel = Int($enemylevel)
        $yourlevel = Int($yourlevel)        
        If $enemytype = 10 And $enemylevel+3 <= $yourlevel Then ;+2 = fight things 2 levels lower than you
            MouseClick("left", 718, 637, 1); Click Fight
            MouseClick("left", 764, 566, 125); Click Attack/Defend
            Sleep(2000)
            MouseClick("left", 572, 230, 20); Click Feed
            Sleep(1000)
            MouseClick("left", 572, 230, 20); Click Feed
            Sleep(1000)
            $PressButton1 = True; Starts It Over
        ElseIf $enemytype = 16 And $enemylevel+3 <= $yourlevel Then
            MouseClick("left", 718, 637, 1); Click Fight
            MouseClick("left", 764, 566, 125); Click Attack/Defend
            Sleep(2000)
            MouseClick("left", 572, 230, 20); Click Feed
            Sleep(1000)
            MouseClick("left", 572, 230, 20); Click Feed
            Sleep(1000)
            $PressButton1 = True; Starts It Over
        ElseIf $enemytype = 20 And $enemylevel+4 <= $yourlevel Then
            MouseClick("left", 718, 637, 1); Click Fightbeta
            MouseClick("left", 764, 566, 150); Click Attack/Defend
            Sleep(2000)
            MouseClick("left", 572, 230, 20); Click Feed
            Sleep(1000)
            MouseClick("left", 572, 230, 20); Click Feed
            Sleep(1000)
            $PressButton1 = True; Starts It Over
        Else
            MouseClick("left", 804, 641, 1); Click Evade
            Sleep(1000)
        EndIf
    WEnd
EndIf

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

I've read some posts on this error but I still haven't come across anything that helps. To my understanding, I haven't set an incorrect number of subscripts and the dimension of the variable should be right. Thanks in advance for the help.

Share this post


Link to post
Share on other sites



Larry's saying there's a timing problem with your code. I know I've had to add a Sleep() in order to make something similar work for me. See if this fixes the problem.

Send ( "^c" )
Sleep(100)
$paste = ClipGet ()

If not then I'm not sure how Larry would suggest correcting the problem.

Share this post


Link to post
Share on other sites

Wow. Thank you guys. That was so simple and it fixed it right up.

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