- Joined
- Aug 7, 2013
- Messages
- 262
- Thread Author
- #1
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: