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.

My script seems to stop immediately and I'm not sure why

Featured Replies

Trying to make a little script to pull equipment from bank and equip it based on attack and defense levels. The script stops as soon as I run it and I'm not exactly sure why. I've tried adding logs to various places but nothing is making it into the logger. Any help would be greatly appreciated.
I am also getting some warnings and I don't see how this would be true

 

===WARNINGS===

Condition 'MyAttackLvl >= 5' is always 'true'

Condition 'MyAttackLvl >= 20' is always 'true'

Condition 'MyAttackLvl >= 30' is always 'true'

Condition 'MyDefenceLvl >= 5' is always 'true'

Condition 'MyDefenceLvl >= 20' is always 'true'

Condition 'MyDefenceLvl >= 30' is always 'true'

 

 

===CODE===

package GearSetter;

import org.osbot.rs07.api.ui.EquipmentSlot;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.api.ui.Skill;


@ScriptManifest(name = "GearSetter", author = "Alakazizam",logo = "", version = 0.1, info = "Equips gear for level")
public class Main extends Script {

    int MyAttackLvl = getSkills().getDynamic(Skill.ATTACK);
    int MyDefenceLvl = getSkills().getDynamic(Skill.DEFENCE);
    String MyWeapon = "";
    String MyHelm = "";
    String MyChest = "";
    String MyLegs = "";
    String MyShield = "";
    String MyNecklace = "Amulet of power";
    String MyGloves = "Leather gloves";
    String MyBoots = "Leather boots";
    String MyCape = "Black cape";

    @Override
    public int onLoop() throws InterruptedException {

        log("Starting script");;
        SetMyWeapon();
        SetMyArmor();
        if (!CheckMyGear()) {
            GoGetGear();
        } else {
            log("Stopping script, you have the proper gear.");
            stop(false);
        }

        return 602;
    }

    private void SetMyWeapon() {
        if (MyAttackLvl < 5) {
            MyWeapon = "Iron longsword";
            log( "Weapon set to Iron longsword");
        } else if (MyAttackLvl >= 5 && MyAttackLvl < 20) {
            MyWeapon = "Steel longsword";
            log( "Weapon set to Steel longsword");
        } else if (MyAttackLvl >= 20 && MyAttackLvl < 30) {
            MyWeapon = "Mithril longsword";
            log( "Weapon set to Mithril longsword");
        } else if (MyAttackLvl >= 30 && MyAttackLvl < 40) {
            MyWeapon = "Adamant longsword";
            log( "Weapon set to Adamant longsword");
        } else {
            MyWeapon = "Rune longsword";
            log( "Weapon set to Rune longsword");
        }
    }

    private void SetMyArmor() {
        if (MyDefenceLvl < 5) {
            MyHelm = "Iron full helm";
            MyChest = "Iron platebody";
            MyLegs = "Iron platelegs";
            MyShield = "Iron kiteshield";
            log( "Armor set to Iron");
        } else if (MyDefenceLvl >= 5 && MyDefenceLvl < 20) {
            MyHelm = "Steel full helm";
            MyChest = "Steel platebody";
            MyLegs = "Steel platelegs";
            MyShield = "Steel kiteshield";
            log( "Armor set to Steel");
        } else if (MyDefenceLvl >= 20 && MyDefenceLvl < 30) {
            MyHelm = "Mithril full helm";
            MyChest = "Mithril platebody";
            MyLegs = "Mithril platelegs";
            MyShield = "Mithril kiteshield";
            log( "Armor set to Mithril");
        } else if (MyDefenceLvl >= 30 && MyDefenceLvl < 40) {
            MyHelm = "Adamant full helm";
            MyChest = "Adamant platebody";
            MyLegs = "Adamant platelegs";
            MyShield = "Adamant kiteshield";
            log( "Armor set to Adamant");
        } else {
            MyHelm = "Rune full helm";
            MyChest = "Rune chainbody";
            MyLegs = "Rune platelegs";
            MyShield = "Rune kiteshield";
            log( "Armor set to Rune");
        }
    }

    private boolean CheckMyGear() {
        return getEquipment().isWearingItem(EquipmentSlot.WEAPON, MyWeapon) &&
                getEquipment().isWearingItem(EquipmentSlot.HAT, MyHelm) &&
                getEquipment().isWearingItem(EquipmentSlot.CHEST, MyChest) &&
                getEquipment().isWearingItem(EquipmentSlot.LEGS, MyLegs) &&
                getEquipment().isWearingItem(EquipmentSlot.SHIELD, MyShield) &&
                getEquipment().isWearingItem(EquipmentSlot.AMULET, MyNecklace) &&
                getEquipment().isWearingItem(EquipmentSlot.HANDS, MyGloves) &&
                getEquipment().isWearingItem(EquipmentSlot.FEET, MyBoots) &&
                getEquipment().isWearingItem(EquipmentSlot.CAPE, MyCape);

    }


