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.

getAmount() Problem

Featured Replies

Is there a reason why this is always return 0 or 1 (0 of there's none and 1 if there's any)

 

It's not boolean it's suppose to be integer.

inventory.getItem("Jug of water").getAmount()

Also is there a way to Face the camera to a NPC?

 

 

Thanks for the help!

Facing camera to NPC: getCamera().toEntity(NPC);

Is your jug of water noted? inventory.getItem() returns the first found item, so you could be getting an unnoted one (hence getting 1), and none should very well be 0 as there are 0 jugs.

  • Author

Facing camera to NPC: getCamera().toEntity(NPC);

Is your jug of water noted? inventory.getItem() returns the first found item, so you could be getting an unnoted one (hence getting 1), and none should very well be 0 as there are 0 jugs.

 

 

No they are not noted. I'm trying to get the number of Jug of water in my inventory.

No they are not noted. I'm trying to get the number of Jug of water in my inventory.

 

The API states that #getItem() returns a type of item. The method you want is ItemContainer#getAmount(String ... items)

 

Usage:

int amt = getInventory().getAmount("Jug of Water");
  • Author

 

The API states that #getItem() returns a type of item. The method you want is ItemContainer#getAmount(String ... items)

 

Usage:

int amt = getInventory().getAmount("Jug of Water");

 

 

Thanks it's working!

 

Also I'm having one last issue with the door.

 

My current code to handle the door is this:

        if(!myPlayer().isMoving()) {
            RS2Object largeDoor = objects.closest(new Filter<RS2Object>() {
                @Override
                public boolean match(RS2Object rs2Object) {
                    return rs2Object != null && rs2Object.getName().equals("Large door") && rs2Object.getPosition().equals(new Position(3293,3166,0));
                }
            });

            if(largeDoor != null){
                getCamera().toEntity(largeDoor);
                if(largeDoor.isVisible())
                    try {
                        largeDoor.interact("Open");
                        log("Opening the door");
                        return true;
                    }catch(Exception e){
                        log("Door is already open");
                        return false;
                    }
            }
        }

The bot isn't Facing the camera on the door and doesn't interact with it.

 

Thanks for helping me smile.png

Edited by frozen8

Thanks it's working!

 

Also I'm having one last issue with the door.

 

My current code to handle the door is this:

        if(!myPlayer().isMoving()) {
            RS2Object largeDoor = objects.closest(new Filter<RS2Object>() {
                @Override
                public boolean match(RS2Object rs2Object) {
                    return rs2Object != null && rs2Object.getName().equals("Large door") && rs2Object.getPosition().equals(new Position(3293,3166,0));
                }
            });

            if(largeDoor != null){
                getCamera().toEntity(largeDoor);
                if(largeDoor.isVisible())
                    try {
                        largeDoor.interact("Open");
                        log("Opening the door");
                        return true;
                    }catch(Exception e){
                        log("Door is already open");
                        return false;
                    }
            }
        }

The bot isn't Facing the camera on the door and doesn't interact with it.

 

Thanks for helping me smile.png

 

I don't think Camera#toEntity accepts an RS2Object as a parameter (could be wrong).

Instead, use Entity for objects and NPC for NPCs:

Entity door = getObjects().closest(new Filter<Entity>() {
 //match code
});

if (!door.isVisible()) {
    getCamera().toEntity(door);
}

if (!door.hasAction("Open")) {
    log("Door is open");
    return false;
}
door.interact("Open");
Position p = door.getPosition();
//Conditional sleep -> check objects at position p, see if they have action "Close"
log("Door should be open");
return true;

 

I don't think Camera#toEntity accepts an RS2Object as a parameter (could be wrong).

Instead, use Entity for objects and NPC for NPCs:

Entity door = getObjects().closest(new Filter<Entity>() {
 //match code
});

if (!door.isVisible()) {
    getCamera().toEntity(door);
}

if (!door.hasAction("Open")) {
    log("Door is open");
    return false;
}
door.interact("Open");
Position p = door.getPosition();
//Conditional sleep -> check objects at position p, see if they have action "Close"
log("Door should be open");
return true;
Rs2 object extends entity so it's fine lol.

@op leave it as rs2 object. Also the code seems fine. Try to see if the rs2 object is null. If it is it will explain why it doesn't interact

  • Author

I did some modifications now and it seems to be working fine.

 

Also now another minor problem :)

When I use that path:
 

    private final Position[] pathToHassan =
            {
                    new Position(3275, 3169, 0),
                    new Position(3279, 3177, 0),
                    new Position(2388, 3180, 0),
                    new Position(3291, 3172, 0),
                    new Position(3292, 3167, 0)
            };

Sometime the bot click a couple time at the same position for some weird reason.

 

I use this to go to a certain location:

localWalker.walkPath(pathToHassan);


Thanks a lot guys for helping me out so much! :)

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.