infallible 28 Posted November 14, 2015 import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.skills.Skill; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.utilities.Timer; import org.dreambot.api.wrappers.interactive.GameObject; import org.dreambot.api.script.Category; import java.awt.*; /** * Created by xxxx on 11/11/2015. */ @ScriptManifest(author = "Hitsuu", name = "Miner Script", category = Category.MINING, version = 1.00) public class Miner extends AbstractScript { private final Area MINING_AREA = new Area(); private final Area BANK_AREA = new Area(); long startTime = System.currentTimeMillis(); long startingxp = getSkills().getExperience(Skill.MINING); long startingLevel = getSkills().getRealLevel(Skill.MINING); @Override public void onStart() { } @Override public int onLoop() { GameObject myORE = getGameObjects().closest(ore -> ore.getID() == 13447); int oreID = 438; if (getInventory().contains(i -> i.getName().contains("pickaxe")) && !getInventory().contains(oreID)) { mine(myORE); } else if (getInventory().contains(oreID)) { getInventory().dropAll(oreID); } return Calculations.random(300, 600); } @Override public void onExit() { } private double progressBar() { return ((double) (getSkills().getExperience(Skill.MINING) - getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.MINING))) / (getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.MINING) + 1) - getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.MINING)))) * 100; } @Override public void onPaint(Graphics g) { long currentxp = getSkills().getExperience(Skill.MINING); long currentLevel = getSkills().getRealLevel(Skill.MINING); long xpgained = currentxp - startingxp; long xpperhour = xpgained / ((System.currentTimeMillis() - startTime)); long LevelsGained = currentLevel - startingLevel; long oresmined = getInventory().count(i -> i.getID() == 438); g.setColor(new Color(48, 48, 48, 180)); g.fillRect(5, 240, 370, 99); g.setFont(new Font(Font.MONOSPACED, Font.ROMAN_BASELINE, 14)); g.setColor(Color.WHITE); g.drawString("Private Miner -", 10, 260); g.drawString("Runtime: " + Timer.formatTime(System.currentTimeMillis() - startTime), 220, 260); g.drawString("Exp/hr: " + xpperhour , 10, 280); g.drawString("Exp gained: " + xpgained, 10, 300); g.drawString("Levels gained: " + LevelsGained , 220, 320); g.drawRect(10, 310, 100, 15); g.fillRect(10, 310, (int) progressBar(), 15); g.drawString("Ores mined: " + oresmined, 220, 300); } public void mine(GameObject myORE) { int oreID = 438; if(myORE.exists() && myORE.isOnScreen()) { myORE.interact("Mine"); int oreCount = getInventory().count(438); sleepUntil(() -> getInventory().count(oreID)> oreCount, Calculations.random(10000, 15000)); } } } So the bot was working till I started creating the paint. Now whenever I push the script to local and run the bot and hit start, the menus stays up and nothing happens. Can someone tell me what is wrong here?
Dreamlicker 750 Posted November 14, 2015 You have to implement the PaintListener to use paints in the Dreambot API
infallible 28 Author Posted November 14, 2015 You have to implement the PaintListener to use paints in the Dreambot API not sure what that means, I don't see that on any other tutorial.
Nuclear Nezz 2107 Posted November 14, 2015 public class Miner extends AbstractScript implements PaintListener
infallible 28 Author Posted November 14, 2015 public class Miner extends AbstractScript implements PaintListener licker helped me out on Skype, thanks Nezz! I have a question for you though. If I'm using ID's to mine rocks, how do I make the script stop miss-clicking the rocks? Or is that just the client bugging? Like, the client has the object's box larger than it actually is?
infallible 28 Author Posted November 15, 2015 @Override public int onLoop() { int oreID = 440; if (getInventory().contains(i -> i.getName().contains("pickaxe")) && !getInventory().contains(oreID) && MINING_AREA.contains(getLocalPlayer())) { mine(myORE); } else if (getInventory().contains(oreID)) { getInventory().dropAll(oreID); } else if(!MINING_AREA.contains(getLocalPlayer())) { Tile startLocation = getLocalPlayer().getTile(); //walk to MINING_AREA } return Calculations.random(300, 600); I've imported the API for AbstractPath but I'm unsure how to use it. I plan on taking the startLocation as Tile1 and MINING_AREA as Tile 2. Can someone help me with this?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.