Jump to content

trainux

Members
  • Posts

    77
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by trainux

  1. 23 hours ago, Beenrange said:

    Instead of using rs GE, use rsbuddy GE as its more reflective of actual prices imo...

    Following code was found elsewhere and adopted for my usecase (sorry cant remember source)

    
    private final static String RSBUDDY_URL = "https://rsbuddy.com/exchange/summary.json";

     

     

    
        public static HashMap<String, Integer> getPriceMap(List<String> items) {
    		HashMap<String, Integer> priceMap = new HashMap<>();
    
    		try {
    			URL url = new URL(RSBUDDY_URL);
    			BufferedReader jsonFile = new BufferedReader(new InputStreamReader(url.openStream()));
    			JsonObject priceJSON = JsonObject.readFrom(jsonFile.readLine());
    			Iterator<Member> iterator = priceJSON.iterator();
    			
    			while (iterator.hasNext()) {
    				JsonObject itemJSON = priceJSON.get(iterator.next().getName()).asObject();
    				String itemName = itemJSON.get("name").asString();
    				if (items.contains(itemName)) {
    					priceMap.put(itemName, itemJSON.get("buy_average").asInt());
    				}
    			}
    		} catch (Exception e) {
    		}
    		return priceMap;
    	}

    Then, every time you loot an item or if you already know the item name, add it to a list of strings. You can use it as such....

    
    HashMap<String,Integer> itemPrices = new HashMap();
    
    itemPrices = getPriceMap(items);

    For keeping a list of total looted you could (inefficiently, sorry unwilling to share my code)

    
            for(String item : items){
                itemPrices = getPriceMap(items);
                try {
                total = total + itemPrices.get(item);
                }
                catch (Exception e) {
                    log("Empty");
                }
                
            }
            items.clear();
    }

     

    You can use the following library (literally just copy and paste the .java files into your code, I don't know of a better way of doing this)

    https://github.com/ralfstx/minimal-json

    thank you very much brother.
     

    • Like 1
  2. I needed something simpler, something to just indicate the ID, thanks for the code fragment and for the advice.

    Price.java

    package scripts;
    
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.util.Iterator;
    import java.util.List;
    
    import json.JsonObject;
    import json.JsonObject.Member;
    
    public class Price {
    
    	private final static String RSBUDDY_URL = "https://rsbuddy.com/exchange/summary.json";
    
    	public int getPrice(List<Integer> items) {
    		int price = 0;
    
    		try {
    			URL url = new URL(RSBUDDY_URL);
    			BufferedReader jsonFile = new BufferedReader(new InputStreamReader(url.openStream()));
    			
    			JsonObject priceJSON = JsonObject.readFrom(jsonFile.readLine());
    			Iterator<Member> iterator = priceJSON.iterator();
    			
    			while (iterator.hasNext()) {
    				JsonObject itemJSON = priceJSON.get(iterator.next().getName()).asObject();
    				int itemID = itemJSON.get("id").asInt();
    				if (items.contains(itemID)) {
    					price = itemJSON.get("buy_average").asInt();
    					break;
    				}
    			}
    		} catch (Exception e) {
    		}
    		return price;
    	}
    }

    Usage:

    final Price price = new Price();
    ArrayList<Integer> items = new ArrayList<Integer>(); 
    items.add(434);
    price.getPrice(items);

     

  3. Using this api as a base

    I consult as follows (as the post says):

    rsExchange.getExchangeItem("Yew logs").ifPresent(System.out::println);

    It works well, but if I consult another item like "Clay" it does not work, the value it brings of the page is "-1" in all prices.

    I manually check the link and return the json with the prices.

    http://api.rsbuddy.com/grandExchange?a=guidePrice&i=434

    The next json throws me:

    {"overall":136,"buying":140,"buyingQuantity":33,"selling":136,"sellingQuantity":867}

     

  4. 7 hours ago, FrostBug said:

    Maybe didn't execute the event properly

    Here as I have the code.

    LoginEvent loginEvent;
    @Override
    public int onLoop() throws InterruptedException{
    	if(!getClient().isLoggedIn()) {
    		loginEvent = new LoginEvent(usuario,clave);
    		getBot().addLoginListener(loginEvent);
    		execute(loginEvent);
    	}else {
    		doTasks();
    	}
    	return 1000;
    }

    It is assumed that onLoop() is repeated in an interval as indicated in the "return", in this case 1 second.

     

  5. 5 minutes ago, Muffins said:

    if the tile is further than 10 spaces (or off of the minimap) you will need to use getWalking().webWalk() instead.

    As you can notice, it is only 1 distance coordinate.

    1 minute ago, ProjectPact said:

    need to set threshold to 0 or use minimap on exact tile

    I did not understand, could you give a better explanation? please.

  6. I execute:

    log(player.getPosition());

    it gives me as a result:

    [x=3172, y=3364, z=0]

    And I am ordering you to address:

    [x=3172, y=3365, z=0]

    As follows:

    getWalking().walk(new Position(3172, 3365, 0));

    Why do not you move to the position that I am ordering?

  7. Make a script that works fishing in Draynor, something simple what you do inside the game.
    What really makes it "interesting" is that it works random times, rests random times, does not work in the range of 22: 00-6: 00.
    The times of "rest" can be of 5-30mins, in these times the account is disconnected (using the script "A simple login handler By @Explv" to manipulate the start of the session when you enter working hours).
    The problem is that when the bot has worked a while (1 day approximately) does not return to log on by itself, I have to press the button to pause the bot and then resume it to return to normal work.
    Why will this take place?

  8. 2 minutes ago, Explv said:

    Well firstly @trainux, don't check if getDialogues().inDialogue(), because as you said yourself, the player is always in a dialogue.

    Whenever you are talking to an NPC on the island the "Click here to continue" / "Click to continue" widget will be visible. So just check for that instead.

    Just look at my open source script https://github.com/Explv/Tutorial-Island

    Your island code is free, I did not know, I will use it to guide me.
    Thanks brother.

  9. According to my logic, this fragment should work to talk to an NPC of Tutorial Island.

    if(dialogues.inDialogue()) {
    	if(!dialogues.isPendingContinuation()) {
    		if(dialogues.clickContinue()) {
    			dialogues.clickContinue();
    		}
    	}
    }else {
    	NPC tuto2 = npcs.closest("Survival Expert");
    	if(tuto2.isVisible()){
    		tuto2.interact("Talk-to");
    	}else{
    		getCamera().toEntity(tuto2);
    	}
    }

    But in Tutorial Island the annoying messages appear that seem to dialogue with another NPC but they are not.

    I attach the image specifying the message to which I refer.

    https://photos.app.goo.gl/3ta5FZpqZNg8EfSM6

  10. I interact with a door, I open it if it is closed, but if this other gate is closed then it interacts with all the doors, I need it to be a specific door.

    final int[] list = new int[] {1560, 1558};
    final RS2Object gate = objects.closest(list);
    if(gate.exists()) {
    	interactCustom(gate, "Open");
    	getWalking().walk(new Position(3180, 3288, 0));
    }else{
    	getWalking().webWalk(new Position(3088, 3235, 0));
    }

     

  11. 17 minutes ago, Lemons said:

    Seems you have some extra spaces, try:

    
    java -jar "osbot 2.5.8.jar" -debug 5005 -login user@gmail.com:pass -bot user@gmail.com:pass:0000 -world 394 -script FishingBot:none -allow norandoms,lowresource

    Thanks for the reply but sorry, error in the writing of the post. The command that I try to execute does not take space.
    I rewrite the command:

    java -jar "osbot 2.5.8.jar" -debug 5005 -login user@gmail.com:pass -bot user@gmail.com:pass:0000 -world 394 -script FishingBot:none -allow norandoms,lowresource

     

  12. If I execute this command to boot osBot, it throws this error:

    java -jar "osbot 2.5.8.jar" -debug 5005 -login user@gmail.com:pass -bot user@gmail.com:pass:0000 -world 394 -script FishingBot:none -allow norandoms,lowresource

    The console sends the following error:

    bot exited with code: 0

     

    If I execute this other command to start everything is perfect:

    java -jar "osbot 2.5.8.jar" -debug 5005 -login user@gmail.com:pass -bot user@gmail.com:pass:0000 -world 394 -script FishingBot:none -allow norandoms

    I need the command "lowresource" :(

  13. 35 minutes ago, Charlotte said:

    Random events were phased out in rs3 as better anti-macro software was developed. Random events have no effect whatsoever and is not used to determine botters. You can either completely ignore it or use the built-in system to dismiss it.

    yH6w6T2.png

    Thank you very much.


    And thank you all for answering.

  14. 9 minutes ago, Antonio Kala said:

    Are you asking how to know if random event is for you or for another player?

    You can just ignore them and they will go away. Or click on settings then tick "dismiss randoms".

    I do not know if I'll ask a stupid question, but ignoring all NPCs is not a bit obvious that it's a bot?
    One playing dismisses 2/3 NPC ramdoms.

  15. 14 minutes ago, Cloxygen said:

    u know there is a built in random event handler right?

    I did not know it :(

    13 minutes ago, Explv said:

    1) I have no idea what you're asking

    2) Why use IDs for NPCs? It looks horrible, is extremely unreadable (highlighted by the fact that you have comments) You can just use the names of the NPCs...

    
    NPC npc = getNpcs().closest("Giles", "Sandwich Lady", "Rick Turpentine");

    etc.

    3) OSBot already has a random event dismisser, why are you writing your own?

    1) An NPC appears but you can not identify if you want to interact with me or are interacting with another character.

    2) The custom of programming of administrative systems I generate a compulsive obsecion of everything programmed by the identifiers (seriously, I do not joke xD)

    3) I did not know it. What is it and how do I use it?

     

    NOTE: I do not know if it is completely understood because I speak Spanish and use "Google Translate" to try to communicate my doubts.

×
×
  • Create New...