Purple Posted January 21, 2016 Posted January 21, 2016 Changes your OSBot frame title to show your current IP address of your bot. Source import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import javax.swing.*; import java.awt.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; @ScriptManifest(author = "Purple", name = "IP Display Changer", version = 1.01, info = "Changes the title of your osbot to display your bots IP address.", logo = "") public class Display extends Script { @Override public int onLoop() throws InterruptedException { changeFrameTitle("OSBot (" + getCurrentIPAddress() + ")"); stop(false); return 0; } public void changeFrameTitle(final String title) { for(Frame frame : Frame.getFrames()) { if(frame.isVisible() && frame.getTitle().startsWith("OSBot")) { SwingUtilities.invokeLater(() -> frame.setTitle(title)); break; } } } public String getCurrentIPAddress() { try { URL url = new URL("http://myip.dnsomatic.com/"); BufferedReader b = new BufferedReader(new InputStreamReader(url.openStream())); String ip = b.readLine(); b.close(); return ip; } catch (Exception e) { e.printStackTrace(); } return "null"; } } 9
Purple Posted January 22, 2016 Author Posted January 22, 2016 where do i have to safe this ? You have to compile it and save it to your scripts folder located in C:\Users\YOUR_NAME_HERE\OSBot\Scripts
Zappster Posted January 22, 2016 Posted January 22, 2016 Wouldn't this be less intensive if this was in the onStart() instead on onLoop() since you only need to set the IP once? Nice job anyways 1
Rudie Posted January 22, 2016 Posted January 22, 2016 (edited) Wouldn't this be less intensive if this was in the onStart() instead on onLoop() since you only need to set the IP once? Nice job anyways @Override public int onLoop() throws InterruptedException { changeFrameTitle("OSBot (" + getCurrentIPAddress() + ")"); stop(false); return 0; } changeFrameTitle("OSBot (" + getCurrentIPAddress() + ")"); stop(false); stop(false); since you only need to set the IP once Edited January 22, 2016 by Rudie 2
Okabe Posted February 25, 2016 Posted February 25, 2016 Wouldn't this be less intensive if this was in the onStart() instead on onLoop() since you only need to set the IP once? Nice job anyways @Override public int onLoop() throws InterruptedException { changeFrameTitle("OSBot (" + getCurrentIPAddress() + ")"); stop(false); return 0; } changeFrameTitle("OSBot (" + getCurrentIPAddress() + ")"); stop(false); stop(false); XD onstart is still the proper use tho.
Birdaking Posted March 4, 2016 Posted March 4, 2016 how do i get this compiled? same, i have eclipse i just have no idea what to do with this code =[
Caesar Posted March 4, 2016 Posted March 4, 2016 can someone do a massive solid for me and compile this? It'll save me the hour or two figuring it out