Jump to content

GE price checker (in the works)


alex_unique_modifi

Recommended Posts

checks price of herbs in the GE.

image.png.5cabc3024d51f584de2a0129dd6b5d71.png

it works so far, more features to come!

feel free to contribute by adding on more herbs/items

credits to help from suko, cryptocode, yukki from discord

import com.epicbot.api.shared.APIContext;
import com.epicbot.api.shared.GameType;
import com.epicbot.api.shared.methods.IGrandExchangeAPI;
import com.epicbot.api.shared.model.ge.GrandExchangeItemDetail;
import com.epicbot.api.shared.model.ge.GrandExchangeSlot;
import com.epicbot.api.shared.script.LoopScript;
import com.epicbot.api.shared.script.ScriptManifest;
import com.epicbot.api.shared.util.paint.frame.PaintFrame;
import com.epicbot.api.shared.util.time.Time;

import java.awt.*;
import java.util.LinkedHashMap;

@ScriptManifest(name = "Test Script", gameType = GameType.OS)
public class TestClass extends LoopScript {
    private final LinkedHashMap<String, Integer> items_to_check = new LinkedHashMap<String, Integer>() {{
        put("Grimy guam leaf", 199);
        put("Guam leaf", 249);
        put("Grimy marrentill", 201);
        put("Marrentill", 251);
        put("Grimy tarromin", 203);
        put("Tarromin", 253);
        put("Grimy harralander", 205);
        put("Harralander", 255);
    }};
    private LinkedHashMap<String, Integer> marketprices = new LinkedHashMap<String, Integer>(){};
    @Override
    public boolean onStart(String... strings) {
        Time.sleep(3000);
        getMarketPricesFromOSRS();
        return true;
    }
    @Override
    protected int loop() {
        System.out.println("======Market prices from OSRS======");
        printOSRSPrices();
        //for (String item: items_to_check.keySet()){
        //    priceCheck(item);
        //}
        return 1550; // delay for 1.55 seconds
    }
    @Override
    protected void onPaint(Graphics2D g, APIContext ctx) {
        PaintFrame frame = new PaintFrame("GE price checker (herbs)");
        frame.addLine("Status", "Price checking in progress...");
        frame.draw(g, 0, 170, ctx);
    }
    IGrandExchangeAPI ge(){
        return getAPIContext().grandExchange();
    }
    void getMarketPricesFromOSRS(){
        for (String item: items_to_check.keySet()) {
            int id = items_to_check.get(item);
            GrandExchangeItemDetail itemDetail = ge().getItemDetails(id);
            int price = itemDetail.getCurrentPrice();
            Time.sleep(200);
            marketprices.put(item,price);
        }
    }
    void printOSRSPrices(){
        for (String item: marketprices.keySet()) {
            int price = marketprices.get(item);
            System.out.println(item+" "+price);
        }
    }
    private int priceCheck(String item){ // work in progress for actual buying and selling
        //todo withdraw coins from bank first
        if (!ge().isOpen()){
            System.out.println("Opening GE");
            ge().open();
        }
        Time.sleep(1500);
        if (!ge().isOpen()){
            System.out.println("Unable to open GE.");
            return -1; // cant open ge
        }
        GrandExchangeSlot emptySlot = null;
        for (GrandExchangeSlot slot : ge ().getSlots()){
            if (!slot.inUse()){
                emptySlot=slot;
                break;
            }
        }
        if (emptySlot==null){
            System.out.println("No empty slots in GE.");
            return -2; // no empty slots in ge
        }
        emptySlot.placeBuyOffer(item,1,-1);
        Time.sleep(1500);
        return 1;
    }
}

 

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.

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...