Results 1 to 9 of 9

Thread: fail safe?

  1. #1
    Join Date
    Jul 2007
    Location
    Pluto... Maybe?
    Posts
    198
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default fail safe?

    Iv been messing around with trying to make a fail safe for my dtm to find coins.. i want it to look for the dtm and if it doesnt find it then it should search for another dtm and if it doesnt find that then logout. heres an example of what i tried:

    SCAR Code:
    Procedure FindTheCoins;
    Var
    Coins, Coins2, x, y : Integer;
    begin
      if not LoggedIn then Exit;
      Coins := DTMFromString(blablablablabla);
      Coins2 := DTMFromString(blablablablabla);
           If FindDTM(Coins, x, y, MBX1, MBY1, MBX2, MBY2) Then
           begin
           MMouse(x, y, 0, 0);
           Wait(50 + Random(50));
           if (IsUpText('Coin')) then
           GetMousePos(x, y);
          Mouse(x, y, 0, 0, False);
         ChooseOption('draw-X');
        Wait(500 + Random(600));
       TypeSend('6750');
       FreeDTM(Coins);
     If Not FindDTM(Coins, x, y, MBX1, MBY1, MBX2, MBY2) Then
      begin
       If FindDTM(Coins2, x, y, MBX1, MBY1, MBX2, MBY2) Then
      begin
            MMouse(x, y, 0, 0);
           Wait(50 + Random(50));
           if (IsUpText('Coin')) then
           GetMousePos(x, y);
          Mouse(x, y, 0, 0, False);
         ChooseOption('draw-X');
        Wait(500 + Random(600));
       TypeSend('6750');
       FreeDTM(Coins2);
       end else
         begin
           Writeln('No Coins Found!')
           Closebank;
           Logout;
         TerminateScript;
      end;
    end;

    but it doesnt seem to want to work i also tried 'if(not(finddtm ect...' and that didnt work.

  2. #2
    Join Date
    Feb 2009
    Posts
    2,155
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

    this should work idk though i didnt really test it all i did was make it a boolean


    SCAR Code:
    function FindTheCoins: boolean;
    Var
      Coins, Coins2, x, y : Integer;
    begin
      if not LoggedIn then Exit;
      Coins := DTMFromString('fadsaf');
      Coins2 := DTMFromString('fasdd');
      If FindDTM(Coins, x, y, MBX1, MBY1, MBX2, MBY2) Then
      begin
        MMouse(x, y, 0, 0);
        Wait(50 + Random(50));
        if (IsUpText('Coin')) then
        begin
          result := true;
          GetMousePos(x, y);
          Mouse(x, y, 0, 0, False);
          ChooseOption('draw-X');
          Wait(500 + Random(600));
          TypeSend('6750');
          FreeDTM(Coins);
          freedtm(coins2);// still need to free the dtm even if u dont use it
          If Not result Then
          begin
            If FindDTM(Coins2, x, y, MBX1, MBY1, MBX2, MBY2) Then
            begin
              MMouse(x, y, 0, 0);
              Wait(50 + Random(50));
              if (IsUpText('Coin')) then
              begin // adding a begin makes it so that if it doesnt find the dtm itll quit
                result := true; //and u need a begin to make it read more than 1 line below the if.. then
                GetMousePos(x, y);
                Mouse(x, y, 0, 0, False);
                ChooseOption('draw-X');
                Wait(500 + Random(600));
                TypeSend('6750');
                freedtm(coins);// again free all dtms
                FreeDTM(Coins2);
              end else
              begin
                Writeln('No Coins Found!')
                Closebank;
                Logout;
                TerminateScript;
              end;
            end;
          end;
    end;

  3. #3
    Join Date
    Feb 2007
    Posts
    3,616
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You are missing a few begins and ends in there:

    SCAR Code:
    Procedure FindTheCoins;
    Var
    Coins, Coins2, x, y : Integer;
    begin
      if not LoggedIn then Exit;
      Coins := DTMFromString(blablablablabla);
      Coins2 := DTMFromString(blablablablabla);
           If FindDTM(Coins, x, y, MBX1, MBY1, MBX2, MBY2) Then
           begin
           MMouse(x, y, 0, 0);
           Wait(50 + Random(50));
           if (IsUpText('Coin')) then
           begin //Here
           GetMousePos(x, y);
          Mouse(x, y, 0, 0, False);
         ChooseOption('draw-X');
        Wait(500 + Random(600));
       TypeSend('6750');
       FreeDTM(Coins);
           end; //Here
     If Not FindDTM(Coins, x, y, MBX1, MBY1, MBX2, MBY2) Then
      begin
       If FindDTM(Coins2, x, y, MBX1, MBY1, MBX2, MBY2) Then
      begin
            MMouse(x, y, 0, 0);
           Wait(50 + Random(50));
           if (IsUpText('Coin')) then
           begin //Here
           GetMousePos(x, y);
          Mouse(x, y, 0, 0, False);
         ChooseOption('draw-X');
        Wait(500 + Random(600));
       TypeSend('6750');
       FreeDTM(Coins2);
       end else
         begin
           Writeln('No Coins Found!')
           Closebank;
           Logout;
         TerminateScript;
         end;
      end;
    end;

    You need a begin/end after an if/then statement if doing more than one statement.

    Also, you probably just edited out the DTM, but you have to create one. blablablabla is not a DTM unless you have a global variable called that above.

  4. #4
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    SCAR Code:
    procedure FindTheCoins;
    var
    Coins, Coins2, x, y : Integer;

    begin
      if not LoggedIn then Exit;
      Coins := DTMFromString(blablablablabla);
      Coins2 := DTMFromString(blablablablabla);
      if FindDTM(Coins, X, Y, MBX1, MBY1, MBX2, MBY2) or
      FindDTM(Coins, X, Y, MBX1, MBY1, MBX2, MBY2) then
      begin
        MMouse(X, Y, 5, 5);
        if WaitUpText('oins', 150) then
        begin //Here
          GetMousePos(X, Y);
          Mouse(X, Y, 0, 0, False);
          WaitOption('draw-X', 150);
          Wait(500 + Random(600));
          TypeSend('6750');
          FreeDTM(Coins);
          FreeDTM(Coins2);
        end else
        begin
          Writeln('No Coins Found!')
          Closebank;
          Logout;
          TerminateScript;
        end;
      end else
      begin
        Writeln('No Coins Found!')
        Closebank;
        Logout;
        TerminateScript;
      end;
    end;

    Shortened a lot. Also, what's the problem you are having - the script won't compile, or won't it find the DTMs?

    Richard
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  5. #5
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Why not use FindCoins in SRL?

  6. #6
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Why not use FindCoins in SRL?
    There is such a thing?! Me looks in SRL folder...

    EDIT: I've had a look, and I can't find FindCoins. Where is it?
    Last edited by Rich; 08-29-2009 at 04:56 PM.
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  7. #7
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by R1ch View Post
    There is such a thing?! Me looks in SRL folder...

    EDIT: I've had a look, and I can't find FindCoins. Where is it?
    http://www.villavu.com/repositories/...re/Amount.scar

    In Amount.scar:

    SCAR Code:
    function FindCoins(var X, Y: Integer; Area: string): Boolean;
    var
      B: TBox;
      CTS, I, J, H, L: Integer;
      Pts, tPts: TPointArray;
      ATPA: T2DPointArray;
      V: array [0..1] of TVariantArray;
    begin
      case Lowercase(Area) of
        'inv', 'inventory': B := IntToBox(MIX1, MIY1, MIX2, MIY2);
        'bank': B := IntToBox(26, 83, 496, 292);
        'trade': B := IntToBox(323, 73, 509, 302);
        'your trade': B := IntToBox(9, 73, 196, 302);
      end;
      V[0] := [1215148, 4, 0.09, 1.32]; //Darker colour (top of coins)
      V[1] := [3590386, 8, 0.04, 1.08]; //Lighter colour (rest of the coins)
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetLength(tPts, 0);
      try
        for I := 0 to 1 do
        begin
          SetColorSpeed2Modifiers(V[I][2], V[I][3]);
          FindColorsTolerance(Pts, V[I][0], B.X1, B.Y1, B.X2, B.Y2, V[I][1]);
          if (Length(Pts) < 10) then Exit;
          ATPA := SplitTPAEx(Pts, 10, 10);
          h := High(ATPA);
          L := High(tPts) + 1;
          SetLength(tPts, L + h + 1);
          for J := 0 to H do
            tPts[L + j] := MiddleTPA(ATPA[J]);
        end;
        ATPA := SplitTPAEx(tPts, 20, 20);
        H := High(ATPA);
        for I := 0 to H do
          if (High(ATPA[I]) = 1) then
            Break;
        if (I > H) then Exit;
        Result := True;
        MiddleTPAEx(ATPA[I], X, Y);
      finally
        ColorToleranceSpeed(CTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
      end;
    end;


  8. #8
    Join Date
    Jul 2007
    Location
    Pluto... Maybe?
    Posts
    198
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for all the help and yes i did edit out the dtm its fixed now thanks to everyone

  9. #9
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by R1ch View Post
    There is such a thing?! Me looks in SRL folder...

    EDIT: I've had a look, and I can't find FindCoins. Where is it?
    http://freddy1990.com/srlmanual/index.html

    Some of the functions/procedures are outdated(I mean some of them missing or some of them don't exists any more) but still better than the broken hint list in scar 3.22

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
  •