Results 1 to 19 of 19

Thread: Basic srl question

  1. #1
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Basic srl question

    As practice for making code and stuff, I'm making a script that uses Camelot teleport repeatedly. I have everything figured out, but I want my time between loops to be a random number between two numbers. How do I do that?
    Thanks!

  2. #2
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    You can use Wait() to wait.
    Then you need to put a number between the brackets, you want a random number between two numbers which can be achieved by using RandomRange(X, Y).
    X being the lowest number, Y being the highest number.

    Example:
    Simba Code:
    Wait(RandomRange(1000, 2000))

    Script source code available here: Github

  3. #3
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    RandomRange(MinNumber,MaxNumber)

    or MinNumber + Random(Number)

    Used like this -
    Simba Code:
    Wait(RandomRange(1000,2000));
    Wait(1000 + Random(1000));

    Both of those lines of code will wait between 1-2sec (or 1000 to 2000 milliseconds).

    EDIT: Ninja'd :P

  4. #4
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks! Also, is getting my script to detect random events(RS) difficult? I'm still very new to this.

  5. #5
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    SRL has two built in functions for finding randoms

    Simba Code:
    FindNormalRandoms;
    FindNonInventoryRandoms;

    There are some random events that can't be solved but for the most part these work really well.

  6. #6
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    So if that is my script, how would Iinsert it? I don't need it to solve, logout would be fine.
    program CamTele;

    var

    *x, y:integer;



    begin

    *repeat

    FindColorSpiralTolerance(x, y, 6102593, 674, 268, 694, 284, 10);

    **movemouse(x, y);

    **clickmouse(x, y, 1);

    **wait(randomrange(2000, 2500));

    **until(false);

    end. *******

  7. #7
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry, it copied weird. I think the stars are spaces

  8. #8
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    put something like
    Simba Code:
    if FindNormalRandoms or FindNonInventoryRandoms then
    begin
      LogOut;
      TerminateScript;
    end;

    into your mainloop or wherever (i'd recommend making a procedure instead which you then call in your mainloop).

    This will check wherever you place this for a 'normal' random or 'non-inventory' random and if they are found it will log out your player and then completely stop your script.

    Try using the 'edit' button at the bottom of your posts, saves double-posting which is a no-no on the SRL forums.

    EDIT: Steer well clear of movemouse(x, y); and clickmouse(x, y, 1); They are horribly likely to get you banned if this is for actual runescape.

    for moving the mouse use MMouse(x,y,randx,randy);
    for moving and clicking use Mouse(x,y,randx,randy,clicktype);
    and for click where your mouse already is use ClickMouse2(clicktype);

    These movements are MUCH more human-like and will avoid your impending ban by using the others.
    Last edited by P1ng; 06-22-2012 at 01:59 PM.

  9. #9
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry about that. Whenever I try procedures, I get an error saying it expects a semicolon on my main loop begin. Do you know how to fix that? Sorry for all the questions...

  10. #10
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Quote Originally Posted by Foooty View Post
    Sorry about that. Whenever I try procedures, I get an error saying it expects a semicolon on my main loop begin. Do you know how to fix that? Sorry for all the questions...
    You need to post your full script if you want to fix that, it can have multiple reasons. You probably forgot to put a ; or and end; somewhere in the procedures/functions above your mainloop.

    Script source code available here: Github

  11. #11
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    means you need to put a semicolon on the line before it so if you have

    Simba Code:
    procedure DoSomething;
    begin
      if FindSomething then
        DoThis else
      DoThisOtherThing;
    end

    begin
      DoSomething;
    end.

    That will give you an error on the begin in your mainloop, but if you look to the line above it (the one with the end on it) it doesn't have a semicolon. Put a semicolon there and it should work nicely.

    Also, if you are using SRL functions in your script don't forget to add the include and put SetupSRL; at the beginning of your mainloop.

  12. #12
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Here's my script right now, I still have to fix that moving mouse and click thing
    program CamTele;

    var

    x, y:integer;



    Procedure Teleport;

    begin

    repeat

    FindColorSpiralTolerance(x, y, 6102593, 674, 268, 694, 284, 10);

    movemouse(x, y);

    clickmouse(x, y, 1);

    wait(randomrange(2000, 2500));

    until(false);

    end



    Procedure Random

    begin

    if findnormalrandoms or findnoninventoryrandoms then

    begin

    logout;

    terminatescript;

    end

    end





    begin

    Repeat

    Teleport

    Random

    until(false);

    end.

  13. #13
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Every line you have written in that code with end on it (apart from the absolute last end) needs to have a semicolon ( at the end of it.

    every time you write an end write it like this end;

    The ONLY exception to this is the begin and end of your mainloop, which Simba already has written in for you. Your scripts mainloop will end with a full-stop (period [ . ]).

  14. #14
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Lol thanks. It's still not compiling though. It's saying findnormalrandoms is an unknown identifier. Any ideas why?

  15. #15
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Slightly edited your code to make it compile and make it do what you wanted it to do.
    Simba Code:
    program CamTele;
    {$i srl/srl.simba}

    Procedure Teleport;
    var
      x, y:integer;

    begin
      repeat
        if FindColorSpiralTolerance(x, y, 6102593, 674, 268, 694, 284, 10) then
          begin
            movemouse(x, y);
            clickmouse(x, y, 1);
            wait(randomrange(2000, 2500));
          end;
      until(false);
    end;

    Procedure Randoms;
    begin
      if findnormalrandoms or findnoninventoryrandoms then
        begin
          logout;
          terminatescript;
        end;
    end;

    begin
      Repeat
        Teleport;
        Randoms;
      until(false);
    end.

    You need to include srl.simba by using {$i srl/srl.simba}
    This basicly includes a file to Simba which has many useful stuff in it such as FindNormalRandoms.

    Let us know if you have any questions. All 'ing eachother

    Script source code available here: Github

  16. #16
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    If your script uses any SRL functions (which I highly recommend you use, they are infinitely helpful) you must include SRL.

    This means putting {$i SRL\SRL.Simba} at the beginning of your code (just after the program CamTele; line)

    Also in this include are the functions MMouse, Mouse, ClickMouse2 which I mentioned earlier, these are much more human-like and will avoid Jagex' ban system unlike your current MoveMouse and ClickMouse, I recommend you replace those with the aforementioned.

    EDIT: Haha, ninja'd again Feel free to PM myself or J J (he is a bit more experienced than I am, but for these errors we both seem to be able to help). for any further help you require.

  17. #17
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sweet, it finally compiles! Thanks so much guys! One last thing, with mouse, what do I enter for rx and ry?

  18. #18
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    they are integers for how much to randomise the x and y co-ords that your mouse will move to.

    I highly recommend this: http://villavu.com/forum/showthread.php?t=58935 for a read, it answers the issues we have already covered plus many, many more.

  19. #19
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Alright. I'll check that out. Thanks guys!

    EDIT: Everythings looking good, but I have one more question... In this script, I used findcolorspiraltolerance to pick a random pixel on the teleport button, so i wasnt always clicking the same pixel, is there a different way to pick a random pixel in an area? Because the pixels might not always be the same color.
    Last edited by Footy; 06-22-2012 at 09:09 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
  •