Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users

    Recommended Posts

    Posted

    Writing something as a personal / learning project and integrating multiple skills into one "AIO". When I got to handling Melee i'm having a slight issue. My Bank.count("coins") >= cost * (Anything I can put here) seems to always want to default to Mithril instead of Rune which the account im testing it on has the requirements for. 

     

    public boolean Find_Gear() {
            // Define gear requirements by level using a HashMap
            Map<String, Object[]> gearByLevel = new HashMap<>();
            gearByLevel.put("Rune", new Object[]{40, 40, new int[]{1333, 1079, 1113, 1163, 1201}, "Rune Scimitar", 15000});
            gearByLevel.put("Mithril", new Object[]{20, 20, new int[]{1329, 1071, 1121, 1159, 1197}, "Mithril Scimitar", 3000});
            gearByLevel.put("Iron", new Object[]{1, 1, new int[]{1323, 1067, 1115, 1153, 1191}, "Iron Scimitar", 2000});
    
            // Sort tiers from highest to lowest priority
            for (Map.Entry<String, Object[]> entry : gearByLevel.entrySet()) {
                String tier = entry.getKey();
                Object[] data = entry.getValue();
    
                int attackLevel = Skills.getRealLevel(Skill.ATTACK);
                int defenceLevel = Skills.getRealLevel(Skill.DEFENCE);
                int[] itemIds = (int[]) data[2];
                String weaponName = (String) data[3];
                int cost = (int) data[4];
    
                // Check level requirements
                if (attackLevel >= (int) data[0] && defenceLevel >= (int) data[1]) {
                    if (Bank.isOpen()) {
                        if (Bank.contains(itemIds)) {
                            // Withdraw and equip if gear is already in the bank
                            withdrawAndEquipGear(itemIds);
                            return true;
                        } else if (Bank.count("Coins") >= cost * 5) { // Ensure enough coins for all items
                            // Purchase and equip gear if sufficient gold is available
                            purchaseAndEquipGear(itemIds, weaponName, cost);
                            return true;
                        } else {
                            script.log("Not enough coins for " + tier + " gear.");
                        }
                    } else {
                        openBankAndRetry();
                    }
                } else {
                    script.log("Requirements not met for " + tier + " gear. Checking next tier...");
                }
            }
            return false;
        }

    I can give the account 10m gold and it'll still try to buy mithril gear. Just curious if something is wrong here? Don't wanna slam it into chatGPT because it spits out some garbled dumb stuff.

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.