The client is offline due to RuneScape update. You may see instance errors but this is due to the update and not actual instance errors. This should be resolved soon. Join our Discord for more information.

Muling snippet


  • Script Writer

    import org.rspeer.runetek.adapter.component.Item;
    import org.rspeer.runetek.adapter.scene.Player;
    import org.rspeer.runetek.api.commons.Time;
    import org.rspeer.runetek.api.commons.math.Random;
    import org.rspeer.runetek.api.component.Trade;
    import org.rspeer.runetek.api.component.tab.Inventory;
    import org.rspeer.runetek.api.scene.Players;
    import org.rspeer.runetek.providers.RSItemDefinition;
    import org.rspeer.script.task.Task;
    import org.rspeer.ui.Log;
    import java.util.function.Predicate;
    
    
    public class MuleTrade extends Task {
        private static final Predicate<Item> RESTRICTED_ITEMS = item -> {
            String name = item.getName();
            return name.contains(" rune") || name.contains(" of water") || name.contains(" logs") ||
                    name.contains(" ore");
        };
        public static final Predicate<Item> ITEM_TO_MULE = item -> {
            if (RESTRICTED_ITEMS.test(item)) return false;
            RSItemDefinition definition = item.getDefinition();
            return definition != null && definition.isTradable() || item.isExchangeable();
        };
        private String muleName = "Mule";
    
        @Override
        public boolean validate() {
            return Inventory.contains(ITEM_TO_MULE) || Trade.isOpen();
        }
    
        @Override
        public int execute() {
            if (!Trade.isOpen()) {
                Player mule = Players.getNearest(p->muleName.toLowerCase().equals(p.getName().toLowerCase()));
                if (mule == null) {
                    Log.info("No mule found");
                } else if (mule.interact("Trade with")) {
                    Time.sleepUntil(Trade::isOpen, 10000);
                }
            } else {
                if (Trade.isOpen(true) && Trade.isWaitingForMe()) {
                    Log.info("Accepting second screen");
                    Trade.accept();
                } else {
                    if (Inventory.contains(ITEM_TO_MULE)) {
                        Log.info("Offering items");
                        for (Item item : Inventory.getItems(ITEM_TO_MULE)) {
                            Trade.offerAll(item.getId());
                        }
                    } else if (Trade.isWaitingForMe()) {
                        Log.info("Accepting first screen");
                        Trade.accept();
                    }
                }
            }
            return Random.high(500,1000);
        }
    }
    

    A few notes

    • Iterating over items and offering them is 1000x faster than offering one item per task activation
    • Assumes mule inventory is empty, trade window can never be full so no need to check that before offering items
    • Restricted items in this case are some groups of items that fresh F2P accounts cannot trade before 24 hours

 

48
Online

16.5k
Users

1.4k
Topics

19.2k
Posts