Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • improving script so i dont get instant ban?


    sipfer

    Recommended Posts

    Hello,

    as the title says, i keep getting banned at around 1day of botting. Anyone could look through my script and tell me some "no no"'s i have mabye done? its not really missclicking or anything, runs pretty smooth. Thank you

    package smither;
    
    import java.awt.Color;
    import java.awt.Graphics;
    
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.utilities.Timer;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import org.dreambot.api.wrappers.interactive.NPC;
    
    @ScriptManifest(category = Category.CRAFTING, name = "amuCrafter", author = "Sipfer", version = 1.1)
    
    public class goldAmu extends AbstractScript{
    	private Timer timer;
    	private int amus = 0;
    	final int profitEach = 33;
    	final Area BANK =  new Area(3269, 3168, 3272, 3164);
    	final Area FURNACE = new Area(3274, 3187, 3279, 3185);
    	final Area GE = new Area(3274, 3187, 3279, 3185);
    	
    	public boolean walkArea(Area toWalk) {
    		if(!toWalk.contains(getLocalPlayer())) {
    			final Tile rng = toWalk.getRandomTile();
    			while(!toWalk.contains(getLocalPlayer())) {
    				getWalking().walk(rng);
    				sleepUntil(() -> (getWalking().getDestinationDistance() < 3),10000);
    				while(toWalk.contains(getWalking().getDestination())) {
    					sleepUntil(() -> toWalk.contains(getLocalPlayer()), 100);
    				}
    			}
    		}
    		return false;
    	}
    	
    	public boolean doSmelting() {
    		if(!getInventory().contains("Amulet mould")) {
    			return false;
    		}
    		log("start smelting");
    		String a = "Gold bar";
    		if(getInventory().contains("Gold bar") && FURNACE.contains(getLocalPlayer())) {
    			log("inv contains gold, at furnace");
    			GameObject furnace = getGameObjects().closest(24009);
    			if(getWidgets().getWidget(446) == null){
    				log("widget not visible");
    				if(!getInventory().isItemSelected()) {
    					log("selecting goldbar");
    					getInventory().interact("Gold bar", "Use");
    					sleep(500);
    				}
    				if(furnace.interact("Use")) {
    					log("wait till widget is up");
    					sleepUntil(() ->  (getWidgets().getWidget(446) != null), 6000);
    					log("is widget visible?");
    				}
    				return false;
    			}
    			else {
    				log("widget visible");
    			}
    			if(getWidgets().getWidget(446).isVisible()) {
    				if(getWidgets().getWidget(446).getChild(34).interact("Make-All")) {
    					log("widget visible");
    					sleepUntil(() -> {
    						if(!getInventory().contains("Gold bar")) {
    							log("no more gold bars");
    							return true;
    						}
    						if(getWidgets().getWidget(233) != null) {
    							log("level uped");
    							return true;
    						}
    						return false;
    					}, 120000);
    				}
    			}
    		}
    		log("no need for smelting");
    		return false;
    	}
    	
    	public boolean doBanking() {
    		if(BANK.contains(getLocalPlayer()) && !getInventory().contains("Gold bar")) {
    			amus = amus + 27;
    			NPC banker = getNpcs().closest("Banker");
    			if(banker != null && banker.interact("Bank") && !getBank().isOpen()) {
    				sleepUntil(() -> getBank().isOpen(), 3000);
    				if(getBank().isOpen()) {
    					log("bank is open");
    				}
    				else {
    					log("failed to open bank");
    					return false;
    				}
    			}
    			if(getBank().isOpen() && (getInventory().contains("Gold amulet (u)") || !getInventory().contains("Gold bar"))){
    				getBank().depositAllExcept("Amulet mould");
    				sleepUntil(() -> (getInventory().fullSlotCount() == 1), 2000);
    				if(getBank().contains("Gold bar")) {
    					if(!getInventory().contains("Amulet mould")) {
    						getBank().withdraw("Amulet mould");
    					}
    					getBank().withdrawAll("Gold bar");
    					sleepUntil(() -> getInventory().contains("Gold bar"), 2000);
    					if (getInventory().contains("Gold bar")){
    						log("banking succesfull");
    						return true;
    					}
    					else {
    						log("something went wrong while banking");
    						return false;
    					}
    				}
    				else {
    					log("no gold in bank");
    					getTabs().logout();
    					stop();
    					return false;
    				}
    			}
    		}
    		else {
    			log("no need for banking");
    		}
    		return false;
    	}
    	
    	@Override
    	public void onStart() {
    		timer = new Timer();
    	}
    	
    	@Override
    	public void onPaint(Graphics g) {
    		g.setColor(Color.GREEN);
    		g.drawString("Time running: "+ timer.formatTime(), 50, 160);
    		g.drawString("Gold amulets crafted: " + amus, 50, 180);
    		g.drawString("Gold amulets p/H: " + timer.getHourlyRate(amus), 50, 200);
    		g.drawString("Profit made: " + profitEach * amus, 50, 220);
    		g.drawString("Profit P/h: " + profitEach * timer.getHourlyRate(amus), 50, 240);
    	}
    	
    	@Override
    	public int onLoop() {
    		doBanking();
    		if(BANK.contains(getLocalPlayer()) && getInventory().contains("Gold bar")) {
    			walkArea(FURNACE);
    		}
    		if(FURNACE.contains(getLocalPlayer()) && !getInventory().contains("Gold bar")) {
    			walkArea(BANK);
    		}
    		doSmelting();
    		return 1;
    	}
    }
    
    
    Link to comment
    Share on other sites

    Probably having static sleep times doesn't help. Rng isn't perfect but I imagine it would make your bots last a bit longer if you used gaussian randoms instead of a fixed sleep time.

    Link to comment
    Share on other sites

    Would really suggest against this. I would recommend not using while statements too, they can get weird at times.

    			while(!toWalk.contains(getLocalPlayer())) {
    				getWalking().walk(rng);
    				sleepUntil(() -> (getWalking().getDestinationDistance() < 3),10000);//Can just use shouldWalk() and perhaps loop this instead of sleepUntil.
    				while(toWalk.contains(getWalking().getDestination())) {
    					sleepUntil(() -> toWalk.contains(getLocalPlayer()), 100);//Completely un needed just make a regular sleep.
    				}
    			}// Anyways it always returns false and you don't use the boolean function of it, so just make it a void.
    

    Also return 1; is the loop speed, for a small script like this, without much interaction you can most likely bump that up to like 200-400ms. Might add more later.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.