Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Method not functioning.

Featured Replies

Yo i'm trying to organize my script a bit so i have made multiple classes. There is a class for banking with the method doBank and a constructor that takes the item and the bank location.

But this is where the problem starts. When i call my constructor and fill in the parameters everything seems to work till he actually calls the method do bank. There bank will always be null and i cant seem to get it to not be null.

I have tried a ton of things and when i call the method from the same class everything seems to work. So am i making mistakes in my parameters ? This is the code:

This part is in my banking class.

	Area bankingArea;
    String itemToWithdraw;


public void doBbank() throws InterruptedException {



       if (bankingArea.contains(myPlayer())) {   //here is where the error shows in the logger when i start the script bankking area = null, ive tried doing 
						//	if(bankingArea == null) { (log"Bank is null")} but everything still crashes
           getWalking().webWalk(bankingArea);
       }
       else if (!getBank().isOpen()) {
           getBank().open();
           new ConditionalSleep(5000, 500) {
               @Override
               public boolean condition() throws InterruptedException {
                   return getBank().isOpen();
               }
           }.sleep();
       }
       else if (!getInventory().isEmpty()) {
           getBank().depositAll(); }

           if (getBank().contains(itemToWithdraw) && !getInventory().contains(itemToWithdraw)) {
           getBank().withdraw(itemToWithdraw, 1);
       } else {
           log("bank does not contain " + itemToWithdraw + " Ending script.");
           stop(false); //stopping script
       }

    }


    public Banking(String itemToWithdraw, Area bankingArea) {

        this.itemToWithdraw = itemToWithdraw;
        this.bankingArea = bankingArea;


    }
}

i have tried passing multiple parameters for the bank but nothing seems to work. 

This is in my mining script.
        Banking banking = new Banking(pickaxe,faladorEastBank);


        if (!getInventory().contains(pickaxe)){
            banking.doBbank(); } //here is the error

I had a method in my mining class which is as good as the same as the one in my banking class and that works fine. But i wane use my banking class for multiple scripts so id like to figure out how to get it to work. Any help is appreciated. 

since you're calling 'myPlayer()' in the Banking class, I assume it extends MethodProvider?

In that case you'll need to exchange bot contexts with it before you can access the MethodProvider methods

  • Author
12 minutes ago, Vilius said:

No need to check if an area contains anything, when the area is null.

rollsafe.gif

Nullcheck the area, then do the contains call.

I have tried adding before the contains call, if( bankingArea != null) { run code } else { log("bankingArea equals null") } but that didnt seem to change anything. The script still crashed and the client froze. 

9 minutes ago, FrostBug said:

since you're calling 'myPlayer()' in the Banking class, I assume it extends MethodProvider?

In that case you'll need to exchange bot contexts with it before you can access the MethodProvider methods

My banking class extends Scripts not MethodeProvider. Is this where the error is ? it has an onloop since otherwise everything was abstract but that onloop just just empty. 

Edit changed it to extend MethodeProvider instead of script but it still gives the same error. 

Edited by zwaffel

4 minutes ago, zwaffel said:

I have tried adding before the contains call, if( bankingArea != null) { run code } else { log("bankingArea equals null") } but that didnt seem to change anything. The script still crashed and the client froze. 

My banking class extends Scripts not MethodeProvider. Is this where the error is ? it has an onloop since otherwise everything was abstract but that onloop just just empty. 

You should not have multiple Script classes in a script project. Tho the actual error is the same, since Script extends methodprovider as well.
You should extend MethodProvider and call exchangeContext on your Banking instance

If you want to take a more organised approach why not an abstract task based system?

  • Author
42 minutes ago, FrostBug said:

You should not have multiple Script classes in a script project. Tho the actual error is the same, since Script extends methodprovider as well.
You should extend MethodProvider and call exchangeContext on your Banking instance

Adding 

banking.exchangeContext(getBot()); 

worked like a charm. Thank you! 

 

27 minutes ago, 01053 said:

If you want to take a more organised approach why not an abstract task based system?

I wasn't able to implement any abstract methods probably cos i don't know enough about them yet. 

edit: if i misinterpreted this and you mean a task system with a case than id prefer just a clean if else system in my onloop. 

Edited by zwaffel

I may be wrong but,

 

Quote

 if (bankingArea.contains(myPlayer())) {   //here is where the error shows in the logger when i start the script bankking area = null, ive tried doing 
						//	if(bankingArea == null) { (log"Bank is null")} but everything still crashes
           getWalking().webWalk(bankingArea);
       }

Shouldn't that first line be if (!bankingAre.contains(myPlayer()))) {

getWalking.webWalk(bankingArea);

 

?

  • Author
11 hours ago, m3JS said:

I may be wrong but,

 

Shouldn't that first line be if (!bankingAre.contains(myPlayer()))) {

getWalking.webWalk(bankingArea);

 

?

Nah it works fine there are only 3 bracers that open so only need 3 to close adding the 4th ) would trow an error. 

5 hours ago, zwaffel said:

Nah it works fine there are only 3 bracers that open so only need 3 to close adding the 4th ) would trow an error. 

I know that, I was referencing the if statement, your saying if the bank contains my player, then walk to bank. 

 if (bankingArea.contains(myPlayer())) {   //here is where the error shows in the logger when i start the script bankking area = null, ive tried doing 
						//	if(bankingArea == null) { (log"Bank is null")} but everything still crashes
           getWalking().webWalk(bankingArea);
       }

 

What I suggested was saying if bank does NOT contain my player.

Quote

(!bankingAre.contains(myPlayer())) {

getWalking.webWalk(bankingArea);

 

 

  • Author
30 minutes ago, m3JS said:

I know that, I was referencing the if statement, your saying if the bank contains my player, then walk to bank. 


 if (bankingArea.contains(myPlayer())) {   //here is where the error shows in the logger when i start the script bankking area = null, ive tried doing 
						//	if(bankingArea == null) { (log"Bank is null")} but everything still crashes
           getWalking().webWalk(bankingArea);
       }

 

What I suggested was saying if bank does NOT contain my player.

 

Oh ye that was a typo. Problem was that bank always was null but has been resolved by FrostBug.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.