Results 1 to 9 of 9

Thread: Bank.scar CloseBank;

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

    Default Bank.scar CloseBank;

    I just noticed it seemed unnecessarily long.

    The two functions have less than a 5 ms difference in speed I just figured I would post for the criticism and explanations.

    SRL's:
    SCAR Code:
    {*******************************************************************************
    function CloseBank: Boolean;
    By: Starblaster100
    Description: Closes the bank window - Tries twice before exiting
    *******************************************************************************}

    function CloseBank: Boolean;
    var
      i, Timer: Integer;
    begin
      Result := False;
      if BankScreen then
      begin
        Timer := GetTimeRunning + 8000;
        repeat
          Mouse(483, 28, 10, 12, True);
          for i := 0 to 30 do
          begin
            if not BankScreen then
            begin
              Result:= True;
              Break;
            end;
            Wait(100);
          end;
          Wait(Random(100));
        until (GetTimeRunning > Timer) or Result;
      end;
    end;

    Mine:
    SCAR Code:
    function N_CloseBank: Boolean;
    var
      t: Integer;
    begin
      if not BankScreen then
        Exit;
      t := GetTimeRunning + 8000;
      repeat
        Mouse(483, 28, 10, 12, True);
        while (BankScreen) and (GetTimeRunning < (t / 2)) do
          Wait(100);
        Result := not BankScreen;
      until(Result) or (GetTimeRunning > t);
    end;
    Last edited by NCDS; 06-23-2010 at 10:20 PM.

  2. #2
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The for-to-do loop that you've omitted is actually extremely useful and effective. It accounts for slower computers or just general server lag. Often times, the bank screen will still be detected after Wait(100).

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

    Default

    Quote Originally Posted by bbri06 View Post
    The for-to-do loop that you've omitted is actually extremely useful and effective. It accounts for slower computers or just general server lag. Often times, the bank screen will still be detected after Wait(100).
    That's what the repeat..until is for.

    It uses the same basic method as the other one, just less lines really.

    There, that should fix any lag problems now as well.
    Last edited by NCDS; 06-23-2010 at 10:19 PM.

  4. #4
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Well if we really wanted to shorten it:

    Code:
    function CloseBank: Boolean;
    begin
      Result := CloseWindow;
    end;
    /end

    E:
    Does the same thing.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

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

    Default

    Quote Originally Posted by Narcle View Post
    Well if we really wanted to shorten it:

    Code:
    function CloseBank: Boolean;
    begin
      Result := CloseWindow;
    end;
    /end
    lol yeah, that works. I had assumed there was a reason for CloseBank; Apparently not?

  6. #6
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Narcle View Post
    Well if we really wanted to shorten it:

    Code:
    function CloseBank: Boolean;
    begin
      Result := CloseWindow;
    end;
    /end

    E:
    Does the same thing.
    Wouldn't work because CloseWindow calls CloseBank right off the bat. You'd have to modify CloseWindow. But either way, it's pointless to have two. This will be one of the many good things about SRL 5.

    @NCDS: I'm not going to commit it, someone else might though. Since CloseBank and CloseWindow are working fine right now, I'm not going to change it. But you have brought to my attention this for SRL 5, so thanks.
    Last edited by Coh3n; 06-23-2010 at 10:36 PM.

  7. #7
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Wouldn't work because CloseWindow calls CloseBank right off the bat. You'd have to modify CloseWindow. But either way, it's pointless to have two. This will be one of the many good things about SRL 5.

    @NCDS: I'm not going to commit it, someone else might though. Since CloseBank and CloseWindow are working fine right now, I'm not going to change it. But you have brought to my attention this for SRL 5, so thanks.
    Yeah I thought it might of. The system is there tho... just have to add it in. Its kind of redundant now that we have it.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

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

    Default

    Quote Originally Posted by Coh3n View Post
    @NCDS: I'm not going to commit it, someone else might though. Since CloseBank and CloseWindow are working fine right now, I'm not going to change it. But you have brought to my attention this for SRL 5, so thanks.
    That's fine man, I just noticed it was abnormally long and figured I would bring it to the peoples attention.

  9. #9
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    That's fine man, I just noticed it was abnormally long and figured I would bring it to the peoples attention.
    Yeah, I'm sure there's a lot of that in SRL.

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
  •