Results 1 to 23 of 23

Thread: What am I doing wrong?[should be quick fix]

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default What am I doing wrong?[should be quick fix]

    What am i doing wrong here?

    Simba Code:
    procedure ClickNPC;
    var
      X, Y,cx,cy: Integer;
    begin     // kill npc
      WriteLn('Attacking skeleton...');
      if FindColorTolerance(X, Y, NPC, tleft, tright, bleft, bright, tolerence) then
      begin
        GetMousePos(cx,cy);
        MouseSpeed:=40;
        mmouse(x, y,1,1);
        Wait(20 + Random(50));
        ClickMouse(X, Y, Mouse_Left);
      if FindColorTolerance(x,y,65535,cx-10,cy+10,cx+10,cy-10,5) then
       begin
       ClickNPC;
       end;
        WriteLn('Attacked skeleton!');
        CheckCombat;
        end;
      end;

    Code:
    Error: Exception: You passed wrong values to a finder function: ys > ye (116,96). at line 67
    The following bitmaps were not freed: [0]

  2. #2
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Simba Code:
    if FindColorTolerance(x,y,65535,cx-10,cy-10,cx+10,cy+10,5) then

    Maybe had +s and -s wrong? Try that.

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Simba Code:
    if FindColorTolerance(x,y,65535,cx-10,cy-10,cx+10,cy+10,5) then

    Maybe had +s and -s wrong? Try that.
    what do you mean. lol

  4. #4
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Compare your line to mine.
    From the first two you need to subtract, from the last two you need to add.
    You did + - + -
    I did - - + +

  5. #5
    Join Date
    Jan 2012
    Location
    127.0.0.1
    Posts
    702
    Mentioned
    11 Post(s)
    Quoted
    76 Post(s)

    Default

    Quote Originally Posted by rjj95 View Post
    What am i doing wrong here?

    Simba Code:
    procedure ClickNPC;
    var
      X, Y,cx,cy: Integer;
    begin     // kill npc
      WriteLn('Attacking skeleton...');
      if FindColorTolerance(X, Y, NPC, tleft, tright, bleft, bright, tolerence) then
      begin
        GetMousePos(cx,cy);
        MouseSpeed:=40;
        mmouse(x, y,1,1);
        Wait(20 + Random(50));
        ClickMouse(X, Y, Mouse_Left);
      if FindColorTolerance(x,y,65535,cx-10,cy+10,cx+10,cy-10,5) then
       begin
       ClickNPC;
       end;
        WriteLn('Attacked skeleton!');
        CheckCombat;
        end;
      end;

    Code:
    Error: Exception: You passed wrong values to a finder function: ys > ye (116,96). at line 67
    The following bitmaps were not freed: [0]
    You are calling the exact same function, as it is detected the first time round, it will also be detecting the second time round . etc, henceforth you just made a endless loop there mate.

    Try doing something along the lines of this - based on your code
    Simba Code:
    if FindColorTolerance(X, Y, NPC, tleft, tright, bleft, bright, tolerence) then
      begin
        MouseSpeed:=40;
        mmouse(x, y,1,1);
        GetMousePos(cx,cy);// shifted this so it grabs the co-ords of the moved mouse position and checks in that box there
        Wait(20 + Random(50));
      if FindColorTolerance(x,y,65535,cx-10,cy+10,cx+10,cy-10,5) then
       begin
        ClickMouse(X, Y, Mouse_Left);// if colour isfound in the mousebox around the area surrounding where first colour was found, then click on that colour spot
       end;
        WriteLn('Attacked skeleton!');
        CheckCombat;
        end;

  6. #6
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Enslaved View Post
    You are calling the exact same function, as it is detected the first time round, it will also be detecting the second time round . etc, henceforth you just made a endless loop there mate.

    Try doing something along the lines of this - based on your code
    Simba Code:
    if FindColorTolerance(X, Y, NPC, tleft, tright, bleft, bright, tolerence) then
      begin
        MouseSpeed:=40;
        mmouse(x, y,1,1);
        GetMousePos(cx,cy);// shifted this so it grabs the co-ords of the moved mouse position and checks in that box there
        Wait(20 + Random(50));
      if FindColorTolerance(x,y,65535,cx-10,cy+10,cx+10,cy-10,5) then
       begin
        ClickMouse(X, Y, Mouse_Left);// if colour isfound in the mousebox around the area surrounding where first colour was found, then click on that colour spot
       end;
        WriteLn('Attacked skeleton!');
        CheckCombat;
        end;
    The whole point is a failsafe, if it misclicks the skeleton or hits a different color, it searches again

  7. #7
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    This line:
    Simba Code:
    if FindColorTolerance(x,y,65535,cx-10,cy+10,cx+10,cy-10,5) then

    Notice that you are not searching in a box starting from the top-left to the bottom-right. Instead, you are searching from the bottom-left to the top-right - Simba does not support this. The top-left should be (cx-10, cy-10), and the bottom-right should be (cx+10, cy+10). See, in your function, you did the cy+10 first, and the cy-10 second. Simply reverse these and you should be right.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  8. #8
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    This line:
    Simba Code:
    if FindColorTolerance(x,y,65535,cx-10,cy+10,cx+10,cy-10,5) then

    Notice that you are not searching in a box starting from the top-left to the bottom-right. Instead, you are searching from the bottom-left to the top-right - Simba does not support this. The top-left should be (cx-10, cy-10), and the bottom-right should be (cx+10, cy+10). See, in your function, you did the cy+10 first, and the cy-10 second. Simply reverse these and you should be right.
    How dare you re-word what I said and try and one up me!


    Rjj95, what you are doing is this:


    Searching from bottom left to top right.

    Simba only searches from top left to bottom right.
    So by switching your +s and -s around like Daniel and I have said, you will need to tell Simba the top left and bottom right coordinates of the box you wish to search, then it will work!

  9. #9
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Code:
    if FindColorTolerance(X,Y,65535,cx+10,cy+10,cx-10,cy-10,20) then
    still gives me an error lol

  10. #10
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    When you subtract a number, it becomes smaller; when you add a number, it becomes larger.
    xs, ys should be smaller than xe, ye, or else you won't have a box.
    So you should subtract xs ys and add xe ye by that variable.

  11. #11
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    When you subtract a number, it becomes smaller; when you add a number, it becomes larger.
    xs, ys should be smaller than xe, ye.
    So you should subtract xs ys and add xe ye by that constant.
    i used
    Code:
    if FindColorTolerance(X,Y,65535,cx+10,cy+10,cx,cy,20) then
    And it still gives me an error

  12. #12
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    How dare you re-word what I said and try and one up me!
    Lol, I didn't even read what you said

    Quote Originally Posted by rjj95 View Post
    i used
    Code:
    if FindColorTolerance(X,Y,65535,cx+10,cy+10,cx,cy,20) then
    And it still gives me an error
    Okay, think of it like this. You have to give it X, Y, Colour, X1, Y1, X2, Y2, Tolerance. You have given the function all of those successfully, except for the X1, Y1, X2, and Y2. Your X1 and Y1 are larger than X2 and Y2, this simply isn't allowed. X1 and Y1 always has to be smaller than X2 and Y2, and not the other way around.
    Last edited by Daniel; 11-28-2012 at 02:57 AM.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  13. #13
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by rjj95 View Post
    i used
    Code:
    if FindColorTolerance(X,Y,65535,cx+10,cy+10,cx,cy,20) then
    And it still gives me an error
    Ok, read carefully word by word of all the previous posts. You are not reading.

  14. #14
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Ok, read carefully word by word of all the previous posts. You are not reading.
    Can you give me an example?

  15. #15
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by rjj95 View Post
    Can you give me an example?
    Please re-read my edited post, above.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  16. #16
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    Please re-read my edited post, above.
    ok so now i put
    Code:
    if FindColorTolerance(X,Y,65535,cx-10,cy-10,cx+10,cy+10,20) then
    no errors, great... but now it does not work

  17. #17
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Look at my post too (#2, and the picture one).
    Simple change your line, to be like the line I posted in post #2, easy.

  18. #18
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Look at my post too (#2, and the picture one).
    Simple change your line, to be like the line I posted in post #2, easy.
    I did use it, It does not work.

    The way im testing this is, I make the mouse speed really slow so that is 99% chance not to click on it therfor showing the yellow click marks:

    Simba Code:
    procedure ClickNPC;
    var
      X, Y,cx,cy: Integer;
    begin     // kill npc
      WriteLn('Attacking skeleton...');
      if FindColorTolerance(X, Y, NPC, tleft, tright, bleft, bright, tolerence) then
      begin
        MouseSpeed:=5;
        mmouse(x, y,1,1);
        GetMousePos(cx,cy);
        ClickMouse(X, Y, Mouse_Left);
      //if FindColorTolerance(X,Y,65535,cx-10,cy-10,cx+10,cy+10,20) then
      if FindColorTolerance(x,y,65535,cx-10,cy-10,cx+10,cy+10,5) then
       begin
       WriteLn('Shit, we misclicked retrying!');
       ClickNPC;
       end else
        WriteLn('Attacked skeleton!');
        CheckCombat;
        end;
      end;



    But.. I used your method and It did not repeat the procedure like it is suposed to.

  19. #19
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Currently you are
    Looking for NPC color
    Slowly moving the mouse to it
    Once mouse is there, you are calling that point cx,cy
    Left Clicking it
    Then looking for color 65535

    Add more writeln lines and stuff to debug it and see what's going on.

    What is color 65535 anyways? And why are you moving the mouse slowly?

  20. #20
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Currently you are
    Looking for NPC color
    Slowly moving the mouse to it
    Once mouse is there, you are calling that point cx,cy
    Left Clicking it
    Then looking for color 65535

    Add more writeln lines and stuff to debug it and see what's going on.

    What is color 65535 anyways? And why are you moving the mouse slowly?
    65535 is yellow, and im moving the mouse slow for now so it misclicks the skeleton, and i was hopping the bot would see the misclick(yellow) and repeat the procedure

  21. #21
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Look up the function DidRedClick and see if that helps you out.

  22. #22
    Join Date
    Oct 2012
    Posts
    758
    Mentioned
    6 Post(s)
    Quoted
    282 Post(s)

    Default

    There's also a DidYellowClick function.

  23. #23
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Ok, So I tried using the redclick function and it works some of the time. But after it clicks the skeleton, it clicks it again and again and sometimes stops and go ons to the next procedure

    Simba Code:
    procedure ClickNPC;
    var
      X, Y,cx,cy: Integer;
    begin     // kill npc
      Wait(650 + Random(150));
      WriteLn('Attacking skeleton...');
      if FindColorTolerance(X, Y, NPC, tleft, tright, bleft, bright, tolerence) then
      begin
        MouseSpeed:=25;
        mmouse(x, y,1,1);
        ClickMouse(X, Y, Mouse_Left);
        if DidRedClick then
       begin
       WriteLn('Attacked skeleton!');
       CheckCombat;
       end else
        WriteLn('Shit, we misclicked retrying!');
        ClickNPC;
        end;
      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
  •