styxa Posted February 11, 2018 Share Posted February 11, 2018 (edited) This is a simple afker script. The script clicks between inventory and skill tabs at random intervals to prevent logout. The intervals are 3-4,5 minutes. Put the jar file to C:\Users\USERNAME\OSBot\Scripts and the script should appear on your script list in the client. Download: StyxAfker.jar v1.01 Source: Spoiler import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.Color; import java.awt.Graphics2D; import org.osbot.rs07.api.ui.Tab; @ScriptManifest( author = "styxa", name = "StyxAfker", version = 1.01, info = "Afks; clicks inventory and skill tabs to prevent logout.", logo = "https://i.imgur.com/d69IFDq.png" ) public class StyxAfker extends Script { private String scriptName; private String scriptAuthor; private double scriptVersion; private long startTime; private long afkTimer; private int afkLimit; public void onStart() { scriptName = getName(); scriptAuthor = getAuthor(); scriptVersion = getVersion(); log("Welcome to " + scriptName + " v"+scriptVersion+"! Script author: "+scriptAuthor); log("This script clicks between inventory and skill tabs in random intervals to prevent logout."); startTime = System.currentTimeMillis(); afkTimer = System.currentTimeMillis(); afkLimit = random(180000, 270000); //180000ms = 3min, 270000ms = 4,5min } public enum State { WAIT, OPEN_TAB } private State getState() { if (System.currentTimeMillis() - afkTimer >= afkLimit){ afkTimer = System.currentTimeMillis();//reset afkTimer afkLimit = random(180000, 270000);//generate new afkLimit return State.OPEN_TAB; } return State.WAIT; } public int onLoop() throws InterruptedException { switch (getState()) { case WAIT: sleep(random(1000, 2000)); break; case OPEN_TAB: openTab(); break; } return random(300, 600); } public void onPaint(Graphics2D g) { g.setColor(new Color(0, 0, 0, 95)); g.fillRect(4, 240, 140, 50); g.setFont(g.getFont().deriveFont(14.0f)); //script name and version g.setColor(Color.decode("#004d66")); g.drawString(scriptName+" v"+scriptVersion, 11, 261); g.setColor(Color.decode("#1ac6ff")); g.drawString(scriptName+" v"+scriptVersion, 10, 260); //time ran final long runTime = System.currentTimeMillis() - startTime; g.setColor(Color.decode("#006600")); g.drawString("Time ran: "+formatTime(runTime), 11, 281); g.setColor(Color.decode("#00ff00")); g.drawString("Time ran: "+formatTime(runTime), 10, 280); //script author g.setColor(Color.gray); g.setFont(g.getFont().deriveFont(10.0f)); g.drawString("script by "+scriptAuthor, 690, 10); } public final String formatTime(final long ms){ long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24; s %= 60; m %= 60; h %= 24; return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s) : h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d:%02d",h, m, s); } void openTab() { if (getTabs().getOpen().equals(Tab.INVENTORY)) {//if inventory is open, open skills if(getTabs().open(Tab.SKILLS)); } else if (getTabs().getOpen().equals(Tab.SKILLS)){//if skills is open, open inventory if(getTabs().open(Tab.INVENTORY)); } else {//if some other tab is open, open inventory if(getTabs().open(Tab.INVENTORY)); } } } Credits: Thanks to Apaec for the beginners guide on OSBot scripting: A Beginners Guide to Writing OSBot Scripts (where to get started!) by Apaec Thanks to Explv for the paint tutorial: Explv's Dank Paint Tutorial changelog: Spoiler v1.01 (2018-02-15): -runtime paint now includes days if ran for over 24 hours v1.0 (2018-02-11): -released v1.0 edit history:edit2: uploaded v1.01, new screenshot with 23h runtime, updated source , added changelog edit1: fixed typo, uploaded a new screenshot with longer runtime Edited February 15, 2018 by styxa 2 Quote Link to comment Share on other sites More sharing options...
The Donald Posted February 11, 2018 Share Posted February 11, 2018 Tyvm, just registered for this! Do you mind if I copy the source and make a few tiny adjustments? I won't reupload it here or elsewhere or distribute it in any way. Quote Link to comment Share on other sites More sharing options...
styxa Posted February 11, 2018 Author Share Posted February 11, 2018 6 hours ago, The Donald said: Tyvm, just registered for this! Do you mind if I copy the source and make a few tiny adjustments? I won't reupload it here or elsewhere or distribute it in any way. No, I don't mind. I'm glad the source can be of some help! Quote Link to comment Share on other sites More sharing options...
HastyLife Posted February 11, 2018 Share Posted February 11, 2018 nice gj mate looking forward to see more^^ Quote Link to comment Share on other sites More sharing options...
deadfish Posted April 6, 2018 Share Posted April 6, 2018 I wonder if afk'ing the G.E. limit off is safer than using a free 7qp script, since there really isn't much interaction here at all as opposed to the super repetitive interaction in the 7qp scripts. Thanks for sharing the source man, and for linking the tutorials you referenced. Quote Link to comment Share on other sites More sharing options...
Kid Lethal Posted April 6, 2018 Share Posted April 6, 2018 (edited) Source code behind this is a bit messy, missing a few key stuff like Player movement Entity interactions Chat input Emote performing Stuff like that make it more realistic, although Jagex won't look to ban someone to afk botting for whatever reason that may even be. Good job on your efforts, hope your code gets cleaner as you go along. Edited April 6, 2018 by Kid Lethal Quote Link to comment Share on other sites More sharing options...
jb4 Posted April 6, 2018 Share Posted April 6, 2018 Thanks a lot for this! Quote Link to comment Share on other sites More sharing options...