Jump to content

Can scripts just stop working?


uyfgfarOS

Recommended Posts

I've been working on a herb cleaning script for a few days, been working fine, i've not even touched the code but I noticed Jagex changed the name of  "Grimy harralanders" to "Grimy Harralanders". As my initial script skeleton was just for Harralanders, so i changed it so it matched but nothing seems to be working. It won't even click through my inventory anymore.

 

All this seems to be doing is withdrawing grimy harralanders and then opening the grand exchange, which is completely wrong as it should be cleaning the herbs first, then banking and withdrawing clean ones.

here's all my code, please ignore the spacing, after copy and pasting it on here it seems like my code is everywhere. Might be my mac...

import org.osbot.rs07.api.Bank.BankMode;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.api.GrandExchange;


import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import java.awt.*;
import java.util.Random;

@ScriptManifest(author = "Matt", info = "Cleans Herbs", name = "Matt's Herb Cleaner", version = 0, logo = "")
public class main extends Script {

paint Paint;

String Status = " ";
    @[member=Override]
    public void onStart() {
        log("Beginning of script");
  
    }
    
    private enum State {
WITHDRAW, CLEAN, WAIT
}
    
    private State getState() {
     
     if (getInventory().contains("Grimy harralander")) 
{
return State.CLEAN;
}
     if (!getInventory().contains("Grimy harralander")) 
{ 
return State.WITHDRAW;
}
return State.WAIT;
}

    @[member=Override]
    public int onLoop() throws InterruptedException {
     switch (getState()) {
     
case WITHDRAW:
doBanking();

if (!getGrandExchange().isOpen()) { //Checks if ge is open
       sellItem();
       //Process sale
       if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.PENDING_SALE) {
           //Waiting for sale
        }else if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.FINISHED_SALE) {
           grandExchange.collect();
        }
       
       buyItem();
       //Process Buy
       if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.PENDING_BUY) {
           //Waiting for buy
        }else if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.FINISHED_BUY) {
           grandExchange.collect();
        }
      } else
      {
      doBanking();    
      }
break;

case CLEAN:
if (getInventory().contains("Grimy harralander"))
{
doCleaning();
}
else
{
break;
}

