Results 1 to 16 of 16

Thread: how to make procedure stop?

  1. #1
    Join Date
    Jan 2017
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default how to make procedure stop?

    I am trying to figure out how to make a procedure stop if ran for a certain amount of time.
    I tried searching forum but no luck.

    I want to do:

    if procedure has been running for xxxx time then do this :
    begin
    SomeTypeOfAction;
    end;

    any help would be much appreciated.

  2. #2
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    You say you want to make a procedure stop after a certain amount of time, but your snippet looks like you are trying to perform a procedure after a certain amount of time. Either way, take a look at simba's timer functions. You can start a global timer at the beginning of the script, and once a certain amount of time has elapsed, perform said procedure, then reset the timer, so that it will repeat the process. You could also do the same with getTimeRunning, and a condition to check it with.

    e: a lot of people do this in their scripts for breaking and such. You should download a few and skim through them to see what they did.

  3. #3
    Join Date
    Jan 2017
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    what you suggest will work. it is for a antiban I want to run on my script.
    for example if the procedure has been running for 5 minutes I want to preform something.
    since under normal circumstances the procedure would have used "exit" way before 5 minute mark.
    except the timer would have to be reset and started at the beginning of my procedure instead of the start of the script.

  4. #4
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

  5. #5
    Join Date
    Dec 2016
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by ALLINSEO View Post
    what you suggest will work. it is for a antiban I want to run on my script.
    for example if the procedure has been running for 5 minutes I want to preform something.
    since under normal circumstances the procedure would have used "exit" way before 5 minute mark.
    except the timer would have to be reset and started at the beginning of my procedure instead of the start of the script.
    So couldn't you just do something like this?

    Simba Code:
    Procedure mainLoop();
    begin
      if timeRunning > x then
      begin
        antiBan();
      end;
      \\normal procedure here
    end;

    I assume you would want to keep doing this though so you could do a timer.

    Simba Code:
    Procedure mainLoop();
    begin
      if doThis.isFinished() then
      begin
        antiBan();
        doThis.setTime(randomRange(x, y));
      end;
      \\normal procedure here
    end;

    With this second method - your only triggering your antiBan and reseting the timer if the time has already elapsed - so long as you have it within a loop there shouldn't be any problems.

    Also given how your wanting a procedure to "stop". I'm assuming your trying to break or exit out of an existing loop to perform a different procedure? If the above doesn't work to your needs using break; will get you out of your loop (repeat..until..) or exit to get out of your current procedure.
    Last edited by BlitzKrieger; 02-02-2017 at 04:40 PM.

  6. #6
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    Simba Code:
    procedure LesDoItBoiz;
    var
    thisTimer: TTimeMarker;
    money: integer;

    begin
       thisTimer.start(); //Starts your timer
       yourProcedureHere;
       yourFunctionHere;
       anotherProcedure;

    if (thisTimer.getTime() > 10000) then //if the timer is over 10 seconds then...
       repeat
          yourProcedure;
          anotherFunction;
          howMuchMoneyDoWeHave();
       until (money = 999999999) or (thistimer.getTime() > 20000); //Repeat action until desired money amount or timer exceeds 20 seconds
          thisTimer.reset();
    end;
    wrote this in the reply box so I don't know how it looks but that may be one way of doing what you are trying to do
    You have permission to steal anything I've ever made...

  7. #7
    Join Date
    Jan 2017
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Thank you when I try to use the code you provide it says "unkown type TTimeMarker" I am using SRL-5 if that helps

  8. #8
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

  9. #9
    Join Date
    Jan 2012
    Posts
    1,596
    Mentioned
    78 Post(s)
    Quoted
    826 Post(s)

    Default

    Great job everyone assuming what include he was using.

    youll probably want to use marktime() and getsystemtime() or similar funcs.

  10. #10
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

    Default

    Quote Originally Posted by Turpinator View Post
    Great job everyone assuming what include he was using.

    youll probably want to use marktime() and getsystemtime() or similar funcs.
    Great job assuming peoples assumptions!

  11. #11
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    Quote Originally Posted by Turpinator View Post
    Great job everyone assuming what include he was using.

    youll probably want to use marktime() and getsystemtime() or similar funcs.
    I'm not sure if this is actual congratulations or sarcasm but either way thanks
    You have permission to steal anything I've ever made...

  12. #12
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    Quote Originally Posted by Turpinator View Post
    Great job everyone assuming what include he was using.

    youll probably want to use marktime() and getsystemtime() or similar funcs.
    "Did you just assume my include?"

  13. #13
    Join Date
    Jan 2017
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    sorry for late reply been busy irl.

    I was able to use the help of some of the reply's and search features to get it working.
    Thanks so much for the help everyone



    what it does is basically tries to open my bank then waits till it finds the "close bank DTM" and moves to next procedure.
    If it waits longer then 5 seconds it retrys to bank instead of endless wait loop for the Bank DTM it will never find.
    this is only one use for this timer, I use this once if not multiple times in complicated scripts.


    Anyway This Is The Code I Ended Up Using For My AntiBan


    Simba Code:
    Procedure WaitForBank;
    begin
     t:= 0;

      MarkTime(t); //Makes T = 0 ms
      if not FindDTM(cbank, X, Y, 440, 0, 521, 70) then
        begin

    repeat
    if (TimeFromMark(t) > 5000) then
        begin
    AloraBank;
    exit
    end;
    wait(50);
     until FindDTM(cbank, X, Y, 440, 0, 521, 70);
     exit
     end;
     end;
    Last edited by ALLINSEO; 02-14-2017 at 04:29 AM.

  14. #14
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by ALLINSEO View Post
    sorry for late reply been busy irl.

    I was able to use the help of some of the reply's and search features to get it working.
    Thanks so much for the help everyone



    what it does is basically tries to open my bank then waits till it finds the "close bank DTM" and moves to next procedure.
    If it waits longer then 5 seconds it retrys to bank instead of endless wait loop for the Bank DTM it will never find.
    this is only one use for this timer, I use this once if not multiple times in complicated scripts.


    Anyway This Is The Code I Ended Up Using For My AntiBan


    Simba Code:
    Procedure WaitForBank;
    begin
     t:= 0;

      MarkTime(t); //Makes T = 0 ms
      if not FindDTM(cbank, X, Y, 440, 0, 521, 70) then
        begin

    repeat
    if (TimeFromMark(t) > 5000) then
        begin
    AloraBank;
    exit
    end;
    wait(50);
     until FindDTM(cbank, X, Y, 440, 0, 521, 70);
     exit
     end;
     end;
    Out of curisoity what include are you using and is this for OSRS, RS3 or RSPS?

    Edit: disregard; its for RSPS.

  15. #15
    Join Date
    Jan 2017
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    I am actually not 100% sure OSRS worked for a little but when doing certain scripts it stopped working or idk. I am relatively sure I am using the old SRL5 and pascalscript

    I have downloaded alot of SRL and only found one that was best for 317 rsps.


    Update: just checked files it is SRL5, I also have SRL6, RSPS, SRL OSR none of which worked. I would be really interested on how to get rsps SRL to work because right now I have to use DTM's and x,y coords to do anything. things like walking and such are rather difficult but not impossible.
    Last edited by ALLINSEO; 02-14-2017 at 06:16 AM. Reason: update

  16. #16
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    Quote Originally Posted by ALLINSEO View Post
    sorry for late reply been busy irl.

    I was able to use the help of some of the reply's and search features to get it working.
    Thanks so much for the help everyone



    what it does is basically tries to open my bank then waits till it finds the "close bank DTM" and moves to next procedure.
    If it waits longer then 5 seconds it retrys to bank instead of endless wait loop for the Bank DTM it will never find.
    this is only one use for this timer, I use this once if not multiple times in complicated scripts.


    Anyway This Is The Code I Ended Up Using For My AntiBan


    Simba Code:
    Procedure WaitForBank;
    begin
     t:= 0;

      MarkTime(t); //Makes T = 0 ms
      if not FindDTM(cbank, X, Y, 440, 0, 521, 70) then
        begin

    repeat
    if (TimeFromMark(t) > 5000) then
        begin
    AloraBank;
    exit
    end;
    wait(50);
     until FindDTM(cbank, X, Y, 440, 0, 521, 70);
     exit
     end;
     end;
    i feel like this wont work because you set t to 0 so when you put
    timefrommark(t) > 0
    it would be like doing
    0 > 0
    correct me if I'm wrong not sure if marktime in the include will change the value of t or if you have globally declared t as a variable
    You have permission to steal anything I've ever made...

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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