Botre Posted June 25, 2014 Posted June 25, 2014 Wrote this mainly for the cooldown timer. setCooldown(Message message) goes in the onMessage method of the script instance you use it in. Constructive feedback is appreciated as always! public class LumbridgeHomeTeleporter { private Script script; private int cooldown; public LumbridgeHomeTeleporter(final Script script) { this.script = script; Thread cooldownTimer = new Thread(new Runnable() { public void run() { while (true) { try { MethodProvider.sleep(60000); if (cooldown > 0) { --cooldown; } } catch (InterruptedException e) { e.printStackTrace(); } } } }); cooldownTimer.start(); } public void teleport() throws InterruptedException { if (this.cooldown == 0 && this.script.skills.getDynamic(Skill.MAGIC) > 0) { Timer timer = new Timer(); if (this.script.magic.castSpell(Spell.HOME_TELEPORT)) { while (this.cooldown == 0 && !this.script.map.canReach(LocationArea.LUMBRIDGE_TELEPORT_AREA.getArea().getRandomPosition(0)) && timer.getElapsed() < 10000) { MethodProvider.sleep(600); } } } } public void setCooldown(Message message) { if (message.getType().equals(Message.MessageType.GAME) && message.getMessage().toLowerCase().contains("you need to wait another")) { String match = null; Pattern pattern = Pattern.compile("[0-9]+"); Matcher matcher = pattern.matcher(message.getMessage()); while (matcher.find()) { match = matcher.group(); } this.cooldown = Integer.parseInt(match); } } public int getCooldown() { return this.cooldown; } } h 2
Khaleesi Posted June 26, 2014 Posted June 26, 2014 (edited) 11/10 would ... Edited June 26, 2014 by Khaleesi
arm2 Posted June 26, 2014 Posted June 26, 2014 How long have you been scripting for? 1 week?... no wait.... 10/10