Page 1 of 2 12 LastLast
Results 1 to 25 of 49

Thread: Need help with key pressing and if else statments

  1. #1
    Join Date
    Mar 2007
    Posts
    732
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Need help with key pressing and if else statments

    hey ok i have no real experiance with scar programing but ive done other languages so im just kinda patching stuff ive found in the premade files that come with scar together to build my own auto fighter for a moded version of runescape 1.

    ok so i have a if color found click on it, but now i need to make it do something if those monsters colors were not found. what would i use to do that? and also i need the script to press the left and right buttons to look around the map to find more monsters if it still cant find them.

    heres what i got so far..
    SCAR Code:
    program GoblenKiller;
    var
      x, y: Integer;
    begin
      repeat
        if(FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then
        begin
          MoveMouse(x, y);
          ClickMouse(x, y, True);
          Wait(500);
        end;
        if(FindColorTolerance(x, y, 9666382, 1, 1, 350, 320, 25))then
        begin
          MoveMouse(x, y);
          ClickMouse(x, y, True);
          Wait(500);
        end;
        if(FindColorTolerance(x, y, 4208674, 1, 1, 350, 320, 25))then
        begin
          MoveMouse(x, y);
          ClickMouse(x, y, True);
          Wait(500);
        end;
        if(FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then
        begin
          MoveMouse(x, y);
          ClickMouse(x, y, True);
          Wait(500);
        end;
      until(False)
    end.

    you know what i suck at programing scar so maby just rewrite anything you want to make it better.. thanks!
    oh yeah btw, in old runescape you cant retreat before 3 turns of fighting, and id kill these guys so fast that it dosnt matter that you keep clicking around while your fighting.

  2. #2
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    program GoblenKiller;
    {.include srl/srl.scar}
    var
      x, y: Integer;

    procedure kill;
    begin
      repeat
        if(FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then
        begin
          MMouse(x,y,2,2,true);
          Wait(500+random(500));
        end;
        if(FindColorTolerance(x, y, 9666382, 1, 1, 350, 320, 25))then
        begin
          MMouse(x,y,2,2,true);
          Wait(500+random(500));
        end;
        if(FindColorTolerance(x, y, 4208674, 1, 1, 350, 320, 25))then
        begin
          MMouse(x,y,2,2,true);
          Wait(500+random(500));
        end;
        if(FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then
        begin
          MMouse(x,y,2,2,true);
          Wait(500+random(500));
        end;
    end;

    begin
    setupsrl;
    kill;
    until(False);
    end.

    idk if theres anything else you want.. that will click the color if it finds it.. but it will click every half a second..

  3. #3
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Forgot a repeat ^ and if you want it to click, use Mouse(x, y, 3, 3, true);
    The 3's are the randomness of the click.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  4. #4
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yeah I noticed :P

    thanks

  5. #5
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Look into 'else'. It makes it so that if something doesnt work out it will do what you put after 'else'.

    SCAR Code:
    program GoblenKiller;
    var
      x, y: Integer;
    begin
      if ( not( LoggedIn)) then// Failsafe
      exit;// exits the procedure
      repeat
        if not (FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then
        if not (FindColorTolerance(x, y, 9666382, 1, 1, 350, 320, 25))then
        if not (FindColorTolerance(x, y, 4208674, 1, 1, 350, 320, 25))then
        if not (FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then
        begin
          MMouse( x, y, 1, 1);// the 1's are like a pixel tolerance
          Mouse(x, y, 1, 1, True);//same here
          Wait( RandomRange( 500, 1000);// Makes the wait time random between 500 and 1000 MS
        end;
    end.

    MMouse = less detectable way to move the mouse

    Mouse = less detectable way to click the mouse

  6. #6
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    MMouse moves and clicks?

    doesn't it?

  7. #7
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    No, that's Mouse. :P.

    ~Sandstorm

  8. #8
    Join Date
    Mar 2008
    Location
    New Jersey
    Posts
    1,673
    Mentioned
    1 Post(s)
    Quoted
    9 Post(s)

    Default

    N C D S, you forgot until();

    also you would wanna add FindNormalRandoms; after your repeat along with other spots you think you might get a random.

  9. #9
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Mouse moves and clicks?

    I'm dumb..



    baked I think he said this was for rsc.. they don't have the randoms that rs2 uses

  10. #10
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    oops

    SCAR Code:
    program GoblenKiller;
    var
      x, y: Integer;
    begin
      if ( not( LoggedIn)) then// Failsafe
      exit;// exits the procedure
      repeat
        if not (FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then
        if not (FindColorTolerance(x, y, 9666382, 1, 1, 350, 320, 25))then
        if not (FindColorTolerance(x, y, 4208674, 1, 1, 350, 320, 25))then
        if not (FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then
        begin
          MMouse( x, y, 1, 1);// the 1's are like a pixel tolerance
          Mouse(x, y, 1, 1, True);//same here
          Wait( RandomRange( 500, 1000);// Makes the wait time random between 500 and 1000 MS
        end;
      until(False);// you should try and avoid endless loops like this aswell
    end.

    If this is really for RSC then the:
    SCAR Code:
    if ( not( LoggedIn)) then
    Exit;
    may not work, IM not sure about RSC ive never scripted for that before.

  11. #11
    Join Date
    Mar 2007
    Posts
    732
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh k thanks guys :] now how about that pressing left and right so i can move the camera to look for more monsters? and as i said before this isnt for runescape its for a moded version of runescape clasic so some of those functions probably wont work, it dosnt have to be snazzy or anything cause clasic dosnt have any autobanning i dont think.. just you know something that will work haha thanks

  12. #12
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    SCAR Code:
    MakeCompass('Set your angle here');

  13. #13
    Join Date
    Mar 2007
    Posts
    732
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i dono how to use that MakeCompass('Set your angle here'); function... cant you just tell me how to send right and left keys? remember i know nothing of the scar or srl language

  14. #14
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    ok so in your script when you want it to change angles put:
    SCAR Code:
    MakeCompass('N');
    'N' clearly means North.
    Other Valid Arguments would be:
    'S' (south)
    'E' (east)
    'W' (west)
    'an angle number' ex.(45, 90, 180, etc.)

    better?

  15. #15
    Join Date
    Mar 2007
    Posts
    732
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh k thanks :]

  16. #16
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by oo00o View Post
    oh k thanks :]
    No problem, feel free to PM me if you need anything else!

  17. #17
    Join Date
    Mar 2007
    Posts
    732
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok, and those if not(colorcheck) then, translated into english means if this color is not found then... correct? so thats what i would use to check if the monsters were around or not. so i should probably do the check, then if they are found then do the if (colorcheck) then click thing.. haha yeah im confuseing. lol

  18. #18
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    lol yeah you lost me so I will just explain it for you.

    SCAR Code:
    program GoblenKiller;
    var
      x, y: Integer;
    begin
      if ( not( LoggedIn)) then// Failsafe
      exit;// exits the procedure
      repeat
        if not (FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then//if it doesnt find this one
        if not (FindColorTolerance(x, y, 9666382, 1, 1, 350, 320, 25))then //it will search for this one
        if not (FindColorTolerance(x, y, 4208674, 1, 1, 350, 320, 25))then// then this one
        if FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25)then//then this one
        begin
          MMouse( x, y, 1, 1);// the 1's are like a pixel tolerance
          Mouse(x, y, 1, 1, True);//same here
          Wait( RandomRange( 500, 1000);// Makes the wait time random between 500 and 1000 MS
        end else // if it doesnt find any of the monster colors
        WriteLn(' did not find monster, logging out'); //then it will say this on Scar
        TerminateScript;// then end the script
        Exit;  
      until(False);// you should try and avoid endless loops like this aswell
    end.


    Read all the Green

  19. #19
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    the pixel tolerance that he's talking about is that, for example..

    if the color is at 426, 254; it will go to + or - one pixel for the x coord and y coord.. it's just anti ban (looks more realistic to jagex..)

  20. #20
    Join Date
    Mar 2007
    Posts
    732
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    NCDS your program gave me an error =[ lol thanks for trying though

    Failed when compiling
    Line 5: [Error] (5:11): Unknown identifier 'LoggedIn' in script

  21. #21
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    SCAR Code:
    program GoblenKiller;
    {.include srl/srl.scar}

    var
      x, y: Integer;
    begin
      activateclient;//puts rs window on top after you use crosshairs on it
      setupsrl;//allows you to use srl functions and procedures
      if ( not( LoggedIn)) then// Failsafe
      exit;// exits the procedure
      repeat
        if not (FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then//if it doesnt find this one
        if not (FindColorTolerance(x, y, 9666382, 1, 1, 350, 320, 25))then //it will search for this one
        if not (FindColorTolerance(x, y, 4208674, 1, 1, 350, 320, 25))then// then this one
        if FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25)then//then this one
        begin
          MMouse( x, y, 1, 1);// the 1's are like a pixel tolerance
          Mouse(x, y, 1, 1, True);//same here
          Wait( RandomRange( 500, 1000);// Makes the wait time random between 500 and 1000 MS
        end else // if it doesnt find any of the monster colors
        WriteLn(' did not find monster, logging out'); //then it will say this on Scar
        Logout;
        TerminateScript;// then end the script
        Exit;  
      until(False);// you should try and avoid endless loops like this aswell
    end.

  22. #22
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Use what mormonman just posted.
    I thought you had already new about that part already, sorry.

  23. #23
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    program GoblenKiller;
    {.include srl/srl.scar}
     
    var
      x, y: Integer;
    begin
      activateclient;//puts rs window on top after you use crosshairs on it
      setupsrl;//allows you to use srl functions and procedures
      if ( not( LoggedIn)) then// Failsafe
      exit;// exits the procedure
      repeat
        if not (FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then//if it doesnt find this one
        if not (FindColorTolerance(x, y, 9666382, 1, 1, 350, 320, 25))then //it will search for this one
        if not (FindColorTolerance(x, y, 4208674, 1, 1, 350, 320, 25))then// then this one
        if FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25)then//then this one
        begin
          MMouse( x, y, 1, 1);// the 1's are like a pixel tolerance
          Mouse(x, y, 1, 1, True);//same here
          Wait( RandomRange( 500, 1000));// Makes the wait time random between 500 and 1000 MS
        end else // if it doesnt find any of the monster colors
        WriteLn(' did not find monster, logging out'); //then it will say this on Scar
        Logout;
        TerminateScript;// then end the script
        Exit;  
      until(False);// you should try and avoid endless loops like this aswell
    end.

    fixed..

  24. #24
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by 99_ View Post
    SCAR Code:
    program GoblenKiller;
    {.include srl/srl.scar}
     
    var
      x, y: Integer;
    begin
      activateclient;//puts rs window on top after you use crosshairs on it
      setupsrl;//allows you to use srl functions and procedures
      if ( not( LoggedIn)) then// Failsafe
      exit;// exits the procedure
      repeat
        if not (FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25))then//if it doesnt find this one
        if not (FindColorTolerance(x, y, 9666382, 1, 1, 350, 320, 25))then //it will search for this one
        if not (FindColorTolerance(x, y, 4208674, 1, 1, 350, 320, 25))then// then this one
        if FindColorTolerance(x, y, 251224, 1, 1, 350, 320, 25)then//then this one
        begin
          MMouse( x, y, 1, 1);// the 1's are like a pixel tolerance
          Mouse(x, y, 1, 1, True);//same here
          Wait( RandomRange( 500, 1000));// Makes the wait time random between 500 and 1000 MS
        end else // if it doesnt find any of the monster colors
        WriteLn(' did not find monster, logging out'); //then it will say this on Scar
        Logout;
        TerminateScript;// then end the script
        Exit;  
      until(False);// you should try and avoid endless loops like this aswell
    end.

    fixed..
    isnt that the same thing mormonman just posted?? lol

  25. #25
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    no.. he was missing an end to randomrange.. lol took me awhile to see it

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Pressing two keys simultaneously.
    By enig.ma in forum OSR Help
    Replies: 2
    Last Post: 12-25-2007, 07:07 PM
  2. Replies: 5
    Last Post: 12-09-2007, 10:20 PM

Posting Permissions

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