vaynex Posted July 5, 2017 Share Posted July 5, 2017 (edited) Want to be able to interact with multiple account names, not just one using : eg. Player playersToTrade = getPlayers().closest("One Account"); What i've tried: (returns as if playersToTrade is null/not found) String entities[] = {"name1", "name2", "acc4", "acc3"}; Player playersToTrade = getPlayers().closest(entities); if(playersToTrade != null) { if(!playersToTrade.isVisible()){ camera.toEntity(playersToTrade); sleep(random(650,2450)); } else if(playersToTrade.isVisible()) { playersToTrade.interact("Trade with"); sleep(random(2500, 5000)); } Edited July 5, 2017 by vaynex Quote Link to comment Share on other sites More sharing options...
Efpkaf Posted July 5, 2017 Share Posted July 5, 2017 (edited) you can use simple loop private String playerNames[] = {"name1", "name2", "acc4", "acc3"}; private static final TRADE_ACTION = "Trade with"; private void interactWithPlayer(){ for(int i = 0; i < playerNames.length; i++{ Player playersToTrade = getPlayers().closest(playerNames[i]); if(playersToTrade != null) { if(!playersToTrade.isVisible()){ camera.toEntity(playersToTrade); sleep(random(650,2450)); } else if(playersToTrade.isVisible()) { playersToTrade.interact(TRADE_ACTION); sleep(random(2500, 5000)); } } } I dont know if i understand you questionAlso after playersToTrade.interact(TRADE_ACTION) i suggest you to use also while(context.myPlayer().isMoving()){ sleep... } Edited July 5, 2017 by Efpkaf Quote Link to comment Share on other sites More sharing options...
Explv Posted July 5, 2017 Share Posted July 5, 2017 (edited) 1 hour ago, Efpkaf said: you can use simple loop private String playerNames[] = {"name1", "name2", "acc4", "acc3"}; private static final TRADE_ACTION = "Trade with"; private void interactWithPlayer(){ for(int i = 0; i < playerNames.length; i++{ Player playersToTrade = getPlayers().closest(playerNames[i]); if(playersToTrade != null) { if(!playersToTrade.isVisible()){ camera.toEntity(playersToTrade); sleep(random(650,2450)); } else if(playersToTrade.isVisible()) { playersToTrade.interact(TRADE_ACTION); sleep(random(2500, 5000)); } } } I dont know if i understand you questionAlso after playersToTrade.interact(TRADE_ACTION) i suggest you to use also while(context.myPlayer().isMoving()){ sleep... } Do not do this. 5 hours ago, vaynex said: Want to be able to interact with multiple account names, not just one using : eg. Player playersToTrade = getPlayers().closest("One Account"); What i've tried: (returns as if playersToTrade is null/not found) String entities[] = {"name1", "name2", "acc4", "acc3"}; Player playersToTrade = getPlayers().closest(entities); if(playersToTrade != null) { if(!playersToTrade.isVisible()){ camera.toEntity(playersToTrade); sleep(random(650,2450)); } else if(playersToTrade.isVisible()) { playersToTrade.interact("Trade with"); sleep(random(2500, 5000)); } Are there spaces in the usernames? Edited July 5, 2017 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Team Cape Posted July 5, 2017 Share Posted July 5, 2017 2 hours ago, Efpkaf said: you can use simple loop private String playerNames[] = {"name1", "name2", "acc4", "acc3"}; private static final TRADE_ACTION = "Trade with"; private void interactWithPlayer(){ for(int i = 0; i < playerNames.length; i++{ Player playersToTrade = getPlayers().closest(playerNames[i]); if(playersToTrade != null) { if(!playersToTrade.isVisible()){ camera.toEntity(playersToTrade); sleep(random(650,2450)); } else if(playersToTrade.isVisible()) { playersToTrade.interact(TRADE_ACTION); sleep(random(2500, 5000)); } } } I dont know if i understand you questionAlso after playersToTrade.interact(TRADE_ACTION) i suggest you to use also while(context.myPlayer().isMoving()){ sleep... } please no Quote Link to comment Share on other sites More sharing options...
vaynex Posted July 5, 2017 Author Share Posted July 5, 2017 (edited) 2 hours ago, Explv said: Do not do this. Are there spaces in the usernames? note: When using Player playersToTrade = getPlayers().closest("One Account"); it works just fine. its just i have multiple mules and want the script to interact with any account that becomes visible Yes, For example, String entities[] = {"Mule Acc1", "Mule Acc2", "Mule Acc3", "Mule Acc4"}; Edited July 5, 2017 by vaynex Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted July 5, 2017 Share Posted July 5, 2017 4 hours ago, Explv said: Do not do this. Are there spaces in the usernames? What's a better method? I use something along the same lines to grab accounts from a text file. Quote Link to comment Share on other sites More sharing options...
d0zza Posted July 5, 2017 Share Posted July 5, 2017 You can have a counter that you use as the element number for the array. Increment the counter every time a trade is completed. Quote Link to comment Share on other sites More sharing options...
Explv Posted July 5, 2017 Share Posted July 5, 2017 (edited) 3 hours ago, vaynex said: Yes, For example, String entities[] = {"Mule Acc1", "Mule Acc2", "Mule Acc3", "Mule Acc4"}; -removed- Edited July 5, 2017 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted July 6, 2017 Share Posted July 6, 2017 On 05/07/2017 at 1:35 PM, vaynex said: Want to be able to interact with multiple account names, not just one using : eg. Player playersToTrade = getPlayers().closest("One Account"); What i've tried: (returns as if playersToTrade is null/not found) String entities[] = {"name1", "name2", "acc4", "acc3"}; Player playersToTrade = getPlayers().closest(entities); if(playersToTrade != null) { if(!playersToTrade.isVisible()){ camera.toEntity(playersToTrade); sleep(random(650,2450)); } else if(playersToTrade.isVisible()) { playersToTrade.interact("Trade with"); sleep(random(2500, 5000)); } Does the one account that works not have any spaces in it's username? Quote Link to comment Share on other sites More sharing options...
slazter Posted July 6, 2017 Share Posted July 6, 2017 On 2017-07-05 at 7:49 PM, Explv said: Do not do this. Are there spaces in the usernames? Okay so im fairly new to coding, been reading through both your, Apaec's guide aswell as many support questions here and been chewing through Head first java. I've been writing 5-6 fairly simple scripts, although been trying to make them more advanced each time. Even have your answer on the states vs task thread bookmarked, you seem to understand alot about Java, would you care to explain to a fairly new coder why this isn't the correct way/ most optimal? and what could be done instead? Quote Link to comment Share on other sites More sharing options...
vaynex Posted July 6, 2017 Author Share Posted July 6, 2017 (edited) 2 hours ago, Explv said: Does the one account that works not have any spaces in it's username? it does actually have spaces do you know why Player playersToTrade = getPlayers().closest("Account 1", "Account 2", "Account 3") wont work and will only trade account 1 Edited July 6, 2017 by vaynex Quote Link to comment Share on other sites More sharing options...
Explv Posted July 6, 2017 Share Posted July 6, 2017 23 minutes ago, vaynex said: it does actually have spaces do you know why Player playersToTrade = getPlayers().closest("Account 1", "Account 2", "Account 3") wont work and will only trade account 1 What do you mean only trade 1 account? It will always choose the closest of the three. You need to be way more specific Quote Link to comment Share on other sites More sharing options...