Jump to content

clicking issues


Recommended Posts

Posted

ok so im using apaecs tea thiever and ive been rewriting it myself or at least trying to and only using bits and pieces of his tut code the issue im running into and what im wondering how to get rid of is when it clicks the tea stall to thief it clicks 4 times instead of once and in different locations is there a way i can change that so it clicks in 1 spot so it doesnt end up running off and getting stuck behind the stall?

Posted (edited)

You could add a check for where your character stands before thieving. So it makes sure it's standing at those coordinates before it thieves. And if it isn't you can make it walk to that tile. Also you need to have a sleep after clicking otherwise it will try to spamclick the thieving stall because it checks for the stall multiple times before it is actually thieved. Because the tea stall doesn't become empty right at the moment you click it right?

Edited by September
Posted

You could add a check for where your character stands before thieving. So it makes sure it's standing at those coordinates before it thieves. And if it isn't you can make it walk to that tile. Also you need to have a sleep after clicking otherwise it will try to spamclick the thieving stall because it checks for the stall multiple times before it is actually thieved. Because the tea stall doesn't become empty right at the moment you click it right?

 

yea it spam clicks but it clicks all the points on the stall that have the "Steal-from" option but yea that would prolly do it to add a sleep after the first click.. u thing 1000 is long enough or should i made it a little longer? and im not entirely sure where to put the sleep in the code

the sleep worked lol idk if its codes the prettiest but it works lmao thank you :)

Posted (edited)

yea it spam clicks but it clicks all the points on the stall that have the "Steal-from" option but yea that would prolly do it to add a sleep after the first click.. u thing 1000 is long enough or should i made it a little longer? and im not entirely sure where to put the sleep in the code

the sleep worked lol idk if its codes the prettiest but it works lmao thank you smile.png

 

I have rewritten it slightly. I put the onLoop code inside if(!myPlayer().isAnimating())  so that it will not click the Tea stall if it is already thieving. Then I added a ConditionalSleep after the interaction, which stops sleeping when the player has begun animating.

 

(untested)

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(author = "You", info = "My first script", name = "Tea thiever", version = 1.0, logo = "")
public class TeaStealer extends Script {

    private enum State { STEAL, DROP }

    @Override
    public int onLoop() throws InterruptedException {

        if(!myPlayer().isAnimating()) {

            switch (getState()) {

                case STEAL:
                    steal();
                    break;
                case DROP:
                    drop();
                    break;
            }
        }
        return random(200, 300);
    }

    private State getState() {

        if(getInventory().isFull()) return State.DROP;
        return State.STEAL;
    }

    private void steal(){

        Entity stall = getObjects().closest("Tea stall");
        if (stall != null) {

            stall.interact("Steal-from");
            new ConditionalSleep(2000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return myPlayer().isAnimating();
                }
            }.sleep();
        }
    }

    private void drop(){

        getInventory().dropAll();
    }
}
Edited by Explv

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...