RetroBot 35 Posted December 31, 2017 Code: (credit to this thread https://dreambot.org/forums/index.php/topic/10595-get-other-players-equipment/) public static boolean hasNothingEquipped(Player p) { for (int i : getEquipped(p)) { if (i != -1) { return false; } } return true; } public static int[] getEquipped(Player p) { //https://dreambot.org/forums/index.php/topic/10595-get-other-players-equipment/ int[] appearanceData = p.getComposite().getApperance(); int[] equipment = new int[appearanceData.length]; for (int i = 0; i < equipment.length; i++) { equipment[i] = appearanceData[i] > 512 ? appearanceData[i] - 512 : -1; } return equipment; } private HashMap<EquipmentSlot, String> getOthersEquipment(Player p) { HashMap<EquipmentSlot, String> equipmentList = new HashMap<>(); if (p != null) { int[] equipment = p.getComposite().getApperance(); if (p.getComposite() != null && p.getComposite().getApperance() != null) { for (int i = 0; i < equipment.length; i++) { if (equipment[i] - 512 > 0) { switch (i) { case 0: equipmentList.put(EquipmentSlot.HAT, new Item(equipment[i] - 512, 1, getClient().getInstance()).getName()); break; case 1: equipmentList.put(EquipmentSlot.CAPE, new Item(equipment[i] - 512, 1, getClient().getInstance()).getName()); break; case 2: equipmentList.put(EquipmentSlot.AMULET, new Item(equipment[i] - 512, 1, getClient().getInstance()).getName()); break; case 3: equipmentList.put(EquipmentSlot.WEAPON, new Item(equipment[i] - 512, 1, getClient().getInstance()).getName()); break; case 4: equipmentList.put(EquipmentSlot.CHEST, new Item(equipment[i] - 512, 1, getClient().getInstance()).getName()); break; case 5: equipmentList.put(EquipmentSlot.SHIELD, new Item(equipment[i] - 512, 1, getClient().getInstance()).getName()); break; case 7: equipmentList.put(EquipmentSlot.LEGS, new Item(equipment[i] - 512, 1, getClient().getInstance()).getName()); break; case 9: equipmentList.put(EquipmentSlot.HANDS, new Item(equipment[i] - 512, 1, getClient().getInstance()).getName()); break; case 10: equipmentList.put(EquipmentSlot.FEET, new Item(equipment[i] - 512, 1, getClient().getInstance()).getName()); break; } } } } } return equipmentList; } The problem: It works perfect up until I hop worlds. When I hop worlds it won't get the updated player equipment. For example, if another player has an axe equipped and I hop to a new world and then hop back to the world that I previously was on it will still think that the other player is still wielding an axe even if the player would happen to change his weapon to a sword or something to pk me. Here's a gif to show the problem (note: I'm only using it to check localplayer for demonstration purposes) https://i.imgur.com/ZAtkgwh.gifv Any help would be greatly appreciated!
Manly 879 Posted December 31, 2017 Are you fetching the player again once you hop or are you using an old object of the player?
RetroBot 35 Author Posted December 31, 2017 Are you fetching the player again once you hop or are you using an old object of the player? I've tried using your code from the post @Override public int onLoop() { final List<Player> lp = getPlayers().all(player -> player != null && player.exists() && hasNothingEquipped(player)); if (lp != null && lp.size() > 0) { for (Player p : lp) { if (p != null) { log(p.getName()); } } } return Calculations.random(600, 800); } I've tried a lot of things to try to grab the equipment after hopping, but it all gives me the same result. Edit - It still happens even if I end the script, refresh the script in the script manager, and start it back up
Nex 2546 Posted January 2, 2018 Probably easy to set it to null once ur hopping to it will need to fetch it again, Btw to much pooh bear's in there
RetroBot 35 Author Posted January 2, 2018 Probably easy to set it to null once ur hopping to it will need to fetch it again, Btw to much pooh bear's in there I've tried setting it to null once the gamestate equals hopping and I get the same result.
Nex 2546 Posted January 2, 2018 I've tried setting it to null once the gamestate equals hopping and I get the same result. call the method again if it returns null or not the same value as current ?
RetroBot 35 Author Posted January 2, 2018 call the method again if it returns null or not the same value as current ? It gives me a few NPE as its hopping, but once it's loaded in it won't update the equipment that the player has on. It just gives me what the result was before the hop.
Nex 2546 Posted January 2, 2018 It gives me a few NPE as its hopping, but once it's loaded in it won't update the equipment that the player has on. It just gives me what the result was before the hop. Would have to see more of the script like how u calling it and what ur hop state looks like
RetroBot 35 Author Posted January 2, 2018 Would have to see more of the script like how u calling it and what ur hop state looks like I was just manually hopping and running the code i've posted in the main post and the 2nd post. Made the player list equal to null once the gamestate was equal to hopping. I even tried testing out dinh's pk scout script and the same thing happens in that script aswell. Say I have 20k worth of gear on another account when I start his script it will grab it and say that the player has 20k gear then when it hops to a new world I would unequip something an item and when it would come back it would still register that the player has 20k worth of gear. Here's a gif demonstarting it https://i.imgur.com/pOsex9u.gifv (Note: The account in this gif only had a script running to hide the names. The account that pops in and out is the one running dinh's scouter.)
Articron 746 Posted January 3, 2018 Have you tried hard-hopping? Not hopping through the ingame worldhopper?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.