Jump to content

Welcome to DreamBot!

Download for Free

Supercharge Your Bots

Run unlimited bots today using DreamBot's Covert Mode and
stay more protected.

Upgrade Now
Frequently Asked Questions
  • Are you not able to open the client? Make sure you have Java installed
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Creating a Muling Script (FULL SOURCE)


    Recommended Posts

    TLDR; Run stuff in new threads in order to accomplish this.

    So in order to do this we need forms, threads, socket connection, etc.

    The only problem I had with this was the child thread can't really call and get "old script". But I'm sure there is way around that. This will show how you get from Point A (NOTHING) -> Forms with message system that sends message to other script that is "slave". I based all this on @Hashtag's muling script btw if u wanna know inspiration.

    The .JAR included at the bottom is totally UNFILTERED. This was my attempt at a wildy killing muling script for F2P. I will note here it doesn't fully work. But u can still see what i was trying to accomplish. I will admit this code is pretty crazy stupid but i just screw around anyway to try to get what i wanted for fun. But most of the script does work.

    e3b042?filename=1602398789558_11-10-2020

        private void button5ActionPerformed(ActionEvent e) {
            // Slave start
            this.setVisible(false);
            SwingUtilities.invokeLater(() -> {
                ctx.gui3 = new SlaveWindow(ctx);
                ctx.gui3.setBackground(Color.BLACK);
                ctx.gui3.setResizable(false);
                ctx.gui3.setVisible(true);
            });
            int port = Integer.parseInt(spinner1.getValue().toString());
            Thread t = new Thread() {
                public void run() {
                    Script ctx1 = null;
                    ctx1 = ctx;
                    Socket clientSocket1 = null;
                    PrintWriter out1 = null;
                    BufferedReader in1 = null;
                    String resp1 = null;
                    try {
                        clientSocket1 = new Socket(textField1.getText(), port);
                        out1 = new PrintWriter(clientSocket1.getOutputStream(), true);
                        in1 = new BufferedReader(new InputStreamReader(clientSocket1.getInputStream()));
                        out1.println("stay alive");
                    } catch (Exception ex2) {
                        ctx1.log(ex2.toString());
                    }
                    while (!ctx1.gui.hooray) {
                        try {
                            Thread.sleep(9000);
                            if (((int) ctx1.timeRan.elapsed()) > 50000) {
                                out1.println("stay alive");
                                ctx1.timeRan = new Timer();
                            }
                            if (in1.ready())
                                resp1 = in1.readLine();
                            if (resp1 != null) {
                                ctx1.log(resp1);
                                if (resp1.contains("collect")) {
                                    out1.println("received" + "|" + Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getName() + "|" + Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getLevel());
                                    Instance.getInstance().getScriptManager().getCurrentScript().getRandomManager().enableSolver("Login Handler");
                                    ctx1.sleepUntil(() -> Client.getGameState().equals(GameState.LOGGED_IN), 20000);
                                    out1.println("received" + "|" + Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getName() + "|" + Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getLevel());
                                    /*
                                    if (Client.getGameState().equals(GameState.LOGGED_IN)) {
                                        Instance.getInstance().getScriptManager().getCurrentScript().setState(ScriptManager$State.PAUSED);
                                        ctx1.currTile = Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getTile();
                                        while (!Bank.isOpen()) {
                                            Bank.openClosest();
                                            out1.println("received" + "|" + Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getName() + "|" + Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getLevel());
                                            ctx1.sleepUntil(() -> Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().isMoving(), 2000);
                                            ctx1.sleepUntil(() -> !Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().isMoving(), 60000);
                                        }
                                        if (!Bank.isOpen()) break;
                                        ctx1.sleep(1000);
                                        Bank.depositAllItems();
                                        ctx1.sleep(1500);
                                        Bank.depositAllEquipment();
                                        ctx1.sleep(1500);
                                        Bank.withdrawAll("Coins");
                                        ctx1.sleep(1500);
                                        Bank.close();
                                        String[] slaveInfo = resp1.split("\\|");
                                        int wildyLvl = Math.max(Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getLevel(), Integer.parseInt(slaveInfo[2])) - Math.min(Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getLevel(), Integer.parseInt(slaveInfo[2]));
                                        String slaveName = slaveInfo[1];
                                        if (wildyLvl <= 1)
                                            ctx1.wildyTile = ctx1.level1Tile;
                                        else if (wildyLvl <= 5)
                                            ctx1.wildyTile = ctx1.level5Tile;
                                        else if (wildyLvl <= 10)
                                            ctx1.wildyTile = ctx1.level10Tile;
                                        else if (wildyLvl <= 15)
                                            ctx1.wildyTile = ctx1.level15Tile;
                                        else if (wildyLvl <= 20)
                                            ctx1.wildyTile = ctx1.level20Tile;
                                        else if (wildyLvl <= 25)
                                            ctx1.wildyTile = ctx1.level25Tile;
                                        else if (wildyLvl <= 30)
                                            ctx1.wildyTile = ctx1.level30Tile;
                                        else if (wildyLvl <= 35)
                                            ctx1.wildyTile = ctx1.level35Tile;
                                        while (Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getTile().distance(ctx1.beforeTile) < 1) {
                                            Walking.walkExact(ctx1.beforeTile);
                                            ctx1.sleepUntil(() -> Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().isMoving(), 2000);
                                            ctx1.sleepUntil(() -> !Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().isMoving(), 60000);
                                        }
                                        GameObject gobj = GameObjects.closest(go -> go.getName().toLowerCase().contains("ditch"));
                                        if (gobj != null)
                                            gobj.interact("Cross");
                                        if (!WorldHopper.isWorldHopperOpen()) {
                                            WorldHopper.openWorldHopper();
                                            ctx1.sleepUntil(() -> WorldHopper.isWorldHopperOpen(), Calculations.random(500, 3000));
                                        }
                                        ctx1.sleep(2500);
                                        Instance.getInstance().getScriptManager().getCurrentScript().getRandomManager().disableSolver("Login Handler");
                                        if (ctx1.overDitch.contains(Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getTile())) {
                                            while (Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getTile().distance(ctx1.wildyTile) < 1) {
                                                Walking.walkExact(ctx1.wildyTile);
                                                ctx1.sleepUntil(() -> Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().isMoving(), 2000);
                                                if ((Players.closest(p -> p != null && !p.equals(Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer()) && p.distance() < 15 && p.getName() != slaveName) != null)) {
                                                    Tabs.logout();
                                                    WorldHopper.hopWorld(Worlds.getRandomWorld(w -> w != null && !w.isPVP() && !w.isLastManStanding() && !w.isHighRisk() && !w.isDeadmanMode() && !w.isMembers() && !w.isTournamentWorld() && !w.isTwistedLeague() && (!(w.getMinimumLevel() > 100))));
                                                    ctx1.sleepUntil(() -> (!Client.getGameState().equals(GameState.HOPPING)), Calculations.random(4000, 8000));
                                                    Instance.getInstance().getScriptManager().getCurrentScript().getRandomManager().enableSolver("Login Handler");
                                                }
                                            }
                                        }
                                        if (Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getTile().distance(ctx1.wildyTile) < 1) {
                                            while (true) {
                                                if (in1.ready())
                                                    if (in1.readLine().contains("World")) {
                                                        resp1 = in1.readLine();
                                                        out1.println("worrec");
                                                        if (!WorldHopper.isWorldHopperOpen());
                                                        {
                                                            WorldHopper.openWorldHopper();
                                                            ctx1.sleepUntil(()->WorldHopper.isWorldHopperOpen(),5000);
                                                        }
                                                        WorldHopper.hopWorld(Integer.parseInt(resp1.substring(resp1.indexOf("d") + 1)));
                                                        ctx1.sleepUntil(() -> (!Client.getGameState().equals(GameState.HOPPING)), Calculations.random(4000, 8000));
                                                        break;
                                                    }
                                                if ((Players.closest(p -> p != null && !p.equals(Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer()) && p.distance() < 15 && p.getName() != slaveName) != null)) {
                                                    Tabs.logout();
                                                    WorldHopper.hopWorld(Worlds.getRandomWorld(w -> w != null && !w.isPVP() && !w.isLastManStanding() && !w.isHighRisk() && !w.isDeadmanMode() && !w.isMembers() && !w.isTournamentWorld() && !w.isTwistedLeague() && (!(w.getMinimumLevel() > 100))));
                                                    ctx1.sleepUntil(() -> (!Client.getGameState().equals(GameState.HOPPING)), Calculations.random(4000, 8000));
                                                    Instance.getInstance().getScriptManager().getCurrentScript().getRandomManager().enableSolver("Login Handler");
                                                }
    
                                            }
                                        }
                                        while (true) {
                                            if (Players.closest(p -> p.getName().equals(slaveName)) != null) {
                                                if (Combat.isAutoRetaliateOn()) {
                                                    Tabs.open(Tab.COMBAT);
                                                    Thread.sleep(2000);
                                                    Combat.toggleAutoRetaliate(true);
                                                    Thread.sleep(2000);
                                                    Players.closest(p -> p.getName().equals(slaveName)).interact("Attack");
                                                }
                                                if (Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().isInCombat()) {
                                                    Walking.walkExact(ctx1.wildyTile.translate(2, 2));
                                                }
                                                if (Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().distance(ctx1.wildyTile) > 30) break;
                                            }
                                        }
                                        Tabs.open(Tab.INVENTORY);
                                        while (Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().getTile().distance(ctx1.currTile) < 1) {
                                            Walking.walkExact(ctx1.currTile);
                                            ctx1.sleepUntil(() -> Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().isMoving(), 2000);
                                            ctx1.sleepUntil(() -> !Instance.getInstance().getScriptManager().getCurrentScript().getLocalPlayer().isMoving(), 120000);
                                        }
                                        Instance.getInstance().getScriptManager().getCurrentScript().setState(ScriptManager$State.RUNNING);
                                    }
                                    */
                                }
                            }
                        } catch (Exception ex) {
                            ctx1.log(ex.toString());
                        }
                        if (ctx.gui.hooray) {
                            try {
                                out1.println(".");
                            } catch (Exception ex3) {
                                ctx.log(ex3.toString());
                            }
                        }
                    }
                    try {
                        clientSocket1.close();
                        in1.close();
                        out1.close();
                    } catch (Exception ex6) { ctx.log(ex6.toString()); }
                }
            };
            t.start();
            //ctx.setState(ScriptManager$State.STOP);
        }

    So this opens when we launch a slave. I commented out the parts that probably don't concern us at all. And might need changing.

    So what happens here?

    We launch a new Thread. Which allows us then to STOP the script. So the script is no longer running. But the thread is still running because of the while loop that checks for this magical "hooray" variable to be true. Hooray doesn't get set to true until this:

            this.addWindowListener(new WindowAdapter(){
                public void windowClosing(WindowEvent e){
                    ctx.gui.hooray = true;
                }
            });

    So until the SLAVE window is closed. Our slave will continue to listen for socket messages. And will send a "Keep alive" every so often to keep the connection from closing.

    This IS THE MOST IMPORTANT PART of the socket:

                            if (in1.ready())
                                resp1 = in1.readLine();

    ReadLine is NOT SAFE. If you try to access it when nothing is there. U WILL CRASH and burn. Hence we have to check for ready().

    So with this we can get responses and check them. And with out.println. We can SEND back to the mule messages. In this instance i decided to send the players level, name, and etc back to the mule in order for the mule to calculate how far in the wilderness he needs to go.

    a "." tells the socket to close up shop.

    For the Mule script we also run it in a new thread for Every Accepted socket connection and we Increment the number of slaves connected on the Mule window.

     

    I'll leave it to you guys to figure it out if u want to use it. Its .JAR here so u can run it and see how it works. Good for scripters who don't necessarily wanna dive at this without some pre code to see and figure out how to do it.

     

    Cheers

    For Full Source. Just decompile the .JAR below.

    TradeRestrictMule.jar

    Edited by LordJashin32
    Link to post
    Share on other sites
    • 2 weeks later...

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    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.

    ×
    ×
    • Create New...