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
  • Need Help With a simple Script


    ProBotterIamN
     Share

    Recommended Posts

    So i am working on a simple script to learn the basics and so on so now i am far but getting errors

    package cabbagepicker;
    
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.container.impl.bank.BankLocation;
    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.ScriptManifest;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    @ScriptManifest(author = "ProBotterIamN", name = "Cabbage Picker", version = 1.0, description = "Will get you to Level 99 Cabbage Picking", category = Category.MONEYMAKING)
    public class cabbagepicker extends AbstractScript {
    
    	public void onStart() {
    		log("Starting Script!");
    		log("Enjoy getting 99 Cabbage Picking!");
    		log("Leave feedback!");
    
    	}
    
    	private enum State {
    		BANK, WALK_FIELD, WALK_BOX, PICK, WAIT
    	};
    
    	private State getState() {
    		getGameObjects().closest("Bank Deposit Box");
    		if (!getInventory().isFull())
    			return State.BANK;
    		getGameObjects().closest("Cabbage");
    			if (!getInventory().isEmpty())
    			return State.PICK;
    		return State.WAIT;
    	}
    
    	public void onExit() {
    		log("Hope you reached level 99 Cabbage Picking!");
    		log("Leave Feedback plx!");
    	}
    
    	Tile deposit = new Tile(3045, 3235); // Deposit Box
    	Tile cabbage = new Tile(3052, 384); //Field
    	
    	@Override
    	public int onLoop() {
    		switch (getState()) {
    		case PICK:
    				if(cabbage.distance(getLocalPlayer()) <= 4) { //Checks if Cabbage is in a 4 Tile range of char
    					if(!getInventory().isEmpty()) { //Checks if inventory is empty
    						log("Picking Vegtables!"); //Puts Text In Log
    						cabbage.interact("Pick");//Interacts with Cabbage
    			
    				}else{
    					log("Walking to Field!"); //Status: Walking to box
    					getWalking().walk(cabbage.getRandomizedTile());
    					sleep(Calculations.random(1827,2482));
    				}
    				}
    		case BANK:
    			if(getBank().isOpen()){
    				getBank().depositAllItems();
    				sleep(Calculations.random(900,1200));
    			}
    			else{
    				getBank().open();
    				Calculations.random(900,1200);
    			}
    			break;
    		case WAIT:
    			sleep(300);
    			break;
    			WALK:
    				getWalking().walk(cabbage.getRandomizedTile());
    			if(!getInventory().isEmpty()) {
    				log("Walking to Field!");
    					}
    				}Calculations.random(2400,2800);
    			}else{
    			if(field.contains(getLocalPlayer())){
    				final GameObject gate = getGameObjects().closest(gate){
    					public boolean match(GameObject go){
    						if(go == null || go.getName() == null)
    							return false;
    						if(!go.getName().equals("Gate"))
    							return false;
    						if(!go.getTile().equals(new Tile(3253,3266,0)))
    							return false;
    						return true;
    					}
    				}
    		return Calculations.random(500, 600);
    	}
    			}
    

    So the errors are here

    case PICK:
    				if(cabbage.distance(getLocalPlayer()) <= 4) { //Checks if Cabbage is in a 4 Tile range of char
    					if(!getInventory().isEmpty()) { //Checks if inventory is empty
    						log("Picking Vegtables!"); //Puts Text In Log
    						cabbage.interact("Pick");//Interacts with Cabbage
    			
    				}else{
    					log("Walking to Field!"); //Status: Walking to box
    					getWalking().walk(cabbage.getRandomizedTile());
    					sleep(Calculations.random(1827,2482));
    				}
    				}
    

    and here

    case WAIT:
    			sleep(300);
    			break;
    			WALK:
    				getWalking().walk(cabbage.getRandomizedTile());
    			if(!getInventory().isEmpty()) {
    				log("Walking to Field!");
    					}
    				}Calculations.random(2400,2800);
    			}else{
    			if(field.contains(getLocalPlayer())){
    				final GameObject gate = getGameObjects().closest(gate){
    					public boolean match(GameObject go){
    						if(go == null || go.getName() == null)
    							return false;
    						if(!go.getName().equals("Gate"))
    							return false;
    						if(!go.getTile().equals(new Tile(3253,3266,0)))
    							return false;
    						return true;
    					}
    				}
    		return Calculations.random(500, 600);
    	}
    			}
    

     


    Ok now i just removed all the lines about picking and interacting so all thats left in the script is the walking instead of either walking to the depo box in port sarim or the cabbage field it walks to the bank in draynor lol

    Link to comment
    Share on other sites

    For one your brackets are misplaced, another would be your checking if the inventory is not empty and your comment says something different.

    if(cabbage.distance(getLocalPlayer()) <= 4) { //Checks if Cabbage is in a 4 Tile range of char
                        if(!getInventory().isEmpty()) { //Checks if inventory is empty
                            log("Picking Vegtables!"); //Puts Text In Log
                            cabbage.interact("Pick");//Interacts with Cabbage
                
                    
    }else{
                        log("Walking to Field!"); //Status: Walking to box
                        getWalking().walk(cabbage.getRandomizedTile());
                        sleep(Calculations.random(1827,2482));
                    }
                    }

    Also why do you call gameobjects twice for no reason

    getGameObjects().closest("Bank Deposit Box");

            if (!getInventory().isFull())
                return State.BANK;
            getGameObjects().closest("Cabbage");
                if (!getInventory().isEmpty())
                return State.PICK;
            return State.WAIT;
        }

    Edited by Towlie
    Link to comment
    Share on other sites

    For one your brackets are misplaced, another would be your checking if the inventory is not empty and your comment says something different.

    if(cabbage.distance(getLocalPlayer()) <= 4) { //Checks if Cabbage is in a 4 Tile range of char

                        if(!getInventory().isEmpty()) { //Checks if inventory is empty

                            log("Picking Vegtables!"); //Puts Text In Log

                            cabbage.interact("Pick");//Interacts with Cabbage

                

                    }else{

                        log("Walking to Field!"); //Status: Walking to box

                        getWalking().walk(cabbage.getRandomizedTile());

                        sleep(Calculations.random(1827,2482));

                    }

                    }

    Also why do you call gameobjects twice for no reason

    getGameObjects().closest("Bank Deposit Box");

            if (!getInventory().isFull())

                return State.BANK;

            getGameObjects().closest("Cabbage");

                if (!getInventory().isEmpty())

                return State.PICK;

            return State.WAIT;

        }

    aye lel but the weird part is the walk method i have now walks to bank in draynor instead of the depo box  i was testing the walking after i removed some things anyways gonna try it out once soccer is done

    Link to comment
    Share on other sites

    aye lel but the weird part is the walk method i have now walks to bank in draynor instead of the depo box  i was testing the walking after i removed some things anyways gonna try it out once soccer is done

    Try using an area instead of a tile.

    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.