Skip 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.

The currentStrenghtxp dont updates

Featured Replies

My Current strenght xp dont changes when i attack someone, and when i try to put the variables in the onloop() i get error because onPaint() metod cant use variables from onLoop()


    @Override
    public void onPaint(Graphics2D g) {

        int currentStrenghtxp = skills.getExperience(Skill.STRENGTH);
        int beginningStrenghtxp = (skills.getExperience(Skill.STRENGTH));
        int strenghtXpGained = currentStrenghtxp - beginningStrenghtxp;

        g.setColor(new Color(25, 25, 25, 100));
        g.fillRect(7, 345, 516, 320);
        g.setColor(new Color(228, 211, 22));


        g.drawString("Current:"+strenghtXpGained,10,364);

    }

Edited by hajar424

  • Author

put the beginningStrengthxp at your onStart methode.

I get a error then saying that it dont know the variable 

bHijlq7.png

loll

 

So the problem you have here is that you're defining start and current exps in the same place so obv they will both be the same so when you subtract 1 from the other you will get 0.

 

Define startStrExp as a global variable and give it a value in onstart. Keep the current value where it is.

Then it will work haha

 

-apa


I get a error then saying that it dont know the variable 

bHijlq7.png

 

there are 2 types of variable, global and local.

 

Local is where you define a variable INSIDE a method

 

eg

public void hello() {
    int i = 10;
    log("value of i: " + i);
}

A global variable is something you define globally i.e it can be reached from any method inside your class

 

eg

private int n = 1337;

public int getn() {
    return n;
}

apa


for more info google 'local vs global variables java' or something like taht

With all due respect, you should really look up the basics of Java. Your problem exists because you are defining "beginningStrengthExp" in the function scope.

The hierarchy for variable scopes goes class > function. If you want your variables to be used in many functions, you put them in the class scope.

public class Main extends Script {
    private int beginningStrengthExp;

    public void onStart() {
        beginningStrengthExp = <code>;
    }

    public void onPaint(Graphics2d g) {
        int x = beginningStrengthExp;
    }
}

In this example, we can access beginningStrengthExp because it was defined in the class. We cannot, however, access beginningStrengthExp with an instance of Main because it is set to private. To solve this, we add a getter value:

public int getBeginningStrengthExp() {
    return beginningStrengthExp;
}

So this can be used when we need to grab it from an instance of Main:

public class SomeArbitraryClass {
    public SomeArbitraryClass(Main m) {
        int beginningStrengthExp = m.getBeginningStrengthExp();
    }
}
  • Developer

 

My Current strenght xp dont changes when i attack someone, and when i try to put the variables in the onloop() i get error because onPaint() metod cant use variables from onLoop()


    @Override
    public void onPaint(Graphics2D g) {

        int currentStrenghtxp = skills.getExperience(Skill.STRENGTH);
        int beginningStrenghtxp = (skills.getExperience(Skill.STRENGTH));
        int strenghtXpGained = currentStrenghtxp - beginningStrenghtxp;

        g.setColor(new Color(25, 25, 25, 100));
        g.fillRect(7, 345, 516, 320);
        g.setColor(new Color(228, 211, 22));


        g.drawString("Current:"+strenghtXpGained,10,364);

    }

 

bcs u set begin exp every single second to the current value ... only call it onStart :)

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.