zanko360 1 Share Posted January 1, 2019 Greetings, The AddFriend() method of org.dreambot.api.methods.friend package doesn't work properly. When put in loop the loop sometimes continues without actually clicking on "Add Friend" an types the name in chat instead. Without delays and if statements it doesn't work. Sometimes the method executes without typing anything at all. With delay of 200milisecond and checking with Friends.haveFriend() it works. Don't know if this is intended or a bug just thought I might point this out Link to comment Share on other sites More sharing options...
Nuclear Nezz 2040 Share Posted January 1, 2019 I'm not entirely sure what you're reporting. Could you give me the code you're using? You're talking about loops and then also delays, is it just the regular method that doesn't work? It's possible that it's lag that is effecting the method. Link to comment Share on other sites More sharing options...
zanko360 1 Author Share Posted January 2, 2019 The method AddFriend(String playerName), of the class Friends. When called in a loop, ie. To iterate bunch of names got from surroundings, and then put in as argument in AddFriend(), works terrible. The method gets called, sometimes it executes as it should (it clicks on "Add Player" THEN types the name), sometimes or alot of the time it just one call gets executed correctly like this the other one ( because it is in loop) gets called "prematurely??" and doesn't click the "Add Player" instead it types the name in chat. Without big delays it could not figure out a way to implement it like this even with all sorts of if() while(true). Any ideas how I could get around this? Thank you in advance Link to comment Share on other sites More sharing options...
7804364 230 Share Posted January 2, 2019 2 hours ago, zanko360 said: The method AddFriend(String playerName), of the class Friends. When called in a loop, ie. To iterate bunch of names got from surroundings, and then put in as argument in AddFriend(), works terrible. The method gets called, sometimes it executes as it should (it clicks on "Add Player" THEN types the name), sometimes or alot of the time it just one call gets executed correctly like this the other one ( because it is in loop) gets called "prematurely??" and doesn't click the "Add Player" instead it types the name in chat. Without big delays it could not figure out a way to implement it like this even with all sorts of if() while(true). Any ideas how I could get around this? Thank you in advance Use something like this, List<Player> playerNames = getPlayers().all(p -> Objects.nonNull(p) && p.distance(getLocalPlayer()) <= 10); playerNames.forEach(p -> { if (getFriends().addFriend(p.getName())) { sleepUntil(() -> Arrays.asList(getFriends().getFriends()).contains(p.getName()), 10000); } }); Link to comment Share on other sites More sharing options...
zanko360 1 Author Share Posted January 2, 2019 Ty 780. I got around it with: while(!Friends.haveFriend(list<Player>.get(iterator).getName())) { if(Widgets.getWidget(162).getChild(45).getText().equals("*") && Widgets.getWidget(162).getChild(45).isVisible()){ Friends.addFriend(list<Player>.get(iterator)); } sleep(100); } after the first attemp/call Link to comment Share on other sites More sharing options...
zanko360 1 Author Share Posted January 2, 2019 while(!Friends.haveFriend(list<Player>.get(iterator).getName())) { if(Widgets.getWidget(162).getChild(45).getText().equals("*") && Widgets.getWidget(162).getChild(45).isVisible()){ Friends.addFriend(list<Player>.get(iterator)); } sleep(100); } Link to comment Share on other sites More sharing options...
Nuclear Nezz 2040 Share Posted January 2, 2019 The add friend method as it is currently written wasn't going to consistently go through every action required to add a friend. This will be changed in the next release, along with adding a few sleeps of its own. You will still need to check if(addFriend()) to see if it successfully finishes (which will only return true when the friend is in your list) Link to comment Share on other sites More sharing options...
zanko360 1 Author Share Posted January 3, 2019 Also deleteFriend() does the same thing. It would be dope to have deleteFriend() right click version so if you had a small friend's list you could chose a deleteFriend(Friend friend, boolean rightclick) something like that. I think it is more natural for a human to rightclick the name instead of typing it down if the friend's list is small Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.