Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Resolved For Loop not being executed in script?

Joined
Mar 23, 2018
Messages
4
Hello everyone! I'm not an experienced developer for runemate or java for that matter, but I am trying to make a simple open-source script that adds up the player's total wealth and tells you it. Simple enough for my first script.

Here's the relevant code:
Code:
if(Bank.open()){

    SpriteItem[] items = Bank.getItems().toArray(new SpriteItem[0]);

    if(items != null){

        System.out.println("Total Items to Count: " + items.length);

        for(int i = 0; i == items.length; i++){

            int id = items[i].getId();

            if(id != 0){

                System.out.println("Looking up price for ID " + id);

                int addwealth = GrandExchange.lookup(id).getPrice();

                if(addwealth > 0) {

                    wealth += addwealth;

                    System.out.println("Total Wealth: " + wealth);
                }else{
                    System.out.println("Could not locate price for " + id);
                }
            }

        }

    }

}

But when I run the bot, it seems to only run this portion of the code, and since it doesn't enter the For loop I imagine, it keeps being validated and executed indefinitely.

Code:
if(Bank.open()){

    SpriteItem[] items = Bank.getItems().toArray(new SpriteItem[77]);

    if(items != null){

        System.out.println("Total Items to Count: " + items.length);

Again, I'm new so my code probably is shite but hey, you gotta start somewhere eh? I can post the full class files if someone needs me to.
 
Top