July 5, 20178 yr 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, 20178 yr by vaynex
July 5, 20178 yr 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, 20178 yr by Efpkaf
July 5, 20178 yr 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, 20178 yr by Explv
July 5, 20178 yr 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
July 5, 20178 yr Author 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, 20178 yr by vaynex
July 5, 20178 yr 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.
July 5, 20178 yr You can have a counter that you use as the element number for the array. Increment the counter every time a trade is completed.
July 5, 20178 yr 3 hours ago, vaynex said: Yes, For example, String entities[] = {"Mule Acc1", "Mule Acc2", "Mule Acc3", "Mule Acc4"}; -removed- Edited July 5, 20178 yr by Explv
July 6, 20178 yr 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?
July 6, 20178 yr 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?
July 6, 20178 yr Author 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, 20178 yr by vaynex
July 6, 20178 yr 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
Create an account or sign in to comment