Jump to content

MarWo22

Members
  • Posts

    33
  • Joined

  • Last visited

  • Feedback

    100%

Everything posted by MarWo22

  1. GrandExchange Snippet: First of all im new to scripting and java. This is one of the first scripts i have ever made. Can you guys please tell me some things to improve in this script and on next scripts in the future. Because my script is really long while it doesnt do that much. Thank you
  2. Im trying to make a part of my script where it will abort all of the pending offers. But i can't seem to get it to work. Can someone help me? Thanks Nvm just found it out
  3. Im trying to find a way to cancel the GE offers. There is probably a really easy way to do it buy I can't seem to find it.
  4. thank you stupid of me that I didnt think of that myself
  5. private enum State{ BANK, MAKE, GRANDEXCHANGE, } private State getState() { if(inventory.contains(227) && inventory.contains(HighestMarginHerbId)) return State.MAKE; return State.BANK; } First of all im a beginner in scripting and in java. Im trying to make getState() return GRANDEXCHANGE when bank does not contain the item 227 and HighestMarginHerbId. But it keeps giving me errors.
  6. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; /** * GrandExchange Price Class * * @author Reid * */ public class GrandExchange { private static final String BASE = "https://api.rsbuddy.com/grandExchange?a=guidePrice&i="; /** * Default Constructor * */ public GrandExchange() { } /** * Gets the overall price of an item. * * @param itemID * @return itemPrice * @throws IOException */ public int getOverallPrice(final int itemID) throws IOException { return parse(itemID,"overall"); } /** * Gets the buying price of an item. * * @param itemID * @return itemPrice * @throws IOException */ public int getBuyingPrice(final int itemID) throws IOException { return parse(itemID,"buying"); } /** * Gets the selling price of an item. * * @param itemID * @return itemPrice * @throws IOException */ public int getSellingPrice(final int itemID) throws IOException { return parse(itemID,"selling"); } /** * Retrieves the price of an item. * * @param itemID * @return itemPrice * @throws IOException */ private int parse(final int itemID, String choice) throws IOException { final URL url = new URL(BASE + itemID); BufferedReader file = new BufferedReader(new InputStreamReader(url.openStream())); String line; String price = null; while ((line = file.readLine()) != null) { if (line.contains("{")) { price = (line).trim(); } } if (choice.equals("buying")){ price = price.substring(price.indexOf(",") + 10, nthOccurrence(price, ',', 1)).trim(); } else if(choice.equals("selling")) { price = price.substring(nthOccurrence(price, ',', 2) + 11 , price.indexOf("sellingQuantity") - 2).trim(); } else { price = price.substring(price.indexOf(":") + 1, price.indexOf(",")).trim(); } file.close(); return Integer.parseInt(price); } private int nthOccurrence(String str, char c, int n) { int pos = str.indexOf(c, 0); while (n-- > 0 && pos != -1) pos = str.indexOf(c, pos + 1); return pos; } } So i found this Snippet but im new to scripting. I dont know how to use it. Can someone please help me? Thank you
  7. Is there a way to check the prices of an item on the GE in your script? For example the instant buy and sell prices of items. This could be very usefull in flipping bots and to check the marging for which items are the most profitable.
  8. Sorry im new to scripting. Can someone do an example of the conditional sleep cause i cant get it to work.
  9. This is my first script i made. Everything works fine except when it starts using the items. It will keep spamming them. I've used if(!myplayer().isanimating()). But there seems to be a small gap in the animations so it will still be spamming the vials of water and herbs and it will eventually cancel the crafting. import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "MarWo", info = "simple bot for making unfinished potions", logo = "", name = "HerbloreBot", version = 0) public class Bot extends Script { private enum State { BANK, MAKE }; private State getState() { if(inventory.contains(227) && inventory.contains(255)) return State.MAKE; return State.BANK; } public void onStart(){ } public void onExit() { } public int onLoop() throws InterruptedException { switch (getState()) { case BANK: if(!getBank().isOpen()) { getBank().open(); } sleep(100); bank.depositAll(); sleep(100); bank.withdraw(227, 14); sleep(100); bank.withdraw(255, 14); sleep(100); bank.close(); break; case MAKE: if(!getWidgets().isVisible(270, 14)) { if(!myPlayer().isAnimating()) { inventory.interact("Use", 227); sleep(250); inventory.interact("Use", 255); } } if (getWidgets().isVisible(270, 14)) { getWidgets().interact(270, 14, "Make"); } break; } return 500; } }
×
×
  • Create New...