case WAIT:
break;
}
        return random(200, 300);
    }

    @[member=Override]
    public void onExit() {
        log("Exit script");
    
    }

    @[member=Override]
    public void onPaint(Graphics2D g) {
    }
    
    public void doCleaning() throws InterruptedException
    { 
     for(int i=0;i<28;i++)
     {
      mouse.move(inventory.getMouseDestination(i));
      mouse.click(false);  
     }
     
     sleep(random(1000,2000));
     
     if (getInventory().contains("Grimy harralander"))
     {
      inventory.getItem("Grimy harralander");
      mouse.click(false);
     }
     
    }
    
    
    public boolean offerItem(String string) {

     for (int n = 0; n < 27; n++) {
      RS2Widget inventoryWidget = getWidgets().get(467, 0, n);
      if (getInventory().getItemInSlot(n).getName().contains(string)) {
       return inventoryWidget.interact("Offer");
      }
     }
     
     return false;
    }
    
    public void sellItem() throws InterruptedException
    {
     if (!grandExchange.isOpen())
     {
     //Open GE
     openGrandExchange();
     sleep(random(500,900));
     grandExchange.sellItem(256, 539, 224);     
sleep(random(5000,6000));
grandExchange.confirm();
     }   
    }
    
    public void buyItem() throws InterruptedException
    {
     if (!grandExchange.isOpen())
     {
     openGrandExchange();
     sleep(random(500,900));
     grandExchange.buyItem(205, "Grimy harralander", 565, 224);  
     
sleep(random(5000,6000));
grandExchange.confirm();

     }
   
     
    }
    
    public void openGrandExchange()
    {
     
     RS2Object geBooth = this.getObjects().closest("Grand Exchange booth");
NPC exchangeWorker = this.getNpcs().closest("Grand Exchange Clerk");

int random = new Random().nextInt(10);
if (geBooth != null && random < 5) {
geBooth.interact("Exchange");
new ConditionalSleep(2500, 3000) {
@[member=Override]
public boolean condition() {
return getGrandExchange().isOpen();
}
}.sleep();
}

if (exchangeWorker != null && random >= 5) {
exchangeWorker.interact("Exchange");
new ConditionalSleep(2500, 3000) {

@[member=Override]
public boolean condition() {
return getGrandExchange().isOpen();
}

}.sleep();
}

    }
    
    private void doBanking() throws InterruptedException {
        if(!bank.isOpen()){
            Status = "Banking: Opening Bank.";
            NPC banker = npcs.closest("Banker");
            if(banker != null) {
                if (banker.isOnScreen()) {
                    Status = "Banking: Interacting Banker.";
                    banker.interact("Bank");
                    sleep(random(900, 1200));
                } 
            }
        }
        
        else
        {
            Status = "Banking: Depositing.";
            if (!inventory.isEmpty())
            {
            bank.depositAll();
         
            }
            else
            {
             //Contains grimy
                if (bank.contains("Grimy harralander"))
                {
                 if (getBank().getWithdrawMode().equals(BankMode.WITHDRAW_NOTE)) 
                 {
                  getBank().enableMode(BankMode.WITHDRAW_ITEM);
                  bank.withdraw("Grimy harralander", 28);
                 }
                 else
                 {
                  bank.withdraw("Grimy harralander", 28);
                 }
                bank.close();
                }
                //Doesn't contain grimy avantoes
                else if (!bank.contains("Grimy harralander"))
                {
                 //Contains clean avantoes
                 if (bank.contains("Harralander"))
                 {
                  //Withdraw 100
                  if (!getBank().getWithdrawMode().equals(BankMode.WITHDRAW_NOTE)) {
                   getBank().enableMode(BankMode.WITHDRAW_NOTE);
                      bank.withdraw("Harralander", 224);
                      bank.withdraw("Coins", 30000);
                      bank.close();
                        }
                  
                   //new GrandExchange instance with our script
                  
                 }  
                 }
                }
              sleep(random(250, 450));
            }
            }
    
            
      
    }

 

Link to comment
Share on other sites

In the code you've posted it still shows 'Grimy harralander' rather than 'Grimy Harralander' 

private void doBanking() throws InterruptedException {
        if(!bank.isOpen()){
            Status = "Banking: Opening Bank.";
            NPC banker = npcs.closest("Banker");
            if(banker != null) {
                if (banker.isOnScreen()) {
                    Status = "Banking: Interacting Banker.";
                    banker.interact("Bank");
                    sleep(random(900, 1200));
                } 
            }
        }
        
        else
        {
            Status = "Banking: Depositing.";
            if (!inventory.isEmpty())
            {
            bank.depositAll();
         
            }
            else
            {
             //Contains grimy
                if (bank.contains("Grimy harralander"))
                {
                 if (getBank().getWithdrawMode().equals(BankMode.WITHDRAW_NOTE)) 
                 {
                  getBank().enableMode(BankMode.WITHDRAW_ITEM);
                  bank.withdraw("Grimy harralander", 28);
                 }
                 else
                 {
                  bank.withdraw("Grimy harralander", 28);
                 }
                bank.close();
                }
                //Doesn't contain grimy avantoes
                else if (!bank.contains("Grimy harralander"))
                {
                 //Contains clean avantoes
                 if (bank.contains("Harralander"))
                 {
                  //Withdraw 100
                  if (!getBank().getWithdrawMode().equals(BankMode.WITHDRAW_NOTE)) {
                   getBank().enableMode(BankMode.WITHDRAW_NOTE);
                      bank.withdraw("Harralander", 224);
                      bank.withdraw("Coins", 30000);
                      bank.close();
                        }
                  
                   //new GrandExchange instance with our script
                  
                 }  
                 }
                }
              sleep(random(250, 450));
            }
            }
    

I believe this code is causing your issue, you've written it so the withdrawing code only executes if the bank is already open. If the bank is not already open, it will open the bank and then continue on with the code in your withdraw state. 

 

Remove the else from this and it should work as intended? 

 

 

Edited by PlagueDoctor
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...