Jump to content

StyxAfker [Free]


styxa

Recommended Posts

d69IFDq.png

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

xy7Uxx8.png

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 by styxa
  • Like 2
Link to comment
Share on other sites

  • 1 month later...

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 by Kid Lethal
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...