Jump to content

Super easy fix(Im a noob) Player doesn't interact with the bank


Recommended Posts

Posted

My script has the player collect wood then he goes to the bank area to place it in the bank. He just stands in the bank area and never accomplishes anything. Help is appreciated :D. Im having trouble near the //bank section

 

 

package Woodcutter;

import java.awt.Graphics;
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import com.google.common.util.concurrent.Service.State;

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.api.Bank;
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.script.MethodProvider;
@ScriptManifest(author = "Me", info = "Chops willows", name = "woodcutter", version = 0.1, logo = "")
public class Woodcutter extends Script
{
    final Area BANK_AREA = new Area(3168,3492,3161,3487);
    final Area TREE_AREA = new Area(3150,3464,3172,3450);
    final int BANK_BOOTH_ID = 5453;
    final String Tree_Name = "Tree";
            public void onStart()
            {
    
            }
        public void onExit()
            {
    
            }
    //code in loop
    public int onLoop()
    {
        Inventory inven = getInventory();
        Player player = getObjects().myPlayer();
        Bank bank = getObjects().getBank();
    if(!inven.isFull())
    {
            //chop
            if(TREE_AREA.contains(player))
            {
            RS2Object willow =  getObjects().closest(Tree_Name);
            
            if(willow != null)
            {
                if (willow.isVisible()) {
                    if (!player.isAnimating()) {
                        if (!player.isMoving()) {
                            willow.interact("Chop down");
                            
                        }
                    }
                } else {
                    getCamera().toEntity(willow);
                }
                   
            }
            }else{
                getWalking().webWalk(TREE_AREA);
            }
            
            
            }else{
                // bank
                if (BANK_AREA.contains(player)) {
                
                    RS2Object bankbooth =  getObjects().closest(BANK_BOOTH_ID, 5454, 5455, 5456);
                    
                    
                    
                    if (bank.isOpen()) {
                        bank.depositAll(1511);
                        bank.depositAll();
                    } else {
                        if (bankbooth != null) {
                            if (bankbooth.isVisible()) {
                                bankbooth.interact("Bank");
                                
                            }else{
                                getCamera().toEntity(bankbooth);
                            }
                        }
                    }

                } else {
                    getWalking().webWalk(BANK_AREA);
                }
            }
        return 50;
    }//end int onloop
    
    
    //paint
    public void onPaint(Graphics g)
    {
        
    }
}
 

Posted (edited)

First of all, don't use ID's as it can change when RS is updated. This also accounts for items as I see you're using ID's everywhere.

Second, the API has bank areas already so you don't need to define them yourself.

Area bankArea = Banks.YOUR_BANK;

Next do something similar to this (might want to use sleep):

if (getWalking().webWalk(bankArea)) {
  if (!getBank().isOpen()) {
    RS2Object bankbooth =  getObjects().closest("Bank booth);

    if (bankbooth != null && bankbooth.hasAction("Bank")) {
       bankbooth.interact("Bank");
    }
  }
}

Btw, use code tags so we can read your code more easily

Edited by lisabe96
Posted (edited)

First of all, don't use ID's as it can change when RS is updated. This also accounts for items as I see you're using ID's everywhere.

Second, the API has bank areas already so you don't need to define them yourself.

Area bankArea = Banks.YOUR_BANK;

Next do something similar to this (might want to use sleep):

if (getWalking().webWalk(bankArea)) {
  if (!getBank().isOpen()) {
    RS2Object bankbooth =  getObjects().closest("Bank booth);

    if (bankbooth != null && bankbooth.hasAction("Bank")) {
       bankbooth.interact("Bank");
    }
  }
}

Btw, use code tags so we can read your code more easily

 

Thank you. How do i use the sleep method? I was having trouble with it and ended up giving up on it. :|

Edited by bobilly89
Posted (edited)

First of all, don't use ID's as it can change when RS is updated. This also accounts for items as I see you're using ID's everywhere.

Second, the API has bank areas already so you don't need to define them yourself.

Area bankArea = Banks.YOUR_BANK;

Next do something similar to this (might want to use sleep):

if (getWalking().webWalk(bankArea)) {
  if (!getBank().isOpen()) {
    RS2Object bankbooth =  getObjects().closest("Bank booth);

    if (bankbooth != null && bankbooth.hasAction("Bank")) {
       bankbooth.interact("Bank");
    }
  }
}

Btw, use code tags so we can read your code more easily

Depending where you are banking keep in mind there are some bank booths that are closed, I think there is also one in Draynor bank that is sitting inside the bank. opposite the bankers that can't be used and it's named "Bank booth". I'd recommend grabbing objects around you and filtering them based on name such as "Bank booth" and checking to ensure the object has an action, in this case that action being "Bank". This will prevent your script attempting to interact with a booth that you can't actually use.

 

Thank you. How do i use the sleep method? I was having trouble with it and ended up giving up on it. :|

 

Regular old sleep: 

sleep(random(150, 200));

Above code will sleep for a random time between 150 and 200 ms.

 

Conditional sleep:

new ConditionalSleep(Script.random(725, 925), 20) {
@Override
   public boolean condition() throws InterruptedException {
      return getBank().isOpen();
   }
}.sleep();

Above code will sleep for a random time between 725 and 925 ms. However, every 20 ms the boolean will be evaluated and if true the sleep will end.

Edited by Molly
Posted

 

Depending where you are banking keep in mind there are some bank booths that are closed, I think there is also one in Draynor bank that is sitting inside the bank. opposite the bankers that can't be used and it's named "Bank booth". I'd recommend grabbing objects around you and filtering them based on name such as "Bank booth" and checking to ensure the object has an action, in this case that action being "Bank". This will prevent your script attempting to interact with a booth that you can't actually use.

 

This, that's why I added action checking in my code.

I ran into this problem at draynor where it wanted to bank with the "bank booth" that isn't a bank :p

  • Like 1
Posted (edited)

This, that's why I added action checking in my code.

I ran into this problem at draynor where it wanted to bank with the "bank booth" that isn't a bank tongue.png

Yeah, I found that out as well long ago when I wrote my thieving script. Trying to bank at Draynor and was wondering why it wasn't banking lol. I only pointed it out because the snippet you posted doesn't filter, it just checks that the object has the action prior to interacting. Theoretically if you walk into the bank and grab a booth

getObjects.closest("Bank booth")

you could end up continuously grabbing the same booth and thus would never interact with it if it didn't have the option. Resulting in the script just endlessly looping.

Edited by Molly
Posted (edited)

Yeah, I found that out as well long ago when I wrote my thieving script. Trying to bank at Draynor and was wondering why it wasn't banking lol. I only pointed it out because the snippet you posted doesn't filter, it just checks that the object has the action prior to interacting. Theoretically if you walk into the bank and grab a booth

getObjects.closest("Bank booth")

you could end up continuously grabbing the same booth and thus would never interact with it if it didn't have the option. Resulting in the script just endlessly looping.

True when I post what I use I get lambda-lovers on my back tongue.png

RS2Object booth = null;

for (RS2Object obj : getObjects().getAll()) {
  if (bankArea.contains(obj) && obj.getName().equalsIgnoreCase("Bank booth")) {
    if (obj.hasAction("Bank")) {
      if (booth == null || getMap().distance(booth) > getMap().distance(obj)) {
        booth = obj;
      }
    }
  }
}
if (booth == null) {
  log("Error, no bank booth found to use.");
  //Return
}
booth.interact("Bank");
Edited by lisabe96

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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