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.

I need help with my script

Featured Replies

I want to add in my script the option that when you reach a specific level in "Attack, force or defense" change the attack form to start uploading another melee skill
Ex: reach level 30 of attack and I want to change to the mode of "Block" so that it raises defense and later that it changes to "Stab" to raise force when it reaches certain levels.

Can you help me with that?

 

if (getSkills().getStatic(Skill.DEFENCE) < 30) {
        }
        else if (getSkills().getStatic(Skill.DEFENCE) >=30) {
            log ("Defence level es 30.");
                this.stop (false);
        }

I have this code but the only thing it can do is when it reaches level 30 of Defense it stops and I want it to change from Defense to Attack or Force ... to keep reaching melee levels.

Quote

@H0rn said: 
For your example you would do the following:
If you are using the defensive attack style and your attack is over the desired level, change the attack style to strength?

If I have already tried to think about that and I have searched the API for hours but I can not get anything.

Please help guys!

Edited by th3gos

else if (getSkills().getStatic(Skill.DEFENCE) >=30) {
            log ("Defence level es 30.");
                this.stop (false);

If you have read the api under https://osbot.org/api/org/osbot/rs07/script/Script.html

The method stop(), will stop the script and will logout the accounts.

What you want to do is to change the style of attack if defence reaches a certain level. In order to change attack styles, you can either use config values or through widget ids.

One way to do it is by widgets and configs.

Check if the config isn't the same as you want it to be (to stop a loop) && a check if its above 30 defence, then do some NPE checks for the widget, then interact.

 

 private int getdefLevel(){
        return api.getSkills().getStatic(Skill.DEFENCE);
    }
 private int defConfig = 2; //Not right config

        RS2Widget defence = api.getWidgets().get(1,1 ); //not the right widget ids, dont use this method btw, use filters
        if(getdefLevel() >= 30 && api.getConfigs().get(43) != defConfig){
            api.log("Defence is 30, attempting to switch attack styles");
            if(defence != null){
                if(defence.isVisible()){
                    if(defence.interact("change")){
                        api.log("Switched attack styles");
                    }
                }else{
                    if(api.getTabs().open(Tab.ATTACK)){
                        api.log("Successfully opened attack tab");
                    }
                }
            }
        }

That by no means will work at all, just remember the npe checks and to get widgets by filters (eg: text, actions etc.)

edit: Dont forget to check if the widget is visible, if not, youll have to open the tab first.

Edited by blogans

You do know that if defence is not less than 30, that means its greater than or equal to 30? If you have specific weapons you are using, then the easiest would be to search for widgets with actions/messages with the nomenclature for "controlled", "defence", etc.

  • Author
On 22/3/2018 at 8:21 AM, Alek said:

You do know that if defence is not less than 30, that means its greater than or equal to 30? If you have specific weapons you are using, then the easiest would be to search for widgets with actions/messages with the nomenclature for "controlled", "defence", etc.

I do not understand you very well, I have to modify it to work ...

On 22/3/2018 at 8:11 AM, blogans said:

private int getdefLevel(){ return api.getSkills().getStatic(Skill.DEFENCE); } private int defConfig = 2; //Not right config RS2Widget defence = api.getWidgets().get(1,1 ); //not the right widget ids, dont use this method btw, use filters if(getdefLevel() >= 30 && api.getConfigs().get(43) != defConfig){ api.log("Defence is 30, attempting to switch attack styles"); if(defence != null){ if(defence.isVisible()){ if(defence.interact("change")){ api.log("Switched attack styles"); } }else{ if(api.getTabs().open(Tab.ATTACK)){ api.log("Successfully opened attack tab"); } } } }

The script is personal, I just want you to do what I said

55 minutes ago, th3gos said:

@blogans Look this.
uQpuCzS.png

you made your getDefLevel as a variable and not a method. The { } below is just a code block (not a method body). Needs to be

int getDefLevel() {
return ....;

}

  • Author
3 hours ago, Butters said:

you made your getDefLevel as a variable and not a method. The { } below is just a code block (not a method body). Needs to be

int getDefLevel() {
return ....;

}

Not work!

I advise you to learn java before learning to make scripts. If you get a basic understanding of java first, you'll be able to learn more throughout coding. But starting with no knowledge of how to create a method is a really bad place to start.

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.