Falcon 0 Share Posted March 19, 2022 How do I make the script wait until it has finished removing the player before starting to add a new one? For some reason it will add players without problem but it refuses to remove the player afterwards. I have tried to make the thread sleep after the add friend method is called but it still just skips deleting the friend entirely and clicks on the add new friend button and starts adding another player. import org.dreambot.api.methods.friend.*; List<Player> players = Players.all(); players.forEach(player -> { Friends.addFriend(player); Friend PlayerFriend = Friends.getFriend(player.getName()); boolean playerIsOnline = PlayerFriend.isOnline(); Friends.deleteFriend(PlayerFriend); } Link to comment Share on other sites More sharing options...
Falcon 0 Author Share Posted March 19, 2022 Okay I made it work by calling the method twice, is this a bug @Pandemic This worked Friends.deleteFriend(PlayerFriend); Friends.deleteFriend(PlayerFriend); This did not work Friends.deleteFriend(PlayerFriend); Link to comment Share on other sites More sharing options...
Pandemic 2731 Share Posted March 20, 2022 You might be calling deleteFriend too quickly after adding them so it thinks they aren't a friend, I'd add some sleeping after adding them. Link to comment Share on other sites More sharing options...
Falcon 0 Author Share Posted March 21, 2022 (edited) @Pandemic I spent an hour debugging and I tried to add sleep calls up to 3 seconds everywhere. Like after it added the player etc, the only thing I could do to make it work was to run the method twice. If it does not work with a 3 seconds delay it should not work by running the method twice as I assume it goes much faster than 3 seconds. Edited March 21, 2022 by DarkFalcon Link to comment Share on other sites More sharing options...
Falcon 0 Author Share Posted July 27, 2022 @Pandemic I am curious if you are going to look into the matter or not? As specified in my earlier post adding delays did not resolve the issue. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now