import java.awt.*;
import java.util.Map;
import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.script.Script;
import com.speljohan.rsbot.event.events.ServerMessageEvent;
import com.speljohan.rsbot.event.listeners.ServerMessageListener;
import com.speljohan.rsbot.event.listeners.PaintListener;
import java.awt.Graphics;
public class AutoTele extends Script implements PaintListener, ServerMessageListener{
public String where="";
public int spell=0;
public int times=0;
public boolean teled=false;
public int painttimes=0;
public boolean cantele=true;
public int notenough=0;
public double getVersion() {
return 1.2;
}
public String getScriptCategory() {
return "Magic";
}
public String getName() {
return "AutoTele";
}
public String getAuthor() {
return "Tom331";
}
public boolean onStart(Map<String, String> args) {
//Starting Code goes here
Bot.getEventManager().addListener(PaintListener.class, this);
Bot.getEventManager().addListener(ServerMessageListener.class, this);
where=args.get("where");
if (where.equals("Varrock")){
where="var";
spell=15; //16;
}else if(where.equals("Lumbridge")){
where="lum";
spell=18; //19;
}else if(where.equals("Falador")){
where="fal";
spell=21; //23;
}else if(where.equals("House")){
where="house";
spell=23; //25;
}else if(where.equals("Camelot")){
where="cam";
spell=26; //28;
}else if(where.equals("Ardougne")){
where="ard";
spell=32; //34;
}else if(where.equals("Watchtower")){
where="wat";
spell=37; //39;
}else if(where.equals("Trollheim")){
where="troll";
spell=44; //46;
}else if(where.equals("Ape Atoll")){
where="ape";
spell=47; //49;
}
return true;
}
public int loop() {
try{
//code goes here
if(cantele==false){
log("Not enough runes to do the spell or not a high enough level!");
log("You teleported "+times + " times");
log("Stopping the script");
return -1;
}
if (canContinue()){clickContinue();}
if(getMyPlayer().getAnimation()==-1){
wait(300);
if(getMyPlayer().getAnimation()==-1){
openTab(TAB_MAGIC);
atInterface(192,spell);
wait(random(500,800));
if(teled=true){
times=times+1;
teled=false;
}
}
}else if (getMyPlayer().getAnimation()!=-1);{
teled=true;
}
}catch(Exception e){
log("An exception has occurred.");
}
return 0;
}
public String getScriptDescription() {
String html = "";
html += "<html>\n";
html += "<body>\n";
html += "<center>\n";
html += "<font size=\"5\">AutoTele by Tom331</font><br><br>";
html += "</center>";
html += "<select name=\"where\"><option selected>Varrock<option>Lumbridge<option>Falador<option>House<option>Camelot<option>Ardougne<option>Watchtower<option>Trollheim<option>Ape Atoll</select>";
html += "</body>";
html += "</html>";
return( html );
}
public void onRepaint(Graphics g) {
g.setColor(Color.BLUE);
g.drawString("Teleported " + times + " times" ,333,16);
}
public void serverMessageRecieved(ServerMessageEvent e) {
if(e.getMessage().contains("do not have enough")){
cantele=false;
}
if(e.getMessage().contains("level is not high enough")){
cantele=false;
}
}
public void onFinish(){
Bot.getEventManager().removeListener(PaintListener.class, this);
Bot.getEventManager().removeListener(ServerMessageListener.class, this);
if(cantele==true){
log("You teleported "+times + " times");
}
notenough=0;
cantele=true;
}
}