Results 1 to 6 of 6

Thread: DTM issue

  1. #1
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default DTM issue

    Hey so this is my first script using DTMs. Basically it withdraws a Steel Med Helm, Rune Dagger, and Gold Ring from my bank and wears them.


    Simba Code:
    program New;
    {$i srl/srl.scar}

    function EquipGear: boolean;
    var
      RuneDagger, SteelMedHelm, GoldRing, x, y:integer;
    begin
    RuneDagger := DTMFromString('mlwAAAHicY2dgYMhmhuACIM4C4lQgzgTiOCDuZWRgmAjEHUDcCcSTgXgKEC8GYjvvAKBuJhwYN2DEgZEAAI2+B+Q=');
    SteelMedHelm := DTMFromString('mbQAAAHicY2VgYHBggmA/IHYFYjMgvg8Uvw7Ez4D4ExC/AOLstDQgyYSGMQEjFgwGACndBxM=');
    GoldRing := DTMFromString('mbQAAAHicY2VgYNjOzMCwE4j3AfEWIF4PxP2MDAw9QDwdiGcD8UQg3rlAGqiaCQ1jAkYsGAwAoCIICg==');
        if FindDTM(RuneDagger, x, y, MSX1, MSY1, MSX2, MSY2) then
        begin
          Mouse(x, y, 4, 4, true)
          if FindDTM(SteelMedHelm, x, y, MSX1, MSY1, MSX2, MSY2) then
          begin
            Mouse(x, y, 4, 4, true);
            if FindDTM(GoldRing, x, y, MSX1, MSY1, MSY2, MSX2) then
            begin
              Mouse(x, y, 4, 4, true);
              CloseWindow;
              wait(1000+random(400));
              GameTab(tab_inv);
              wait(2000+random(1000));
              if FindDTM(RuneDagger, x, y, MIX1, MIY1, MIX2, MIY2) then
              begin
                Mouse(x, y, 4, 4, true);
                if FindDTM(SteelMedHelm, x, y, MIX1, MIY1, MIX2, MIY2) then
                  begin
                    Mouse(x, y, 4, 4, true);
                    if FindDTM(GoldRing, x, y, MIX1, MIY1, MIX2, MIY2) then
                      Mouse(x, y, 4, 4, true);
                    result := true
                    end;
                  end;
                end;
              end;
            FreeDTM(RuneDagger);
            FreeDTM(SteelMedHelm);
            FreeDTM(GoldRing);
          end;




    begin
      setupSRL;
      Wait(1000+random(2000));
      EquipGear;
    end.


    It withdraws the items from my bank and closes the bank screen perfectly fine, but won't equip the items. Could someone please tell me where my error is?

    Thanks
    Last edited by Nebula; 12-18-2011 at 06:48 PM.

  2. #2
    Join Date
    Nov 2011
    Posts
    1,268
    Mentioned
    17 Post(s)
    Quoted
    217 Post(s)

    Default

    It doesn't find your DTM and since it is in a If..then statement, it doesn't do the clicking and doesn't check for the 2nd and third item.

    Try making the DTM global vars, and adding procedure to load DTM and procedure to free DTM outside of the if..then clauses, you could had made it a procedure EquipGear; instead of function EquipGear; since you are telling it to do stuff not to find out something.

    Your first mouse is missing this part Mouse(x, y, 4, 4, True);

    What I would do in this case is place all 3 items in inventory, open up DTM editor, load DTM from string, just paste into the pop pup this code

    Item := DTMFromString('this code');

    everything inside the '' but not including the '', it should load your DTM, then click Image > show matching DTM, it should look at your whole screen for the matching DTM and put an "x" over it, if it doesn't appear then your DTM is off, I would suggest remaking it or modifying the Tolerance on it since Items often have diff colors in inv than in bank and if all your tolerances are 0, it has very low chance of finding the item if it changed colors

    Simba Code:
    program New;
    {$i srl/srl.scar}

    var
      RuneDagger, SteelMedHelm, GoldRing, x, y:integer;// Vars are now global vars, this is recommended to avoid problems

    procedure EquipGear; //If you want it do do something, make it a procedure.
    begin
      RuneDagger := DTMFromString('mlwAAAHicY2dgYMhmhuACIM4C4lQgzgTiOCDuZWRgmAjEHUDcCcSTgXgKEC8GYjvvAKBuJhwYN2DEgZEAAI2+B+Q=');
      SteelMedHelm := DTMFromString('mbQAAAHicY2VgYHBggmA/IHYFYjMgvg8Uvw7Ez4D4ExC/AOLstDQgyYSGMQEjFgwGACndBxM=');
      GoldRing := DTMFromString('mbQAAAHicY2VgYNjOzMCwE4j3AfEWIF4PxP2MDAw9QDwdiGcD8UQg3rlAGqiaCQ1jAkYsGAwAoCIICg==');
        if FindDTM(RuneDagger, x, y, MSX1, MSY1, MSX2, MSY2) then
          Mouse(x, y, 4, 4, true);
        if FindDTM(SteelMedHelm, x, y, MSX1, MSY1, MSX2, MSY2) then
          Mouse(x, y, 4, 4, true);
        if FindDTM(GoldRing, x, y, MSX1, MSY1, MSY2, MSX2) then
          Mouse(x, y, 4, 4, true);//Don't add begin end if you only doing 1 action, your code would have done the following 10+ lines if the Gold Ring is in the bank in the above step because begin/end; wrap around everything in between them.
        CloseWindow;//Since these are no longer arround begin/end; they are no longer conditional and that is important because you want these to happen 100% of the times I suppose
        wait(1000 + random(400));
        GameTab(tab_inv);
        wait(2000 + random(1000));//Added a few spaces for standards and readability, there is a tutorial on standards on this site, might be worth your time to look at it sometime in the future
        if FindDTM(RuneDagger, x, y, MIX1, MIY1, MIX2, MIY2) then
          Mouse(x, y, 4, 4, true);//Note I removed the begins since they are only needed when doing more than 1 action.
        if FindDTM(SteelMedHelm, x, y, MIX1, MIY1, MIX2, MIY2) then
          Mouse(x, y, 4, 4, true);
        if FindDTM(GoldRing, x, y, MIX1, MIY1, MIX2, MIY2) then
          Mouse(x, y, 4, 4, true);
        //result := true is no longer needed, only need something like this for functions
        //Also since begins are gone, ends are not needed, leaving them in will return error
        FreeDTM(RuneDagger);
        FreeDTM(SteelMedHelm);
        FreeDTM(GoldRing); // this is good you free the DTMs correctly =)
    end; //End for the begining of the procedure
    begin
      setupSRL;
      Wait(1000+random(2000));
      EquipGear;
    end.

    See if these few fixes help but just replacing this for your code is not enough, you got to make sure to learn from your mistakes so that you can grow as a scripter =) I left some comments so you understand what I did, good luck

    Just loaded your DTM and indeed all the tolerances are set to 0, Tolerance is a number telling the client how off an exact color can the colors of the DTM be, I usually use 15 but since you using the boundary method, your first point which is the mother point should have 255 Tol instead of zero, that will allow your item to be recognized both on the inv and in the bank.

    You have:


    You should have:


    Redo your DTMs and make the top point in the list 255 Tol and it should work, always remember to add Tolerance to your DTMs =)

    P.S. Good luck with your first script
    Last edited by DemiseScythe; 12-18-2011 at 07:16 PM. Reason: Added stuff =)
    GLH Tutorial ~ OpenGL Scripting
    http://villavu.com/forum/showthread.php?p=1292150

    GLH Scripts ~ Abyssal Scripts
    http://villavu.com/forum/showthread.php?p=1293187
    Current Projects:
    A) DemiseSlayer Pro (Released/100%).
    B) Demise Power Miner(Released/100%).
    C) Demise Pyramid Plunder(Planning Stage/0%).

  3. #3
    Join Date
    Sep 2010
    Location
    Finland
    Posts
    299
    Mentioned
    8 Post(s)
    Quoted
    37 Post(s)

    Default

    I corrected your code Nebula. You were missing some ends and I also corrected the standards. This piece of code looks very nice.

    Just remember that for every begin there's a end;

    Simba Code:
    program New;
    {$i srl/srl.scar}

    function EquipGear: boolean;
    var
      RuneDagger, SteelMedHelm, GoldRing, x, y:integer;
    begin
      RuneDagger := DTMFromString('mlwAAAHicY2dgYMhmhuACIM4C4lQgzgTiOCDuZWRgmAjEHUDcCcSTgXgKEC8GYjvvAKBuJhwYN2DEgZEAAI2+B+Q=');
      SteelMedHelm := DTMFromString('mbQAAAHicY2VgYHBggmA/IHYFYjMgvg8Uvw7Ez4D4ExC/AOLstDQgyYSGMQEjFgwGACndBxM=');
      GoldRing := DTMFromString('mbQAAAHicY2VgYNjOzMCwE4j3AfEWIF4PxP2MDAw9QDwdiGcD8UQg3rlAGqiaCQ1jAkYsGAwAoCIICg==');
      if FindDTM(RuneDagger, x, y, MSX1, MSY1, MSX2, MSY2) then
      begin
        Mouse(x, y, 4, 4, true)
        if FindDTM(SteelMedHelm, x, y, MSX1, MSY1, MSX2, MSY2) then
        begin
          Mouse(x, y, 4, 4, true);
          if FindDTM(GoldRing, x, y, MSX1, MSY1, MSY2, MSX2) then
          begin
            Mouse(x, y, 4, 4, true);
            CloseWindow;
            wait(1000+random(400));
            GameTab(tab_inv);
            wait(2000+random(1000));
            if FindDTM(RuneDagger, x, y, MIX1, MIY1, MIX2, MIY2) then
            begin
              Mouse(x, y, 4, 4, true);
              if FindDTM(SteelMedHelm, x, y, MIX1, MIY1, MIX2, MIY2) then
              begin
                Mouse(x, y, 4, 4, true);
                if FindDTM(GoldRing, x, y, MIX1, MIY1, MIX2, MIY2) then
                begin
                  Mouse(x, y, 4, 4, true);
                  result := true
                end;
              end;
            end;
          end;
          FreeDTM(RuneDagger);
          FreeDTM(SteelMedHelm);
          FreeDTM(GoldRing);
        end;
      end;
    end;


    begin
      setupSRL;
      Wait(1000+random(2000));
      EquipGear;
    end.

    Quote Originally Posted by DemiseScythe View Post
    It doesn't find your DTM and since it is in a If..then statement, it doesn't do the clicking and doesn't check for the 2nd and third item.
    Yes it does click.
    Here is (small)part of my script, and it works just fine. It finds a DTM on bankscreen (MBX1,...) then moves the mouse to location of it and checks for uptext, if uptext check is true then it will click it.
    Simba Code:
    if (FindDTM(Item.rDTM, x, y, MBX1, MBY1, MBX2, MBY2)) then // Searches the DTM at bankscreen
    begin //If DTM was found
      MMouse(x, y, 5, 5); //Moves mouse to it

      if WaitUpTextMulti(Item.rUpText, 700 + Random(140)) then //Checks for uptext
      begin
        Mouse(x, y, 5, 5, False); //Clicks it with right mouse button
        Wait(RandomRange(350, 500));
      end;
      // Code continues here...
    Rusting away

  4. #4
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    Thanks a lot Demise I got my script working perfectly
    +rep

  5. #5
    Join Date
    Nov 2011
    Posts
    1,268
    Mentioned
    17 Post(s)
    Quoted
    217 Post(s)

    Default

    Quote Originally Posted by Smidqe View Post
    Yes it does click.
    Here is (small)part of my script, and it works just fine. It finds a DTM on bankscreen (MBX1,...) then moves the mouse to location of it and checks for uptext, if uptext check is true then it will click it.
    Never said it didn't click, you can have all the begin and end; you want in your script as long as you have 1 end; for every begin. I was just simply stating that the problem was that the points to be click were not found and that was due to the Tolerance on the DTMs he was using being set at 0.

    By fixing the Tolerance in his DTM strings, the client can now find his items in the Inventory and then proceed to click[Equip] them.

    I did not correct every single standard so he could notice where he was deviating from them and to preserve the originality of his code.

    I hope you don't take this wrong. No harm intended in my words, just explaining myself.
    GLH Tutorial ~ OpenGL Scripting
    http://villavu.com/forum/showthread.php?p=1292150

    GLH Scripts ~ Abyssal Scripts
    http://villavu.com/forum/showthread.php?p=1293187
    Current Projects:
    A) DemiseSlayer Pro (Released/100%).
    B) Demise Power Miner(Released/100%).
    C) Demise Pyramid Plunder(Planning Stage/0%).

  6. #6
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Kinda busy at the moment, so no time to read the full problem.

    BUT, you could shorten your code with something like this
    Simba Code:
    function EquipItems: boolean;
    var
      DTMs: Array [0..2] of Integer; // a list containing 3 integers, with indexes 0, 1 and 2
      i, x, y, EquippedItems: Integer;
    begin
      if (not LoggedIn) then
        Exit;
      GameTab(TAB_INV);
      DTMs[0] := DTMFromString('mlwAAAHicY2dgYMhmhuACIM4C4lQgzgTiOCDuZWRgmAjEHUDcCcSTgXgKEC8GYjvvAKBuJhwYN2DEgZEAAI2+B+Q=');
      DTMs[1] := DTMFromString('mbQAAAHicY2VgYHBggmA/IHYFYjMgvg8Uvw7Ez4D4ExC/AOLstDQgyYSGMQEjFgwGACndBxM=');
      DTMs[2] := DTMFromString('mbQAAAHicY2VgYNjOzMCwE4j3AfEWIF4PxP2MDAw9QDwdiGcD8UQg3rlAGqiaCQ1jAkYsGAwAoCIICg==');

      for i := 0 to 2 do
        if FindDTM(DTMs[i], x, y, MIX1, MIY1, MIX2, MIY2) then
        begin
          Mouse(x, y, 5, 5, True);
          Wait(1000 + random(400));
          Inc(EquippedItems);
        end else
          Break; // Will exit if even one of the items was not found
     
      for i := 0 to 2 do // Free all the DTMs after the equipping
        FreeDTM(DTMs[i]);

      Result := (EquippedItems = 3); Only results True if all 3 items were equipped
    end;

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
  •