Results 1 to 7 of 7

Thread: backpack function updates (waitTime: integer = 0)

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

    Default backpack function updates (waitTime: integer = 0)

    I have not tested these so far, can test later today though. These updates are usefull when looping a banking function with presets untill backpack.isFull or empty, so you don't have to repeat random waits untill you have desired backpack.

    Simba Code:
    function TRSTabBackpack.isFull(waitTime: integer = 0): boolean;
    var
      i: integer;
      t: UInt64;
    begin
      result := false;
      t := (getTickCount64() + waitTime);

      while (not result) and (t >= getTickCount64()) do
      begin
      if (not self.open()) then
        exit(false);

      for i := BACKPACK_SLOT_LOW to BACKPACK_SLOT_HIGH do
        if (not (self.isItemInSlot(i))) then
          exit(false);

      result := true;
      wait(randomRange(20, 50));
      end;
    end;

    Simba Code:
    function TRSTabBackpack.isEmpty(waitTime: integer = 0): boolean;
    var
      b: tbox;
      t: UInt64;
    begin
      result := false;
      t := (getTickCount64() + waitTime);

      while (not result) and (t >= getTickCount64()) do
      begin
          if (not self.open()) then
        exit(false);

      b := self.getBounds();
      b.edit(0, 0, 0, -30);

      result := (not b.colorExists(ITEM_OUTLINE_BLACK)) and (not b.colorExists(ITEM_OUTLINE_BLACK_SECONDARY)) and
                  (not b.colorExists(ITEM_OUTLINE_WHITE));
        wait(randomRange(20, 50));
      end;
    end;

    Simba Code:
    function TRSTabBackpack.isItemInSlot(slot: integer; waitTime: integer = 0): boolean;
    var
      t: UInt64;
    begin
      result := false;
      t := (getTickCount64() + waitTime);

      while (not result) and (t >= getTickCount64()) do
      begin
        if (not self.open()) or (not self.isSlotValid(slot))then
        exit(false);

      result := isItemIn(self.getSlotBox(slot));
        wait(randomRange(20, 50));
      end;
    end;

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

    Default

    If someone could test these please? For some reason I'm unable to spawn a SMART client currently...

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

    Default

    @Clarity
    Do you have any clue why these functions are so much slower then the regular/non modified?

    Seems to work just fine on desktop though. If anyone else tests these im sure they can be pushed!

    Banking function:
    Simba Code:
    function banking(preset: integer): Boolean;
    begin
      if (not isLoggedIn()) then
        exit(False);
      FailTimer.start();
      begin
        repeat
          if bankscreen.open(BANK_GE) then
            break();
          wait(gaussRangeInt(100, 500));
          minimap.clickCompass();
          if (FailTimer.getTime() > TIMEOUT) or (not isLoggedIn()) then
            exit(False);
        until bankScreen.isOpen(5000) or pinscreen.isOpen();
        if pinScreen.isOpen() then
          pinScreen.enter(players[currentPlayer].bankPin);
        repeat
          if bankScreen.clickButton(preset) then
            exit(True);
          wait(gaussRangeInt(100, 500));
        until (FailTimer.getTime() > TIMEOUT) or (not isLoggedIn());
      end;
    end;

    Part in mainloop:
    Simba Code:
    repeat
        if banking(BANK_BUTTON_PRESET_1) and (not tabBackpack.isFull()) then
          failCount := failCount + 1;
        if (FailCount > 4) then
        begin
          writeLn('Failed withdrawing, shutting down');
          players[currentPlayer].logout();
          terminateScript();
        end;
        if (not isLoggedIn()) or (FailTimer.getTime() > TIMEOUT) then
          exit;
      until tabBackpack.isFull(15000);

  4. #4
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Hey

    These are cool snippets! If I am reading your intentions correctly, however, you should be made aware of the waitFunc() method that can be used for any function returning a boolean.

    It will continually run the desired function with the desired wait period in between runs. It will wait until the desired function returns true, with a desired timeout.

    For example...
    Simba Code:
    waitTypeFunc(@tabBackpack.isFull, 100, 10000);
    ...will run tabBackpack.isFull every 100ms until 10000ms has elapsed.

    You need to use a "@" before the desired function, and waitTypeFunc() if using a type function.
    Last edited by Clarity; 04-15-2015 at 07:53 PM.

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

    Default

    @Clarity
    Holy! I did not know that! Screw them repeat random waits until!

    You mention waitfunc and waittypefunc, what is the difference? What is a typefunc?

  6. #6
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Quote Originally Posted by lovebotter View Post
    @Clarity
    Holy! I did not know that! Screw them repeat random waits until!

    You mention waitfunc and waittypefunc, what is the difference? What is a typefunc?
    No problem Making those snippets were still good practice I'm sure!

    A normal function:
    Simba Code:
    function hiHelloThere(): boolean;
    A type function:
    Simba Code:
    function greetingPhrase.hiHelloThere(): boolean;

    So something like tabBackpack.isFull() is a type function, with the type being tabBackpack.

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

    Default

    Quote Originally Posted by Clarity View Post
    No problem Making those snippets were still good practice I'm sure!

    A normal function:
    Simba Code:
    function hiHelloThere(): boolean;
    A type function:
    Simba Code:
    function greetingPhrase.hiHelloThere(): boolean;

    So something like tabBackpack.isFull() is a type function, with the type being tabBackpack.
    Thanks, my script seems to run flawless now!
    Will also be usefull for my portable well vials script. Updating that tomorrow.

    @Clarity
    It seems to crash if I use this, resulting in an error given at the includes (forgot to copy paste);
    Simba Code:
    until waitTypeFunc(@tabBackpack.isItemInSlot(1), 100, 5000);

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
  •