Jump to content

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


bobilly89

Recommended Posts

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)
    {
        
    }
}
 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

 

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
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.

Guest
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...