Jump to content

Problem with boolean conditions in while loop (trade script)


Recommended Posts


   If (im not in the bank) {
       go there 
       } else if (im in the bank) {
                 if (I have finished banking) {
                         if (im not in trade) {
                             if (mule is here) {
                                if (2nd trade screen open) {
                                    accept trade
                                    } else if (2nd trade screen isn't open) {
                                              if (im in trade with mule) {
                                                  if (other player is mule) {
                                                     if (our offer contains coins) {
                                                        accept trade
                                                        } else if (our offer doesn't contain coins) {
                                                                  offer all coins
                                                     } else if (other player isn't mule) {
                                                               decline trade
                                                  } else if (im not in trade with mule) {
                                                            interact trade with mule
                                } else if (mule isn't here) {
                                           if (mule has been launched) {
                                               } else if (mule has not been launched) {
                                                          get mule
                                                          mule has been launched
                         }else if (I haven't finished banking) {
                               if (The bank isn't open) {
                                   open the bank
                                   } else if (The bank is open) {
                                              if (the bank contains coins) {
                                                  withdraw coins
                                                  } else if (the bank doesn't contain coins) {
                                                            close bank
                                                            I have finished banking


    private void bank(boolean banked, boolean launched) throws IOException, InterruptedException {

        banked = false;
        launched = false;
        log ("banking finished: " + banked);
        log ("banking finished: " + launched);
        while (!banked && !launched) {
            log("starting bank&mule..");
            if (!Banks.VARROCK_WEST.contains(myPosition())) {
                log("Walking to muling location");
            } else if (Banks.VARROCK_WEST.contains(myPosition())) {
                log("We're at muling location");
                if (banked = true) {
                    if (!trade.isCurrentlyTrading()) {
                        if (getPlayers().closest(mule) != null && getPlayers().closest(mule).interact("Trade with.")) {
                            if (!trade.isSecondInterfaceOpen()) {
                                if (trade.isCurrentlyTrading()) {
                                    if (trade.getOtherPlayer().equals(mule)) {
                                        if (trade.getOurOffers().contains("Coins")) {
                                            log("Accepting trade");
                                        } else if (!trade.getOurOffers().contains("Coins")) {
                                            log("Offering coins");

                                    } else if (!trade.getOtherPlayer().equals(mule)) {
                                        log("Trading the wrong player, declining");

                                } else if (!trade.isCurrentlyTrading()) {
                                    log ("Trying to trade with: " + mule);
                                    getPlayers().closest(mule).interact("Trade with.");
                            } else if (!trade.isSecondInterfaceOpen()) {
                                log ("Accepting second trade");
                        } else if (getPlayers().closest(mule) != null && !getPlayers().closest(mule).interact("Trade with")) {
                            if (launched) {
                                log("Waiting for mule..");
                                sleep(random(500, 5000));
                            } else if (!launched) {
                                log("Launching mule from server");
                                launched = true;
                } else if (banked = false) {
                    log("banking completed: " + banked);
                    if (!getBank().isOpen()) {
                        log("Opening bank");
                    } else if (getBank().isOpen()) {
                        if (getBank().contains("Coins")) {
                            log("Withdrawing coins");
                            banked = true;


The bot just sits idle in the bank while the logger goes like this:




I made my own booleans because I don't think I could use any of the ones in the OSbot API like getInventory().contains("Coins") would get it done properly. The bot might have coins in its inventory already and then it would never get the ones that might be in the bank. I want the script to first bank, then launch the mule, wait for it to log in, then trade it the coins when it appears. 

Any help to let me fix this script would be very appreciated! :)


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...