whipz Posted January 30, 2017 Share Posted January 30, 2017 Hey guys; I was slowly updating my beef slave script; which used to run just fine other than bugs(which is why i rewrote some of it) but now it shows up in script selector but doesnt actually run you click it and nothing happens; Could you have a quick look over and see if i have completely missed something ? also if you have any feedback on what else I can do to make this run more smoothly dont hesitate to tell me ! as i want to learn more ! thanks heres the code import org.osbot.rs07.api.Bank; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "Whipz", info = "Beef Slave Picks up stuff from cowpaddock", logo = "", name = "beefSlave", version = 1) public class main extends Script { // Areas Area cowArea = new Area(new int[][] { { 3253, 3253 }, { 3265, 3253 }, { 3265, 3255 }, { 3265, 3260 }, { 3265, 3297 }, { 3264, 3299 }, { 3262, 3299 }, { 3261, 3300 }, { 3259, 3300 }, { 3257, 3300 }, { 3256, 3299 }, { 3241, 3299 }, { 3240, 3298 }, { 3240, 3295 }, { 3240, 3287 }, { 3240, 3284 } }); Area lumbyBankArea = new Area(new int[][] { { 3210, 3221, 2 }, { 3207, 3217, 2 } }); // Paint @SuppressWarnings("unused") private long startTime; // Player to trade @SuppressWarnings("unchecked") Player muleAccount = getPlayers() .closest(o -> o.getName().replaceAll("\\u00a0", " ").equalsIgnoreCase("InsertNameHere")); private enum State { PICKUP, WALKTOBANK, BANK, GETNOTEDITEMS, TRADEMULE, OFFERITEMS, ACCEPTTRADE, ACCEPTTRADE2, WALKTOPICKUP, WAIT } private State getState() { if (!inventory.isFull() && cowArea.contains(myPlayer())) return State.PICKUP; if (inventory.isFull() && !lumbyBankArea.contains(myPlayer())) return State.WALKTOBANK; if (muleAccount != null && muleAccount.isVisible() && lumbyBankArea.contains(myPlayer())) return State.GETNOTEDITEMS; if (muleAccount == null && inventory.isFull() && lumbyBankArea.contains(myPlayer())) return State.BANK; if (inventory.contains(2133, 1740) && lumbyBankArea.contains(myPlayer())) return State.TRADEMULE; if (inventory.contains(2133, 1740) && trade.isFirstInterfaceOpen()) return State.OFFERITEMS; if (trade.getOurOffers().contains("Raw beef", "Cowhide") && trade.isFirstInterfaceOpen()) return State.ACCEPTTRADE; if (trade.isSecondInterfaceOpen() && trade.isCurrentlyTrading()) return State.ACCEPTTRADE2; if (!inventory.isFull() && !bank.isOpen() && !trade.isCurrentlyTrading() && !cowArea.contains(myPlayer())) return State.WALKTOPICKUP; return State.WAIT; } public void onStart() throws InterruptedException { startTime = System.currentTimeMillis(); log("Welcome to beef slave"); log("This is a quick money making method"); log("Please post errors to thread"); } @Override public int onLoop() throws InterruptedException { switch (getState()) { case PICKUP: doPickUp(); break; case WALKTOBANK: log("Walking to bank"); getWalking().webWalk(lumbyBankArea); break; case GETNOTEDITEMS: getNotedItems(); break; case BANK: doBank(); break; case TRADEMULE: tradeMule(); break; case OFFERITEMS: offerItems(); break; case ACCEPTTRADE: acceptTrade1(); break; case ACCEPTTRADE2: acceptTrade2(); break; case WALKTOPICKUP: log("Walking to CowArea"); getWalking().webWalk(cowArea); break; case WAIT: break; } return random(300, 500); } private void doPickUp() throws InterruptedException { GroundItem loot = getGroundItems().closest("Raw beef", "Cowhide"); if (!inventory.isFull() && cowArea.contains(myPlayer()) && (loot != null) && !myPlayer().isAnimating()) { loot.interact("Take"); log("Picking up Raw Beef or Cowhide"); sleep(random(750, 1500)); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return !myPlayer().isMoving(); } }.sleep(); } } private void getNotedItems() throws InterruptedException { NPC closestBanker = getNpcs().closest("Banker"); Entity closestBankBooth = objects.closest("Bank Booth"); if (bank.isOpen()) { if (inventory.isEmpty()) { if (getBank().getWithdrawMode().equals(Bank.BankMode.WITHDRAW_NOTE)) { log("Withdrawing Noted Beef & CowHide"); getBank().withdrawAll("Raw beef"); getBank().withdrawAll("Cowhide"); sleep(random(750, 1500)); bank.close(); sleep(random(750, 1500)); } else { log("changing to withdraw note mode"); bank.enableMode(Bank.BankMode.WITHDRAW_NOTE); sleep(random(750, 1500)); } } else { bank.depositAll(); } sleep(random(1000, 2500)); } else { int rand = random(3); if (rand == 1) { closestBankBooth.interact("Bank"); log("Using Bank Booth"); sleep(random(750, 1500)); } else { closestBanker.interact("Bank"); log("Using NPC Banker"); sleep(random(750, 1500)); } sleep(random(1000, 2500)); log("Opening Bank"); } } private void doBank() throws InterruptedException { NPC closestBanker = getNpcs().closest("Banker"); Entity closestBankBooth = objects.closest("Bank Booth"); if (bank.isOpen()) { if (!inventory.isEmpty()) { bank.depositAll(); } sleep(random(1000, 2500)); } else { int rand = random(3); if (rand == 1) { closestBankBooth.interact("Bank"); log("Using Bank Booth"); sleep(random(750, 1500)); } else { closestBanker.interact("Bank"); log("Using NPC Banker"); sleep(random(750, 1500)); } sleep(random(1000, 2500)); log("Opening Bank"); } } private void tradeMule() throws InterruptedException { if (muleAccount != null && muleAccount.isVisible() && lumbyBankArea.contains(myPlayer()) && inventory.contains(2133, 1740)) { log("Trying to trade mule"); if (muleAccount.interact("Trade with")) { sleep(random(750, 1500)); log("Waiting to be in trade menu"); } new ConditionalSleep(10000) { @Override public boolean condition() throws InterruptedException { return trade.isFirstInterfaceOpen(); } }.sleep(); } } private void offerItems() throws InterruptedException { if (trade.isFirstInterfaceOpen() && trade.isCurrentlyTrading()) { log("Offering Loot"); getInventory().getItem("Raw beef").interact("Offer-All"); if (inventory.contains("Cowhide")) { getInventory().getItem("Cowhide").interact("Offer-All"); } else { sleep(random(750, 1000)); } sleep(random(750, 1500)); new ConditionalSleep(20000) { @Override public boolean condition() throws InterruptedException { return trade.getOurOffers().contains("Raw beef", "Cowhide"); } }.sleep(); } } private void acceptTrade1() throws InterruptedException { if (trade.isFirstInterfaceOpen() && trade.getOurOffers().contains("Raw beef", "Cowhide")) { trade.acceptTrade(); new ConditionalSleep(10000) { @Override public boolean condition() throws InterruptedException { return trade.isSecondInterfaceOpen(); } }.sleep(); } } private void acceptTrade2() throws InterruptedException { if(trade.isSecondInterfaceOpen()) { sleep(random(500, 1500)); trade.acceptTrade(); new ConditionalSleep(10000) { @Override public boolean condition() throws InterruptedException { return !trade.isCurrentlyTrading(); } }.sleep(); } } public void onExit() { log("Thanks for using beef Slave"); } } Quote Link to comment Share on other sites More sharing options...
Lewis Posted January 30, 2017 Share Posted January 30, 2017 post error in logger here please 1 Quote Link to comment Share on other sites More sharing options...
Chris Posted January 30, 2017 Share Posted January 30, 2017 // Player to trade @SuppressWarnings("unchecked") Player muleAccount = getPlayers() .closest(o -> o.getName().replaceAll("\\u00a0", " ").equalsIgnoreCase("InsertNameHere")); move this 2 Quote Link to comment Share on other sites More sharing options...
whipz Posted January 30, 2017 Author Share Posted January 30, 2017 Just now, Lewis said: post error in logger here please Theres no error it just doesnt do anything its like my code is empty Quote Link to comment Share on other sites More sharing options...
whipz Posted January 30, 2017 Author Share Posted January 30, 2017 Just now, Chris said: // Player to trade @SuppressWarnings("unchecked") Player muleAccount = getPlayers() .closest(o -> o.getName().replaceAll("\\u00a0", " ").equalsIgnoreCase("InsertNameHere")); move this I have moved it to where it is only required in the getstate and in the trading mule both didnt work I can upload both versions if you like /: i have a feeling its to do with Area lumbyBankArea = new Area(new int[][] { { 3210, 3221, 2 }, { 3207, 3217, 2 } }); really the only difference in my old script and this one is I want to bank at lumby; and dont want to trade to my mule every single time only when his logged in, So my States are different but methods are pretty much the same; I will try again with //PLayer trade somewhere else and see how it goes but it didnt work last time ): Quote Link to comment Share on other sites More sharing options...
whipz Posted January 30, 2017 Author Share Posted January 30, 2017 Area lumbyBankArea = new Area(new int[][] { { 3210, 3221, 2 }, { 3207, 3217, 2 } }); This was the problem I thought you needed to know the y of the bank but you only need x and y my bad guys ): Quote Link to comment Share on other sites More sharing options...
Team Cape Posted January 30, 2017 Share Posted January 30, 2017 chris is right. you can have the Player muleaccount; definition at the top, but you can't have any references to Script before onStart(), so you need to put the assignment in onStart() your onStart() should look like this: public void onStart() throws InterruptedException { startTime = System.currentTimeMillis(); muleAccount = getPlayers(...); log("Welcome to beef slave"); log("This is a quick money making method"); log("Please post errors to thread"); } 1 Quote Link to comment Share on other sites More sharing options...
whipz Posted January 30, 2017 Author Share Posted January 30, 2017 Just now, Imateamcape said: chris is right. you can have the Player muleaccount; definition at the top, but you can't have any references to Script before onStart(), so you need to put the assignment in onStart() your onStart() should look like this: public void onStart() throws InterruptedException { startTime = System.currentTimeMillis(); muleAccount = getPlayers(...); log("Welcome to beef slave"); log("This is a quick money making method"); log("Please post errors to thread"); } Thank you that will make it look a lot neater and user friendly as well thanks (: 1 Quote Link to comment Share on other sites More sharing options...