Jump to content

Explv

Scripter II
  • Posts

    2314
  • Joined

  • Last visited

  • Days Won

    6
  • Feedback

    100%

Everything posted by Explv

  1. I have pushed a fix for this, it will be available next time the SDN updates. I will update the change log on this thread when it is available.
  2. Thanks, I'll check it out This has been fixed, will be available next SDN update (I will update the change log when it is available)
  3. Yes, my apologies. I have been very busy at work, and also have a lot on my plate @OSBot. I will do my best to get this finished and released over the next few days
  4. What skill did you setup to go to after tut island?
  5. It's pretty much finished, I will try and release if over the next few days, been super busy at work. It will be free, open source, and the link will be provided on this thread.
  6. Yep, I'll fix it ASAP, been very busy at work lately. Sorry for the delay
  7. Not from the app store, from random websites.
  8. You could just wait until it comes out in the store for your region. It's just a shitty pokemon game after all
  9. If you got the official version of Pokemon GO from the app store, it will not have malware. However, if you are downloading dodgy .apks from random sites, then rip you.
  10. I've updated it. Should be a bit more memory efficient now. Still some improvements that could be made but I cba
  11. Yeah I will be improving this further, I just wrote this up quickly to get things started
  12. Here is a simple class I have written to retrieve grand exchange information for specified osrs items, using the json file hosted by rsbuddy at: https://rsbuddy.com/exchange/summary.json Note the retrieval of this data should only be done once at the start of your script, and you should store the map for use later rather than re-calling the method. You may also get better performance using a JSON library. RSExchange.java import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.HashMap; import java.util.Map; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; public final class RSExchange { private final String ITEMS_JSON; public RSExchange() { ITEMS_JSON = getItemsJson().orElse(""); } private Optional<String> getItemsJson() { try { URL url = new URL("https://rsbuddy.com/exchange/summary.json"); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); con.setUseCaches(true); BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); String json = br.readLine(); br.close(); return Optional.of(json); } catch (Exception e) { e.printStackTrace(); } return Optional.empty(); } public final Optional<ExchangeItem> getExchangeItem(final String itemName) { return getItemID(ITEMS_JSON, itemName).map(id -> new ExchangeItem(itemName, id)); } public final Map<String, ExchangeItem> getExchangeItems(final String... itemNames) { Map<String, ExchangeItem> exchangeItems = new HashMap<>(); for (final String itemName : itemNames) { getItemID(ITEMS_JSON, itemName).ifPresent(id -> exchangeItems.put(itemName, new ExchangeItem(itemName, id))); } return exchangeItems; } private Optional<Integer> getItemID(final String json, final String itemName) { return getItemFromJson(json, itemName).flatMap(this::getItemIDFromItemJson); } private Optional<String> getItemFromJson(final String json, final String itemName) { Matcher matcher = Pattern.compile("(\\{[^}]*\"name\"\\s*:\\s*\"" + Pattern.quote(itemName) + "\"[^}]*})").matcher(json); return matcher.find() ? Optional.of(matcher.group(1)) : Optional.empty(); } private Optional<Integer> getItemIDFromItemJson(final String json) { Matcher matcher = Pattern.compile("\"id\"\\s*:\\s*(\\d*)").matcher(json); return matcher.find() ? Optional.of(Integer.parseInt(matcher.group(1))) : Optional.empty(); } } ExchangeItem.java import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; public final class ExchangeItem { private final String name; private final int id; private int overallAverage = -1; private int buyAverage = -1; private int sellAverage = -1; private int buyingQuantity; private int sellingQuantity; public ExchangeItem(final String name, final int id) { this.name = name; this.id = id; updateRSBuddyValues(); } public final String getName() { return name; } public final int getId() { return id; } public final int getBuyAverage() { return buyAverage; } public final int getSellAverage() { return sellAverage; } public final int getBuyingQuantity() { return buyingQuantity; } public final int getSellingQuantity() { return sellingQuantity; } public void updateRSBuddyValues() { try { URL url = new URL("http://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + id); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); con.setUseCaches(true); BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); String json = br.readLine(); br.close(); getItemValue("overall", json).ifPresent(overallAverage -> this.overallAverage = overallAverage); getItemValue("buying", json).ifPresent(sellAverage -> this.sellAverage = sellAverage); getItemValue("selling", json).ifPresent(buyAverage -> this.buyAverage = buyAverage); getItemValue("buyingQuantity", json).ifPresent(buyQuantity -> this.buyingQuantity = buyQuantity); getItemValue("sellingQuantity", json).ifPresent(sellingQuantity -> this.sellingQuantity = sellingQuantity); } catch (Exception e) { e.printStackTrace(); } } private Optional<Integer> getItemValue(final String key, final String json) { Matcher overallAvgMatcher = Pattern.compile("\"" + key + "\"\\s*:\\s*(\\d*)").matcher(json); if (overallAvgMatcher.find()) { return Optional.of(Integer.parseInt(overallAvgMatcher.group(1))); } return Optional.empty(); } public final String toString() { return String.format("Name: %s, ID: %d, Overall AVG: %d gp, Buying AVG: %d gp, Selling AVG: %d gp, Buying Quantity: %d, Selling Quantity:%d", name, id, overallAverage, buyAverage, sellAverage, buyingQuantity, sellingQuantity); } } Usage: final RSExchange rsExchange = new RSExchange(); rsExchange.getExchangeItem("Yew logs").ifPresent(System.out::println); This would print out Name: Yew logs, ID: 1515, Overall AVG: 355 gp, Buying AVG: 355 gp, Selling AVG: 354 gp, Buying Quantity: 90576, Selling Quantity :71726
  13. I learned a lot, thanks!
  14. Looking good bawss, nice work. Just a few things you might want to clean up: Firstly, if(getInventory().contains(i -> !i.getName().equals("Cosmic rune") && !i.getName().equals("Sapphire ring"))) Can be replaced with: if(!getInventory().onlyContains("Cosmic rune", "Sapphire ring")) Secondly, I don't think you need to open the magic tab before casting a spell, it will already do that for you. Also when enchanting you don't need to check: if (getMagic().canCast(Spells.NormalSpells.LVL_1_ENCHANT)) Because you already know you have the required runes. Instead, in onStart() you should check if the player has a magic level >= the required, and stop the script if they don't with a useful message: if(getSkills().getStatic(Skill.MAGIC) < Spells.NormalSpells.LVL_1_ENCHANT.getRequiredLevel()) { log("You do not have a magic level high enough to use this script!"); stop(); } In onStart you also may want to check the player is in a P2P world, as enchanting is members only (I think). If they are not in P2P attempt to hop worlds, if it fails, again log a useful message and stop the script: if(!getWorlds().isMembersWorld()) { log("You need to be logged into a members world to use this script."); log("Attempting to hop worlds"); if(!getWorlds().hopToP2PWorld()) { log("Failed to hop to P2P world"); stop(); } } You also haven't made any checks anywhere for if the player has water runes / a staff of water, and no banking to retrieve them.
  15. I'll check it out this weekend / earlier if I have time. Thanks
  16. Just clicks, you will have to write your own methods if you want to do that.
  17. Just use getDialogues().completeDialogue(options) it will click continue and click on any options with the text you specify until the dialogue is over
  18. Awesome, thanks. Feel free to close the thread.
  19. Not sure whether this information is currently accessible or not (I couldn't find it). Currently for premium scripts you can ascertain the popularity of your script by looking at sales. For free scripts you can see the user count on the scripts page. However, for VIP+ scripts there isn't currently a way (I don't think) to see a user count. Could we get access to this information, either on the script page, or just privately on the sales info page?
  20. So you are saying the method "isMoving" should return true even if the npc is not moving? The method is called isMoving() not canMove()
  21. The code I commented with only gets the stall object once, and then stores it. The code you have written here is just a longer way of writing: private Entity teaStall; public final int onLoop() throws InterruptedException { if (teastall == null) teaStall = getObjects().closest("Tea stall"); } Which is exactly what my code does. Also I would not concern yourself with memory usage here.
  22. I assume you mean a global variable? You could do something like that if you wanted to, by doing so you would only need to find the tea stall once: import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "You", info = "My first script", name = "Tea thiever", version = 0.1, logo = "") public final class TeaThiever extends Script { private Entity teaStall; @Override public final int onLoop() throws InterruptedException { if(teaStall == null) teaStall = getObjects().closest("Tea stall"); else if(getInventory().isFull()) getInventory().dropAll(); else if(teaStall.hasAction("Steal-from")) stealFromStall(); return random(200, 300); } private void stealFromStall() { if(teaStall.interact("Steal-from")) { new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); } } }
  23. Explv

    Explv's Walker

    Hopefully if I remember, I will be adding a map to this script this weekend so you can select whatever location you want. I will add sand crabs today though for you
×
×
  • Create New...