Jump to content

TheScrub

Members
  • Posts

    1130
  • Joined

  • Last visited

  • Feedback

    100%

Posts posted by TheScrub

  1. What is the bug you encountered: Null Pointers alot of them..

     

    How to reproduce the bug (if possible): get a random esp MAZE

     

    Command line logs + console debugs:

    [ERROR][12/11/13 08:57:19 PM]: Error on executing random worker!

    java.lang.NullPointerException

        at org.osbot.uB.onLoop(zm:10)

        at org.osbot.script.rs2.randoms.RandomManager.scan(ao:273)

        at org.osbot.lpT1.run(cl:265)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

        at java.lang.Thread.run(Unknown Source)

    [iNFO ][12/11/13 08:57:20 PM]: Activating random : Maze

    [iNFO ][12/11/13 08:57:23 PM]: Next door : [x=11300, y=11614, z=2]

    [iNFO ][12/11/13 08:57:28 PM]: Next door : [x=11300, y=11614, z=2]

    [iNFO ][12/11/13 08:57:42 PM]: Exited random : Maze

    [ERROR][12/11/13 08:57:42 PM]: Error on executing random worker!

    java.lang.NullPointerException

        at org.osbot.uB.onLoop(zm:10)

        at org.osbot.script.rs2.randoms.RandomManager.scan(ao:273)

        at org.osbot.lpT1.run(cl:265)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

        at java.lang.Thread.run(Unknown Source)

    [iNFO ][12/11/13 08:57:43 PM]: Activating random : Maze

    [iNFO ][12/11/13 08:57:45 PM]: Next door : [x=11304, y=11616, z=2]

    [iNFO ][12/11/13 08:58:00 PM]: Exited random : Maze

    [ERROR][12/11/13 08:58:00 PM]: Error on executing random worker!

    java.lang.NullPointerException

        at org.osbot.uB.onLoop(zm:10)

        at org.osbot.script.rs2.randoms.RandomManager.scan(ao:273)

        at org.osbot.lpT1.run(cl:265)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

        at java.lang.Thread.run(Unknown Source)

    [iNFO ][12/11/13 08:58:01 PM]: Activating random : Maze

  2. Using Client Version: 1.7.63


    Issue: Bank always trying to scroll to top to grab item even if the item is visable


    Media(Pics\Logs):

     

    Trying to grab tuna but it keeps trying to scroll up!

     

    5Gblm.png

     

    using method withdrawX(int item,item amount)

  3.  

    Sweet super excited how did the test go?

    testing the trader right now if everything looks good we can expect release in 1-2 days

     

     

     

    the test's went alright even though it's buggy it didn't get scammed so that's a good thing but will need alot longer to make it perfect!

  4. This will be far less impressive then our script so therefore I do not care that you release it for free but it will destroy everything because world 1 would be overrun by bots and there wouldn't be any normal players left actually buying the items...

     

    the first sentence is true while you have had months to develop yours so far I've spent about 3hrs working on mine

  5.  

    Stark is going to need this o.o

    Except my script has been complete for almost a week now, before this post was made. It's been pending in SDN upload requests for 5 days.

     

     

    Please no Trolling/Flaming on thread both of you two idc about this crap i'm here to code and to improve my java knowledge!

     

     

    (I know stark your defending yourself but just don't reply to him look at his name...)

  6.  

     

    Stark is going to need this o.o

     

    if you read the terms and conditions you may not use my code for any premium scripts..

     

    do not be talking smack mr asshole

     

    Problem is that you won't know if anyone uses it or not xd

     

    Anyway, some notes:

    public static int mytradescreen = 48;
    

    use correct java naming conventions, if you are coding for yourself I wuldn't give a fuck, but if you are trying to write modular code api/library you need to use conventions or people will have a hard time understanding the code.

    private Script script = Context.script;
    

    Don't use static for the sake of god. You are supposed to use oop with osbot, if you use static the vars will be "shared" to all tabs withing the client. You should init this class with a Script argument instead.

    	public Item[] getItems(int screen) throws InterruptedException {
    		ArrayList<Item> array = new ArrayList<Item>();
    		if (tradeScreenOpen()) {
    			Item[] itemArray = Context.script.client.getInterface(335)
    					.getItems(screen);
    			for (Item i : itemArray) {
    				if (i != null)
    					array.add(i);
    			}
    
    		}
    		return array.toArray(new Item[array.size()]);
    	}
    

    ?????

    getFirstScreenItemByInteger
    

    *ById maybe

    	public static int ourSecondScreen = 37;
    	public static int otherPersonSecondScreen = 40;
    

    There are 4 more childs for second screen messages

     

     

    Only good thing worth mnetioning is the getItemsSecondaryScreen method that seems very clever

     

     

    thanks for the constructive feedback instead of the usual nice good work or i might use this

  7. Stark is going to need this o.o

     

    if you read the terms and conditions you may not use my code for any premium scripts..

     

    do not be talking smack mr asshole

  8. -Edit spammed threads due to lag my commenting got deleted not rewriting the commenting just read through it

     

    Example usage should be there soon

     

    Needs more methods like custom interactions which will be released later

  9. just updated!

     

     

     

    The Trade class

    import java.awt.Point;
    import java.awt.Rectangle;
    import java.text.NumberFormat;
    import java.text.ParseException;
    import java.util.ArrayList;
    import java.util.List;
    
    
    import org.osbot.script.Script;
    import org.osbot.script.mouse.RectangleDestination;
    import org.osbot.script.rs2.model.Item;
    import org.osbot.script.rs2.ui.RS2InterfaceChild;
    
    
    /*
    * Please do not use this api for any money making purposes such as releasing premium scripts
    */
    public class Trade {
        private final int START_WIDTH = 28;
        private final int START_HEIGHT = 82;
        // width+ height includes spacing lengths
        private final int WIDTH = 47;
        private final int HEIGHT = 32;
        private final int TRADE_SCREEN_ONE_PARENT = 335;
        private final int TRADE_SCREEN_ONE_CHILD_MY_ITEMS = 48;
        private final int TRADE_SCREEN_ONE_CHILD_THEIR_ITEMS = 50;
        private final int TRADE_SCREEN_ONE_DECLINE = 18;
        private final int TRADE_SCREEN_ONE_ACCEPT = 17;
    
        private final int TRADE_SCREEN_TWO_PARENT = 334;
        private final int TRADE_SCREEN_TWO_CHILD_MY_ITEMS = 37;
        private final int TRADE_SCREEN_TWO_CHILD_THEIR_ITEMS = 40;
        private final int TRADE_SCREEN_TWO_DECLINE = 21;
        private final int TRADE_SCREEN_TWO_ACCEPT = 20;
    
        private Script script;
    
        public Trade(Script script) {
            this.script = script;
        }
    
        public boolean tradeScreenOneOpen() {
            if (script.client.getInterface(TRADE_SCREEN_ONE_PARENT) != null) {
                RS2InterfaceChild rc = script.client.getInterface(
                        TRADE_SCREEN_ONE_PARENT).getChild(
                        TRADE_SCREEN_ONE_CHILD_MY_ITEMS);
                if (rc != null && rc.isVisible()) {
                    return true;
                }
            }
            return false;
    
        }
    
        public Item[] getItemsFirstScreen(final int screen) {
            if (tradeScreenOneOpen()) {
                if (script.client.getInterface(TRADE_SCREEN_ONE_PARENT) != null) {
                    RS2InterfaceChild rc = script.client.getInterface(
                            TRADE_SCREEN_ONE_PARENT).getChild(screen);
                    if (rc != null && rc.isVisible()) {
                        return script.client.getInterface(TRADE_SCREEN_ONE_PARENT)
                                .getItems(screen);
                    }
                }
            }
            return null;
        }
    
        public int getItemSlot(Item item) {
            Item[] array = getItemsFirstScreen(TRADE_SCREEN_ONE_CHILD_MY_ITEMS);
            if (array != null && array.length > 0) {
                for (int i = 0; i < array.length; i++) {
                    if (array[i] != null) {
                        if (array[i].equals(item)) {
                            return i;
                        }
                    }
                }
            }
    
            return -1;
        }
    
        public int getItemSlot(String item) {
            Item[] array = getItemsFirstScreen(TRADE_SCREEN_ONE_CHILD_MY_ITEMS);
            if (array != null && array.length > 0) {
                for (int i = 0; i < array.length; i++) {
                    if (array[i] != null) {
                        if (array[i].getName() != null) {
                            if (array[i].getName().equalsIgnoreCase(item)) {
                                return i;
                            }
                        }
                    }
                }
            }
    
            return -1;
        }
    
        public int getItemSlot(int item) {
            Item[] array = getItemsFirstScreen(TRADE_SCREEN_ONE_CHILD_MY_ITEMS);
            if (array != null && array.length > 0) {
                for (int i = 0; i < array.length; i++) {
                    if (array[i] != null) {
                        if (array[i].getName() != null) {
                            if (array[i].getId() == item) {
                                return i;
                            }
                        }
                    }
                }
            }
    
            return -1;
        }
    
        public boolean myItemsContains(int item) {
            if (tradeScreenOneOpen()) {
                Item[] array = getItemsFirstScreen(TRADE_SCREEN_ONE_CHILD_MY_ITEMS);
                if (array.length > 0) {
                    for (Item i : array) {
                        if (i != null) {
                            if (i.getId() == item) {
                                return true;
                            }
    
                        }
                    }
                }
            }
            return false;
        }
    
        public Item myItemsGetItem(int item) {
            if (tradeScreenOneOpen()) {
                Item[] array = getItemsFirstScreen(TRADE_SCREEN_ONE_CHILD_MY_ITEMS);
                if (array.length > 0) {
                    for (Item i : array) {
                        if (i != null) {
                            if (i.getId() == item) {
                                return i;
                            }
    
                        }
                    }
                }
            }
            return null;
        }
    
        private Point getPoint(int slot) {
            int column = slot / 4;
            int row = slot % 4;
            int x = (int) (START_WIDTH + (row * WIDTH));
            int y = (int) START_HEIGHT + (column * HEIGHT);
            return new Point(x, y);
        }
    
        public Rectangle getRectangle(int slot) {
            Point p = getPoint(slot);
            return new Rectangle(p.x, p.y, 30, 27);
        }
    
        public boolean interact(Rectangle rec, String action)
                throws InterruptedException {
            if (rec != null && action != null && !action.isEmpty()) {
                return script.selectOption(null, new RectangleDestination(rec),
                        action);
            }
            return false;
        }
    
        public boolean tradeScreenTwoOpen() {
            if (script.client.getInterface(TRADE_SCREEN_TWO_PARENT) != null) {
                RS2InterfaceChild rc = script.client.getInterface(
                        TRADE_SCREEN_TWO_PARENT).getChild(
                        TRADE_SCREEN_TWO_CHILD_MY_ITEMS);
                if (rc != null && rc.isVisible()) {
                    return true;
                }
            }
            return false;
    
        }
    
        private int parseQuantity(String text) throws ParseException {
            if (text == null) {
                return -1;
            }
    
            if (text.contains("(") && text.contains(")")) {
                text = text.substring(text.indexOf('(') + 1, text.indexOf(')'));
                NumberFormat.getIntegerInstance(java.util.Locale.US).parse(text)
                        .intValue();
            }
    
            return NumberFormat.getIntegerInstance(java.util.Locale.US).parse(text)
                    .intValue();
        }
    
        public List<TradeItem> getItemsSecondaryScreen(String text)
                throws ParseException {
            ArrayList<TradeItem> list = new ArrayList<TradeItem>();
            if (text == null || !text.contains("<br>")) {
                return list;
            }
    
            String items[] = text.split("<br>");
            for (String s : items) {
                String[] itemData = s.split("<col=[0-9A-Fa-f]{6}>");
                if (itemData.length == 2) {
                    list.add(new TradeItem(itemData[1]));
    
                } else if (itemData.length == 4) {
                    list.add(new TradeItem(itemData[1], parseQuantity(itemData[3])));
    
                } else {
                    try {
                        throw new Exception("Sorry please check the item");
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
    
                }
            }
    
            return list;
        }
    
        public String getSecondWindowText(int screen) {
            if (tradeScreenTwoOpen()) {
                return script.client.getInterface(TRADE_SCREEN_TWO_PARENT)
                        .getChild(screen).getMessage();
            }
            return null;
        }
    
        public boolean acceptTrade() throws InterruptedException {
            if (tradeScreenOneOpen()) {
                return interact(script.client.getInterface(TRADE_SCREEN_ONE_PARENT)
                        .getChild(TRADE_SCREEN_ONE_ACCEPT).getRectangle(),
                        "Accept Trade");
            }
            if (tradeScreenTwoOpen()) {
                return interact(script.client.getInterface(TRADE_SCREEN_TWO_PARENT)
                        .getChild(TRADE_SCREEN_TWO_ACCEPT).getRectangle(),
                        "Accept Trade");
            }
            return false;
        }
    
        public boolean declineTrade() throws InterruptedException {
            if (tradeScreenOneOpen()) {
                return script.client.getInterface(TRADE_SCREEN_ONE_PARENT)
                        .getChild(TRADE_SCREEN_ONE_DECLINE)
                        .interact("Decline Trade");
            }
    
            if (tradeScreenTwoOpen()) {
                return script.client.getInterface(TRADE_SCREEN_TWO_PARENT)
                        .getChild(TRADE_SCREEN_TWO_DECLINE).interact("Decline");
            }
    
            return false;
        }
    }
    
    
    

     

    TradeItem Class:

     

    
    public class TradeItem {
    	private String name;
    	private boolean stackable;
    	private int amount;
    
    	public TradeItem(String name) {
    		this.name = name;
    		this.stackable = false;
    		this.amount = 1;
    	}
    
    	public TradeItem(String name, int amount) {
    		this.name = name;
    		this.amount = amount;
    		this.stackable = true;
    	}
    
    	public String getName() {
    		return this.name;
    	}
    
    	public int getAmount() {
    		return this.amount;
    	}
    
    	public boolean isStackable() {
    		return this.stackable;
    	}
    	
    
    }
    
    

     

     

     

    Example useage;

    Will determine what trade items are in the text on second screen

     List<TradeItem> list =  getItemsSecondaryScreen(getSecondWindowText(TRADE_SCREEN_TWO_CHILD_THEIR_ITEMS));
     TradeItem[]  array = list.toArray(new TradeItem[list.size()]);
          if (array.length>0){
        if (array[0].getName.equals("Lobster")){
       // do action
       }
    }

     

    • Like 1
×
×
  • Create New...