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
  • How can I go to a tile, afk then do the same process again with a different tile?


    droola9

    Recommended Posts

    Title really explains it all, I am basically a newbie when it comes to coding and I am sure this is a very easy script to create but am struggling

    here is my code (please don't judge lol):

    public int onLoop() {
        Timer timer;
        Tile lumbridgeBank = new Tile(3209, 3220, 2);
        Tile ge = new Tile(3165, 3487, 0);
        Tile kharid = new Tile(3269, 3168, 0);
        Tile random1 = new Tile(3104, 3393, 0);
        Tile draynor = new Tile(3092, 3243, 0);
        Tile edgeville = new Tile(3098, 3494, 0);
        Tile faladorwest = new Tile(2947, 3368, 0);
        Tile faladoreast = new Tile(3012, 3355, 0);
        Tile rimmington = new Tile(2954, 3225, 0);
        Tile random2 = new Tile(3062, 3337, 0);
        Tile varrockeast = new Tile(3254, 3420, 0);
        Tile varrockwest = new Tile(3185, 3438, 0);
        Tile lumbridge = new Tile(3222, 3217, 0);
        Tile random3 = new Tile(3157, 3243, 0);
        Tile random4 = new Tile(3301, 3520, 0);
        
    
    
    
        if (Players.getLocal().getTile().equals(ge.getTile())) {
            log("AFKing at Grand Exchange");
            timer = new Timer();
            timer.setRunTime(5000);
    
            if(timer.remaining() < 1){
                log("No Time left");
                if (Players.getLocal().getTile().equals(lumbridge.getTile())) {
                    log("AFKing at Lumbridge");
                    sleep(5000);
                } else {
                    Walking.walk(lumbridge);
                }
    
    
                // clicking here
            }else{
                log("Remaining time"+timer.remaining());
                //after one hour, move 1 tile
    
            }
    
    
        } else {
            Walking.walk(ge);
    
        }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
        return 5000;
    }
    Edited by droola9
    Link to comment
    Share on other sites

    I would suggest not using tiles but use areas. That way you afk in a different spot rather than the same tile every time.

    You will also need to handle being idle for an hour. You'll automatically log out if you're afk that long so you'll need to think of a way to interact and stay logged in.

    Don't sleep for a fixed time and don't set the timer for a fixed time either. Use Calculations.random to at least add a bit of randomness to your sleeps. 

     

    Link to comment
    Share on other sites

    17 hours ago, MaximusPrimo said:

    I would suggest not using tiles but use areas. That way you afk in a different spot rather than the same tile every time.

    You will also need to handle being idle for an hour. You'll automatically log out if you're afk that long so you'll need to think of a way to interact and stay logged in.

    Don't sleep for a fixed time and don't set the timer for a fixed time either. Use Calculations.random to at least add a bit of randomness to your sleeps. 

     

    Hey, first off tysm for the reply, the timers are not even my main problem, it's just that I can't create the logic of it going to a place afking and then going to another place afking and so on, what happens is when the timer is up for the first afking spot, it moves and then returns back to the first spot, I think am fucking up the "else" somehow tbh

    Link to comment
    Share on other sites

    You could have a Tile called goalTile which you'd set to whichever tile you'd want to walk towards, and if you reach it (goalTile.distance() is less than some amount, 10 or w/e) then you can start a Timer for however long you want to wait and change goalTile to the next tile. At the start of your onLoop you can check if the timer isn't finished, and just return early so it keeps looping while doing nothing.

    Link to comment
    Share on other sites

    6 hours ago, droola9 said:

    Hey, first off tysm for the reply, the timers are not even my main problem, it's just that I can't create the logic of it going to a place afking and then going to another place afking and so on, what happens is when the timer is up for the first afking spot, it moves and then returns back to the first spot, I think am fucking up the "else" somehow tbh

    You could try setting the timer for 20h or however long you want the bot to run. Then use If statements to check if timer remaining is between 20h and 19h, then go grand exchange. If between 19h and 18h go lumbridge etc..

    Not the best way to handle it but easy enough to figure out if you want something working

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