Panason9c Posted October 11, 2019 Share Posted October 11, 2019 Hi guys, I'm into scripting for 2 weeks now and ran into another problem now that I can't seem to solve. Thought I'd ask for help. I'm trying to make a pker help where I would get all players attacking/surrounding him within 1 tile. Spoiler public List<Player> getAttackers() { List<Player> friends = getPlayers().filter(p -> p != null && edgeArea.contains(p) && friendList.contains(p.getName())); for (Player friend : friends) { friend.closest().. <<<<<------- this is where I cant get it to work I see that there is no option for this in the API so I obviously can't do this here } return playersToBePjed; } That's the snippet where I cant figure out a way to get the player object next to him I appreciate all help Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted October 11, 2019 Share Posted October 11, 2019 5 hours ago, Panason9c said: Hi guys, I'm into scripting for 2 weeks now and ran into another problem now that I can't seem to solve. Thought I'd ask for help. I'm trying to make a pker help where I would get all players attacking/surrounding him within 1 tile. private List<Player> getPlayersAttackingPlayer(String playerName, int tileDistanceFromPlayer, ArrayList<String> friendNames){ Filter<Player> playerFilter = new Filter<Player>() { @Override public boolean match(Player player) { return !player.getName().equals(playerName) && myPlayer().getArea(tileDistanceFromPlayer).contains(player) && !friendNames.contains(player.getName()) && (player.getInteracting() != null) && player.getInteracting().getName().equals(playerName); } }; return getPlayers().filter(playerFilter); } If you are just trying to get one player, use Malcoms method instead, this one will be more performant heavy. Example Usage ArrayList<String> friendsNames = new ArrayList<>(); friendsNames.add("Bill"); List<Player> players; if((players = getPlayersAttackingPlayer(myPlayer().getName(), 20, friendsNames)) != null){ for(Player player : players){ log(player.getName()); } } 2 Quote Link to comment Share on other sites More sharing options...
Panason9c Posted October 11, 2019 Author Share Posted October 11, 2019 I got what I needed! Thank you both, brothermen! Quote Link to comment Share on other sites More sharing options...