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.

Entity for players.closest

Featured Replies

Hi (again),

As soon as I put this line of code in my script, the console will get spammed with errors and the client will hang.

Entity mule = players.closest("Username");
// OR
Player mule = players.closest("Username");
// Will do the same 

 

  • Author
18 minutes ago, lrdblk said:

Post the whole script

if(mule.isVisible()) {
                    camera.toEntity(mule);
                }

            mule.interact("Trade with username");

When i put in 

players.closest("username");

At each spot where "mule" is the script just works.

22 minutes ago, Chris said:

are you null checking

No I don't.

Everytime I tested the code the mule was close to the bot itself.

 

Edited by The Undefeated

10 minutes ago, The Undefeated said:

if(mule.isVisible()) {
                    camera.toEntity(mule);
                }

            mule.interact("Trade with username");

When i put in 


players.closest("username");

At each spot where "mule" is the script just works.

No I don't.

Everytime I tested the code the mule was close to the bot itself.

 

From now on, make it a habit that you'll null check everywhere where you can imagine it could ever be null. Nullcheck and your issue is fixed :)

24 minutes ago, The Undefeated said:

if(mule.isVisible()) {
                    camera.toEntity(mule);
                }

            mule.interact("Trade with username");

When i put in 


players.closest("username");

At each spot where "mule" is the script just works.

No I don't.

Everytime I tested the code the mule was close to the bot itself.

 

try this 

Player mule = players.closest(myPlayer().getArea(10), "username");

        if (mule != null){
            if (mule.isVisible() && mule.interact("blablabla")){
                log ("mule exists!");
            }else{
                getWalking().webWalk(mule.getPosition());
                camera.toEntity(mule);
            }
        }else {
            log("Mule doesn't exist");
        }

post errors

  • Author
9 minutes ago, Eagle Scripts said:

From now on, make it a habit that you'll null check everywhere where you can imagine it could ever be null. Nullcheck and your issue is fixed :)

if(mule != null) {
                    if(!mule.isVisible()) {
                camera.toEntity(mule);
                }
                    mule.interact("Trade with Username");
                }

Not experienced with null checks at all, this is not working, can't figure out what would.

1 minute ago, The Undefeated said:

if(mule != null) {
                    if(!mule.isVisible()) {
                camera.toEntity(mule);
                }
                    mule.interact("Trade with Username");
                }

Not experienced with null checks at all, this is not working, can't figure out what would.

Please consider tackling down the basics of java before looking into OSBot Scripting. That's a way better road to follow :D

4 minutes ago, The Undefeated said:

if(mule != null) {
                    if(!mule.isVisible()) {
                camera.toEntity(mule);
                }
                    mule.interact("Trade with Username");
                }

Not experienced with null checks at all, this is not working, can't figure out what would.

look at my example...

  • Author
6 minutes ago, Eagle Scripts said:

Please consider tackling down the basics of java before looking into OSBot Scripting. That's a way better road to follow :D

I know the basics of Java pretty much besides things like null checking, as soon as I delete that piece of code with the entity the code works and afaik my null check is good (?). 

3 minutes ago, lrdblk said:

look at my example...

 

Sorry, comments coming in every minute or so.

The error is the same:

Quote

Error in script executor!

java.lang.NullPointerException

 

Edited by The Undefeated

3 minutes ago, Eagle Scripts said:

Please consider tackling down the basics of java before looking into OSBot Scripting. That's a way better road to follow :D

also, this

Edited by lrdblk

5 minutes ago, The Undefeated said:

I know the basics of Java pretty much besides things like null checking, as soon as I delete that piece of code with the entity the code works and afaik my null check is good (?). 

 

Sorry, comments coming in every minute or so.

The error is the same:

 

gonna need to see the whole script then.  there is a null somewhere in your script

  • Author
2 minutes ago, lrdblk said:

gonna need to see the whole script then.  there is a null somewhere in your script

     public void Trade() {

            if (!getBank().getWithdrawMode().equals(Bank.BankMode.WITHDRAW_NOTE)){
                getBank().enableMode(Bank.BankMode.WITHDRAW_NOTE);
            }
            if(skills.getDynamic(Skill.FLETCHING) < 5) {
                 getBank().withdrawAll(".....");	
            }
            else if(skills.getDynamic(Skill.FLETCHING) < 51) {
          		  getBank().withdrawAll(".....");
        }
            else if(skills.getDynamic(Skill.FLETCHING) < 71) {
 				getBank().withdrawAll(".....");
            }
            else if(skills.getDynamic(Skill.FLETCHING) < 86) {
           	  	getBank().withdrawAll(".....");
            }
            else if(skills.getDynamic(Skill.FLETCHING) < 100) {
                getBank().withdrawAll(".....");
            }
            getBank().close();
       
       
       if (mule != null){
                if (mule.isVisible() && mule.interact("Trade with username")){
                    log ("mule exists!");
                }else{
                    getWalking().webWalk(mule.getPosition());
                    camera.toEntity(mule);
                }
            }else {
                log("Mule doesn't exist");
            }

 

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.