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
  • Try asking for help in the chatbox
  • [Thieving] Open source safe cracker


    Lord Rivaldo
     Share

    Recommended Posts

    Here is a free script source for you guys, i wrote this yesterday in 2 minutes because i needed a bot to run while going to sleep.

     

     

    aslong as your name isn't eclipseop or vladboobs don't criticize my code haha

     

     

    OfrYX4U.png

    package thief;
    
    import java.awt.Graphics;
    
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.skills.Skill;
    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.utilities.impl.Condition;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import org.dreambot.api.wrappers.interactive.NPC;
    
    @ScriptManifest(author = "Riet/Trester/Rivaldo", category = Category.THIEVING, description = "", name = "[Riet] safe cracker", version = 0)
    public class looter extends AbstractScript {
    	Timer timer;
    	private Timer t = new Timer();
    	private State state;
    
    	private enum State {
    		LOOTING, BANKING, WAIT;
    	}
    
    	private State getState() {
    		if (getInventory().contains("Lobster")) {
    			return State.LOOTING;
    		}
    		if (getInventory().isFull() || !getInventory().contains("Lobster")) {
    			return State.BANKING;
    		}
    
    		return State.WAIT;
    	}
    
    	public void onStart() {
    		getSkillTracker().start(Skill.THIEVING);
    	}
    	
    	@Override
    	public int onLoop() {
    
    		GameObject safe = getGameObjects().closest("Wall safe");
    		NPC bankguy = getNpcs().closest("Emerald Benedict");
    
    		state = getState();
    
    		switch (state) {
    
    		case LOOTING:
    
    			if (getLocalPlayer().getHealthPercent() < 50) {
    				getInventory().interact("Lobster", "Eat");
    				sleep(1090);
    			} else {
    				if (safe != null) {
    					if (safe.isOnScreen()) {
    						if (!getLocalPlayer().isAnimating()
    								&& !getLocalPlayer().isInteractedWith()
    								&& !getLocalPlayer().isMoving()
    								&& getLocalPlayer().getAnimationDelay() == 0) {
    							safe.interact("Crack");
    							sleep(1790);
    							sleepUntil(new Condition() {
    								public boolean verify() {
    									return !getLocalPlayer().isAnimating();
    								}
    							}, Calculations.random(5000, 12000));
    						}
    					} else {
    						getCamera().rotateToEntity(safe);
    					}
    				}
    			}
    
    		case BANKING:
    
    			if (getBank().isOpen() && !getInventory().contains("Lobster")) {
    				if (getBank().contains("Lobster")) {
    					getBank().depositAllItems();
    					sleepUntil(new Condition() {
    						public boolean verify() {
    							return getInventory().isEmpty();
    						}
    					}, Calculations.random(5000, 12000));
    					getBank().withdraw("Lobster", 7);
    					sleepUntil(new Condition() {
    						public boolean verify() {
    							return getInventory().contains("Lobster");
    						}
    					}, Calculations.random(5000, 12000));
    				} else {
    					System.exit(0);
    				}
    			}
    
    			if (getInventory().isFull() || !getInventory().contains("Lobster")) {
    				if (bankguy != null) {
    					if (!getBank().isOpen()) {
    						if (bankguy.isOnScreen()) {
    							bankguy.interact("Bank");
    							sleep(1090);
    						} else {
    							getCamera().rotateToEntity(bankguy);
    						}
    					}
    				} else {
    					if (getBank().contains("Lobster")) {
    						getBank().depositAllItems();
    						sleepUntil(new Condition() {
    							public boolean verify() {
    								return getInventory().isEmpty();
    							}
    						}, Calculations.random(5000, 12000));
    						getBank().withdraw("Lobster", 7);
    						sleepUntil(new Condition() {
    							public boolean verify() {
    								return getInventory().contains("Lobster");
    							}
    						}, Calculations.random(5000, 12000));
    					} else {
    						System.exit(0);
    					}
    				}
    			}
    		case WAIT:
    			break;
    		default:
    			break;
    		}
    
    		return 5;
    	}
    
    	public void onPaint(Graphics g) {
    		if (t == null) {
    			t = new Timer(0);
    		}
    
    		g.drawString("Time running: " + Timer.formatTime(t.elapsed()), 12, 59);
    		g.drawString(
    				"Levels gained: " + getSkills().getRealLevel(Skill.THIEVING)
    						+ "(+"
    						+ getSkillTracker().getGainedLevels(Skill.THIEVING)
    						+ ")", 12, 79);
    		g.drawString(
    				"XP gained: "
    						+ getSkillTracker().getGainedExperience(Skill.THIEVING)
    						+ "("
    						+ getSkillTracker().getGainedExperiencePerHour(
    								Skill.THIEVING) + ")", 12, 91);
    		g.drawString(
    				"XP to level: "
    						+ getSkills().getExperienceToLevel(Skill.THIEVING), 12,
    				103);
    	}
    
    }
    
    
    Edited by Lord Rivaldo
    Link to comment
    Share on other sites

    While my name might not be Eclipseop or Vladboobs I still have some really minor suggestions for your code.

    First of all I am not saying your code is bad, it actually is really good and I hope to see you release some Scripts to the SDN!

    1. Instead of using System#exit you can also just use AbstractScript#stop which will keep the Client up instead of closing it
      (I do realize that System#exit probably was on purpose since you said you wrote this to run it over night)
    2. You have two Timer Objects, one would have been enough and allows you to remove the null check from the Paint
    3. You define two Objects (safe,bankguy) no matter which state it is, you could only define it in the specific case
    4. Wrap methods like Bank#withdraw with an if and sleep inside there, incase the method fails to withdraw you wont stand there sleeping 5-12 seconds
    5. Lambdas are a cool feature of Java8 you should check it out @Notorious post about it
    Edited by Dinh
    Link to comment
    Share on other sites

     

    While my name might not be Eclipseop or Vladboobs I still have some really minor suggestions for your code.

    First of all I am not saying your code is bad, it actually is really good and I hope to see you release some Scripts to the SDN!

    1. Instead of using System#exit you can also just use AbstractScript#stop which will keep the Client up instead of closing it

      (I do realize that System#exit probably was on purpose since you said you wrote this to run it over night)

    2. You have two Timer Objects, one would have been enough and allows you to remove the null check from the Paint
    3. You define two Objects (safe,bankguy) no matter which state it is, you could only define it in the specific case
    4. Wrap methods like Bank#withdraw with an if and sleep inside there, incase the method fails to withdraw you wont stand there sleeping 5-12 seconds
    5. Lambdas are a cool feature of Java8 you should check it out @Notorious post about it

     

    thanks for your reply :) i will look into lambda and the other points can be improved on yeah

    Link to comment
    Share on other sites

    Hey Trester, when did you get unbanned?

    i never get banned arti 

     

    i was always here and evade whenever :) 

     

    besneden lul

    I'm still waiting for the Entrana walker

    HAHAHAHHA

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • 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.