Abra123 0 Share Posted November 10, 2020 Hello, I am new to Java and scripting and I have been trying to use the documentation and a few guides on the website to make myself a script to purchase cowhide from the ge, tan them and (for now) store the tanned leather in the al-kharid bank. Here is my progress so far Spoiler import org.dreambot.api.methods.container.impl.bank.Bank; import org.dreambot.api.methods.container.impl.bank.BankLocation; import org.dreambot.api.methods.container.impl.bank.BankMode; import org.dreambot.api.methods.grandexchange.GrandExchange; import org.dreambot.api.methods.walking.impl.Walking; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; @ScriptManifest(name = "GE Cowhide Tanner", description = "Purchases cowhide from the GE, then tans and sells", author = "Abra", version = 1.0, category = Category.MONEYMAKING, image = "") public class TestScript extends AbstractScript { private int state; BankLocation GEBank = BankLocation.GRAND_EXCHANGE; BankLocation AK = BankLocation.AL_KHARID; @Override public void onStart(){ state = 0; } private void walkToGE(){ if(!GEBank.getArea(5).contains(getLocalPlayer())) { Walking.walk(GEBank.getCenter().getRandomizedTile()); } } private void walkToAK(){ if(!AK.getArea(5).contains(getLocalPlayer())){ Walking.walk(AK.getCenter().getRandomizedTile()); } } @Override public int onLoop() { if (state == 0) { walkToGE(); // walk to grand exchange Bank.openClosest(); // open bank Bank.depositAllItems(); // deposit inventory Bank.withdraw("COINS", 20000);// withdraw 20k gold Bank.close();// close bank state = 1; } else if (state == 1){ if(!GrandExchange.isBuyOpen()) { currentSlot = GrandExchange.getFirstOpenSlot(); GrandExchange.openBuyScreen(currentSlot); sleep(1000); } int min = 156;int random = (int) (Math.random() *4 +1);int price = min+random; // randomise buy price for cowhide GrandExchange.buyItem("Cowhide", 100, price);// send buy order for 100x cowhide sleep(2000); if(GrandExchange.isReadyToCollect(currentSlot)){ GrandExchange.collect();// collect order } GrandExchange.close(); // close exchange Bank.openClosest(); // open bank Bank.depositAllItems();// deposit inventory state = 2; } else if(state == 2) { walkToAK(); // walk to al-kharid bank Bank.openClosest();// open bank Bank.withdrawAll("COINS");// withdraw all gold Bank.setWithdrawMode(BankMode.ITEM);// set withdraw method to item while(Bank.contains("Cowhide"))// start loop { Bank.withdrawAll("Cowhide");// withdraw all cowhide Bank.close();// close bank // walk to tanner // tan all cowhide walkToAK();// walk to bank Bank.openClosest();// open bank Bank.depositAll("Leather");// deposit all leather } // add leather sell function } return 1000; } } I want to ask for help, how can I have the script walk to and interact with Ellis - the tanning npc and have it right-click and select tan all. Thank you! Link to comment Share on other sites More sharing options...
Pixel_Life 24 Share Posted November 10, 2020 Hi, I'd suggest first that you take a step back and make sure your current code is working, take it one step at a time and make sure it works as expected before you continue. Have you compiled and ran this yet? In state 0 you're doing walkToGE(); and then doing several Bank things and then increasing the state and moving on. Walking#walk needs to loop until you're at the GE, then you can do the bank actions. In state 1 if the cowhides don't buy, you're closing the GE and walking to al kharid anyway. Again in state 2 the walking to al kharid needs to loop and you don't want to do the banking until you're at al kharid. All of those Bank methods return a boolean, you probably should be checking to make sure they return true before moving on and blindly firing the actions. You also want to set the withdraw mode, before withdrawing items. State 2, you should avoid the while loop, that' part's not going to work. onLoop loops every 1000 milliseconds (the return value) so you don't want to do that. Link to comment Share on other sites More sharing options...
una_maquina 35 Share Posted November 11, 2020 Dude, the first thing you should learn is the nodes system, you need to keep your code clean, otherwise you'll end up in a mess. Been there and paid for it. Personally, this guide helped me a ton: Also, if you're walking somewhere -- you can define an area: Area ge_area = new Area(3181, 3506, 3148, 3469); And then: while(!ge_area.contains(getLocalPlayer())) { log("DEBUG: Going to G.E."); Walking.walk(ge_area.getCenter().getRandomizedTile()); sleep(Calculations.random(2000, 3000)); } This will walk to an area until it gets there, and then it'll break out of the loop. Also the sleep is randomized -- an antiban feature. Link to comment Share on other sites More sharing options...
Abra123 0 Author Share Posted November 12, 2020 Thanks guys! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.