Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Resource [Snippet] Some useful little snippets (random event related)

First Bot Author
Joined
Aug 7, 2013
Messages
262
Shut down your script when a random event teleports you to a random location:
Code:
//Declare this field anywhere in your class
    private Coordinate lastPosition;

//Create this method anywhere in your class
    private void teleportCheck() {
        final Player player = Players.getLocal();
        final Coordinate currentPosition = player != null ? player.getPosition() : null;
     
        if (currentPosition != null) {
            if (lastPosition == null) {
                lastPosition = currentPosition;
            } else if (lastPosition.distanceTo(currentPosition) > 50) {
                Game.logout(true);
                stop();
            } else {
                lastPosition = currentPosition;
            }
        }
    }

//Paste this at the top of your onLoop:
        teleportCheck();
 
Last edited:
Top