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.

Checking if Xp has been gained In past (X) milliseconds

Featured Replies

Method

public boolean IsGainingXp (int CheckTime)
    {
        int XpChange;
        int CurrentXp = getSkills().getTotalExperience();
        try {
            sleep(CheckTime);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        int LaterXp = getSkills().getTotalExperience();
        XpChange = LaterXp-CurrentXp;

        if(XpChange>0) {
            return true;
        }
        else return false;
    }

Example of use

while (IsGainingXp(3000)==true)
{
    log ("we have gained xp in the past 3 seconds");
}

log ("we stopped gaining xp");

 

Sorry if this is useless but I couldn't use a check for animations so I made this to see if I gained XP recently. If someone has a better way please post.

Edited by mikehamz

Hmm

You might not want to block execution.

You could create a global variable which keeps track of the current XP. Then you can make your check to see if your new XP is greater the the current. If it is, then just set your current XP to your new XP.

 

Also:

while(test() == true)
  
// is equivalent to
  
while(test())

 

  • Author
56 minutes ago, dreameo said:

Hmm

You might not want to block execution.

You could create a global variable which keeps track of the current XP. Then you can make your check to see if your new XP is greater the the current. If it is, then just set your current XP to your new XP.

 

Also:


while(test() == true)
  
// is equivalent to
  
while(test())

 

It is actually funny you post here because I saw your comment that I thought was really good that didn't block execution for checking idle time with animations, but it was after I had made this.

Quote

 private boolean idleFor(int millis){

        if(myPlayer().isAnimating())
        {
            timeSinceAnimation = System.currentTimeMillis();
        }
        else
        {
            timeSinceIdle = System.currentTimeMillis();
        }

        return timeSinceAnimation + millis < timeSinceIdle;
    }

Would editing your method to something like this work for checking Xp in stuff that doesn't do animations?

 private boolean NoXpFor(int millis){

        if(getSkills().getTotalExperience() > globalXp)
        {
            TimeSinceXpGain = System.currentTimeMillis();
            globalxp = getSkills().getTotalExperience();
        }
        else
        {
            TimeSinceNoXp = System.currentTimeMillis();
        }

        return TimeSinceXpGain + millis < TimeSinceNoXp;
   
    }


 

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.