Results 1 to 13 of 13

Thread: Take break procedure

  1. #1
    Join Date
    May 2015
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default Take break procedure

    Hello,

    I've been working on a procedure to make my scripts take breaks, but I keep running into an error when I try to test it.

    It keeps opening time.simba and writes this message in the debug box:
    Simba Code:
    Error: Access violation at line 456
    Execution failed.

    My code is:
    Simba Code:
    procedure takeBreak(minimum, maximum: integer);
    var
      H, M, S, HH, MM, SS, breakFor, timeLeft: integer;
      breakStartTimer: TTimeMarker;
    begin
      breakFor := gaussRangeInt(minimum * 60000, maximum * 60000);
      convertTime(breakFor, H, M, S);
      writeLn('Taking a break for: ' + toStr(H)+ 'h ' + toStr(M)+ 'm ' + toStr(S)+ 's');
      showBalloonHint('Break', 'Taking a break for: ' + toStr(H)+ 'h ' + toStr(M)+ 'm ' + toStr(S)+ 's', 3000, 0);

      if random(2) = 0 then
      begin
        players[currentPlayer].logout()
      end else
      begin
        players[currentPlayer].exitToLobby();
      end;

      breakStartTimer.start();
      repeat
        timeLeft := breakFor - breakStartTimer.getTime();
        convertTime(timeLeft, HH, MM, SS);
        writeLn('Ending break in: ' + toStr(HH)+ 'h ' + toStr(MM)+ 'm ' + toStr(SS)+ 's');
        showBalloonHint('Break', 'Ending break in: ' + toStr(HH)+ 'h ' + toStr(MM)+ 'm ' + toStr(SS)+ 's', 3000, 0);
        wait(10000 + random(5000));
      until breakFor < breakStartTimer.getTime();
      showBalloonHint('Break', 'Break completed. Loging in..', 3000, 0);
      userLogin;
      inc(breaksTaken);
    end;

  2. #2
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by Guiri View Post
    Hello,

    I've been working on a procedure to make my scripts take breaks, but I keep running into an error when I try to test it.

    It keeps opening time.simba and writes this message in the debug box:
    Can't see anything wrong with your code. When does it throw the error? During a break?

  3. #3
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    You could looks at Echo_'s break handler for help, variations of it are still widely used.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

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

    Default

    What line is line 456?
    <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
    Sep 2014
    Posts
    447
    Mentioned
    10 Post(s)
    Quoted
    203 Post(s)

    Default

    You need a semicolon after : players[currentPlayer].logout()

  6. #6
    Join Date
    May 2015
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    Can't see anything wrong with your code. When does it throw the error? During a break?
    I get the error message after the script exits me to lobby, or logs me out.

    Quote Originally Posted by yourule97 View Post
    You need a semicolon after : players[currentPlayer].logout()
    I've added it and I still get the error, It is not because of that.

    Quote Originally Posted by Rich View Post
    What line is line 456?
    Line 456 of time.simba is:
    Simba Code:
    Self.time := Self.time + (getTickCount64() - Self.__prevMark);

  7. #7
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by Guiri View Post
    I get the error message after the script exits me to lobby, or logs me out.



    I've added it and I still get the error, It is not because of that.



    Line 456 of time.simba is:
    Simba Code:
    Self.time := Self.time + (getTickCount64() - Self.__prevMark);
    Post the rest of your script?

  8. #8
    Join Date
    May 2015
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    Post the rest of your script?
    I'd prefer not releasing my script, what part are you wanting to look at?
    The function itself? How i'm calling it, etc?

  9. #9
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by Guiri View Post
    I'd prefer not releasing my script, what part are you wanting to look at?
    The function itself? How i'm calling it, etc?
    Suit yourself m8

  10. #10
    Join Date
    May 2012
    Posts
    499
    Mentioned
    23 Post(s)
    Quoted
    228 Post(s)

    Default

    Quote Originally Posted by Guiri View Post
    I'd prefer not releasing my script, what part are you wanting to look at?
    The function itself? How i'm calling it, etc?
    You could have posted the parts you didn't mind sharing, or the parts you think might be needed for us to help you.

  11. #11
    Join Date
    May 2012
    Posts
    499
    Mentioned
    23 Post(s)
    Quoted
    228 Post(s)

    Default

    On iPhone.. Try this
    Simba Code:
    breakStartTimer.start();
      repeat
       // timeLeft := breakFor - breakStartTimer.getTime();
       // convertTime(timeLeft, HH, MM, SS);
       // writeLn('Ending break in: ' + toStr(HH)+ 'h ' + toStr(MM)+ 'm ' + toStr(SS)+ 's');
      //  showBalloonHint('Break', 'Ending break in: ' + toStr(HH)+ 'h ' + toStr(MM)+ 'm ' + toStr(SS)+ 's', 3000, 0);
        wait(10000 + random(5000));
      until (breakFor < breakStartTimer.getTime()); //added brackets
     // showBalloonHint('Break', 'Break completed. Loging in..', 3000, 0);
      userLogin;
      inc(breaksTaken);

    Overall your breaking function seems way more complicated then it should be.

    Nvm, it's probably because you converted the breakfor. That isn't needed I think.
    Your breakstarttimer isn't converted either. So you cant compare those.

  12. #12
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    I had this issue with one of my scripts, make sure you're declaring players

    Forum account issues? Please send me a PM

  13. #13
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by Guiri View Post
    I'd prefer not releasing my script, what part are you wanting to look at?
    The function itself? How i'm calling it, etc?
    How do you expect us to help you if you won't post the code?
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

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
  •