Falcon 0 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); }
Falcon 0 Author 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);
Pandemic 2853 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.
Falcon 0 Author Posted March 21, 2022 @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.
Falcon 0 Author 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.