    private void GoGetGear() throws InterruptedException {
        WalkToBank();
        WithdrawGear();
        EquipGear();
        BankInventory();
    }



    private void WalkToBank() {
        log("Walking to closest bank");
        getWalking().walk(getBank().closest());
        log("Arrived at bank");
    }


    private void WithdrawGear() throws InterruptedException {
        if (!getBank().isOpen()) {
            bank.open();
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.WEAPON, MyWeapon)) {
            bank.withdraw(MyWeapon, 1);
            log("Withdrawing " + MyWeapon);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.HAT, MyHelm)) {
            bank.withdraw(MyHelm, 1);
            log("Withdrawing " + MyHelm);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.CHEST, MyChest)) {
            bank.withdraw(MyChest, 1);
            log("Withdrawing " + MyChest);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.LEGS, MyLegs)) {
            bank.withdraw(MyLegs, 1);
            log("Withdrawing " + MyLegs);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.SHIELD, MyShield)) {
            bank.withdraw(MyShield, 1);
            log("Withdrawing " + MyShield);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.AMULET, MyNecklace)) {
            bank.withdraw(MyNecklace, 1);
            log("Withdrawing " + MyNecklace);
        }
        if(!getEquipment().isWearingItem(EquipmentSlot.HANDS, MyGloves)) {
            bank.withdraw(MyGloves, 1);
            log("Withdrawing " + MyGloves);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.FEET, MyBoots)) {
            bank.withdraw(MyBoots, 1);
            log("Withdrawing " + MyBoots);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.CAPE, MyCape)) {
            bank.withdraw(MyCape, 1);
            log("Withdrawing " + MyCape);
        }
        bank.close();
        log("Closing bank");

    }

    private void EquipGear() {
        if (!getEquipment().isWearingItem(EquipmentSlot.WEAPON, MyWeapon)) {
            getEquipment().equip(EquipmentSlot.WEAPON, MyWeapon);
            log("Equipping " + MyWeapon);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.HAT, MyHelm)) {
            getEquipment().equip(EquipmentSlot.HAT, MyHelm);
            log("Equipping " + MyHelm);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.CHEST, MyChest)) {
            getEquipment().equip(EquipmentSlot.CHEST, MyChest);
            log("Equipping " + MyChest);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.LEGS, MyLegs)) {
            getEquipment().equip(EquipmentSlot.LEGS, MyLegs);
            log("Equipping " + MyLegs);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.SHIELD, MyShield)) {
            getEquipment().equip(EquipmentSlot.SHIELD, MyShield);
            log("Equipping " + MyShield);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.AMULET, MyNecklace)) {
            getEquipment().equip(EquipmentSlot.AMULET, MyNecklace);
            log("Equipping " + MyNecklace);
        }
        if(!getEquipment().isWearingItem(EquipmentSlot.HANDS, MyGloves)) {
            getEquipment().equip(EquipmentSlot.HANDS, MyGloves);
            log("Equipping " + MyGloves);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.FEET, MyBoots)) {
            getEquipment().equip(EquipmentSlot.FEET, MyBoots);
            log("Equipping " + MyBoots);
        }
        if (!getEquipment().isWearingItem(EquipmentSlot.CAPE, MyCape)) {
            getEquipment().equip(EquipmentSlot.CAPE, MyCape);
            log("Equipping " + MyCape);
        }
    }

    private void BankInventory() throws InterruptedException {
        if (!getBank().isOpen()) {
            log("Opening bank");
            bank.open();
        }
        log("Depositing inventory");
        bank.depositAll();
        log("Closing bank");
        bank.close();

    }

}


 

46 minutes ago, Alakazizam said:
int MyAttackLvl = getSkills().getDynamic(Skill.ATTACK);
int MyDefenceLvl = getSkills().getDynamic(Skill.DEFENCE);

Don't declare things globally with API methods like this as it can cause scripts to error and never start. Declare it in the onStart or later on in the script.

And this needs to be updated, you never update the value, which is why it will always be the same result.

EDIT: Maybe look into enums btw for your equipment 

  • Author
18 hours ago, Gunman said:

Don't declare things globally with API methods like this as it can cause scripts to error and never start. Declare it in the onStart or later on in the script.

And this needs to be updated, you never update the value, which is why it will always be the same result.

EDIT: Maybe look into enums btw for your equipment 

Thanks. I'm familiar with them from Unreal Engine but I'm just getting my feet wet with Java.

 

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.