Results 1 to 3 of 3

Thread: Exception in Script: The given DTM Index doesn't exist

  1. #1
    Join Date
    Jan 2012
    Posts
    13
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Question Exception in Script: The given DTM Index doesn't exist [SOLVED]

    I've been lurking around the scripting tutorials for some days, and decided to try to make my own script. I have a problem though, i get this DTM error, which i could not find a solution for. Have been searching some around, and found tons of people having the same problem, but strangely no solution (might be me not looking good enough).

    Anyway, what error i get is this:
    Code:
    Exception in Script: The given DTM Index[0] doesn't exist
    The following DTMs were not freed: [1]
    The problem occurs in the below function, in the first FindDTM, between WriteLn('called');, and WriteLn('called2');. It seems that way to me at least


    Simba Code:
    function CraftAndExit: boolean;
      var
        walksDTM, clickDTM, x, y, i: integer;
        aFound: extended;
      begin
        walksDTM := DTMFromString('mrAAAAHic42BgYKhlYmBwgOJJQLwRiMOBOB2INwGxJ1' +
        'CNHxDbAXETEHtB6RYgLgXi/EwlBvkofhTcVuvN0FTlCcZyQDW8ODAHEDMSwDAAAC/WDlM=');
        wait(700 + random(90));
        WriteLn('called');
        if FindDTMRotated(walksDTM, x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) then
        begin
          WriteLn('called2');
          mouse(x, y, 1, 1, true);
          FFlag(2);
          clickDTM := DTMFromString('mlwAAAHicY2dgYOAEYiEg5mGAACYgFgBiPijmhYqB' +
          'gBwQqwGxIhAnJsaAcWhQGENQQAhDZFgUQ3x8FENychwDK1AeF2bEg6EAAKs3CG8=');
          if FindDTM(clickDTM, x, y, MSX1, MSY1, MSX2, MSY2) then
          begin
            WriteLn('called3');
            InvMouse(2, 1);
            wait(30 + random(50));
            mouse(x, y, 10, 10, true);
            FreeDTM(walksDTM);
            FreeDTM(clickDTM);
            Result := true;
            Exit;
          end;
        end;
        FreeDTM(walksDTM);
        FreeDTM(clickDTM);
      end;

    It would not hurt if i could get some suggestions for improvements in the function otherwise as well. Thanks in advance

    EDIT:
    Stupid me managed to free 'clickDTM', even in the event it was not called, had to get some help at IRC to realise it
    Last edited by Atheos; 01-29-2012 at 12:27 AM.

  2. #2
    Join Date
    Dec 2011
    Location
    Holland
    Posts
    545
    Mentioned
    0 Post(s)
    Quoted
    19 Post(s)

    Default

    You get that error because you are trying to free a DTM while it has already been freed, try deleting all "freeDTM();"s except the last two

  3. #3
    Join Date
    Jan 2012
    Posts
    13
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ah, forgot to add and end else and return false after the first Exit;, i see now.
    Thanks!

    EDIT:
    It seems to be something else, or i am just doing something wrong. This is the function now:

    Simba Code:
    function CraftAndExit: boolean;
      var
        walksDTM, clickDTM, x, y, i: integer;
        aFound: extended;
      begin
        if not LoggedIn then
        Exit;
        walksDTM := DTMFromString('mrAAAAHic42BgYKhlYmBwgOJJQLwRiMOBOB2INwGxJ1' +
        'CNHxDbAXETEHtB6RYgLgXi/EwlBvkofhTcVuvN0FTlCcZyQDW8ODAHEDMSwDAAAC/WDlM=');
        wait(700 + random(90));
        WriteLn('called');
        if FindDTMRotated(walksDTM, x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) then
        begin
          WriteLn('called2');
          mouse(x, y, 1, 1, true);
          FFlag(2);
          clickDTM := DTMFromString('mlwAAAHicY2dgYOAEYiEg5mGAACYgFgBiPijmhYqB' +
          'gBwQqwGxIhAnJsaAcWhQGENQQAhDZFgUQ3x8FENychwDK1AeF2bEg6EAAKs3CG8=');
          if FindDTM(clickDTM, x, y, MSX1, MSY1, MSX2, MSY2) then
          begin
            WriteLn('called3');
            InvMouse(2, 1);
            wait(30 + random(50));
            mouse(x, y, 10, 10, true);
           { FreeDTM(walksDTM);
            FreeDTM(clickDTM);  }

            Result := true;
            Exit;
          end else
          begin
           { FreeDTM(walksDTM);
            FreeDTM(clickDTM);  }

            Result := false;
            Exit;
          end;
        end else
        begin
          FreeDTM(walksDTM);
          FreeDTM(clickDTM);
          Result := false;
        end;
      end;

    I commented out all except the last instances of FreeDTM, and i still get the error
    Other than that i can't see how it would run through more than one instance of them anyway, if i remember correctly Exit; exits the entire funtion? If it is any help, it still gets the error at the same line as mentioned in my first post.
    Last edited by Atheos; 01-28-2012 at 10:14 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •