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.

How to track how much i picked up of one specific item?

Featured Replies

How to track how much i picked up of one specific item? I want to kill chickens and track how many feathers i gain

How to track how much i picked up of one specific item? I want to kill chickens and track how many feathers i gain

private long feathersCollected;
private long prevInvCount;

@Override
public void onStart(){

    // initialise previous inventory count to current inventory count
    prevInvCount = getInventory().getAmount("Feather");
}

@Override
public int onLoop(){

    long invCount = getInventory().getAmount("Feather"); // get number of feathers in inventory

    // If the amount of feathers has increased, add the change to total feathers collected
    if(invCount > prevInvCount) feathersCollected += (invCount - prevInvCount);
    
    // Update previous inventory count to current count
    prevInvCount = invCount;

    ...
}

(This accounts for if you are banking, or if you are disposing of the items e.g. burying bones)

 

If you aren't banking:

private long startFeatherCount;

@Override
public void onStart(){

    startFeatherCount = getInventory().getAmount("Feather");
}

private long getFeathersCollected(){

    return getInventory().getAmount("Feather") - startFeatherCount;
}

If you want to make it so that the updating of the count is not paused by the bot's actions, you can move the code in onLoop to the onPaint method. However you should ensure that you limit the amount of times it is called per second.

Edited by Explv

  • Author
private long feathersCollected;private long prevInvCount;@Overridepublic void onStart(){    prevInvCount = getInventory().getAmount("Feather");}@Overridepublic int onLoop(){    long invCount = getInventory().getAmount("Feather");    if(invCount > prevInvCount) featherCount += (invCount - prevInvCount);    else prevInvCount = invCount;    ...}
But what about bones, if i pick them up and bury them, how would i do it then?

But what about bones, if i pick them up and bury them, how would i do it then?

 

bonesBuried = (currentXp - startXp) / boneXP

 

or

 

if(inventory.interact("Bury", "Bones")) bonesBuried++;

 

or

 

onMessage(Message m) { if(m.getMessage().contains("bury")) bonesBuried++; }} (find the correct message, and only check game messages)

Edited by FrostBug

  • Author

bonesBuried = (currentXp - startXp) / boneXP

Thats not what i meant, i know how to get how many i burried, but i want ton get how many i picked up too

Thats not what i meant, i know how to get how many i burried, but i want ton get how many i picked up too

 

Same way as the feather issue, then.

 

Thats not what i meant, i know how to get how many i burried, but i want ton get how many i picked up too

 

See the first part of the solution i posted, and substitute "Feather" for "Bones" .

I would go for the solution frostbug gave you:

onMessage(Message m) { if(m.getMessage().contains("bury")) bonesBuried++; }} (find the correct message, and only check game messages)

Since you can use the same method to track other stuff.

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.