ryank645 Posted June 19, 2019 Share Posted June 19, 2019 (edited) currently having an issue during world hopping where the log produces the following error: "Script executor is taking too long to suspend; restarting now..." however, the previous thread does not die and the script will seem to multi-thread with the previous thread and the new thread, this happens repeatedly until multiple threads are running consecutively all trying to do the same thing. this is the snippet where the issue arises: do { m.log("Hopping"); m.getWorlds().hopToP2PWorld(); m.sleep(15000); } while (m.myPlayer().exists() && player == null); any help would be appreciated and any further logs or code will be provided if needed. Edited June 19, 2019 by ryank645 Quote Link to comment Share on other sites More sharing options...
Ragboys is back Posted June 19, 2019 Share Posted June 19, 2019 (edited) You're already on a loop, I suggest not using a Do/While Edited June 19, 2019 by Ragboys is back Quote Link to comment Share on other sites More sharing options...
Token Posted June 19, 2019 Share Posted June 19, 2019 Avoid any looping code unless it's really necessary Quote Link to comment Share on other sites More sharing options...
Hybris Posted June 19, 2019 Share Posted June 19, 2019 As said above, don't use while loops. That being said your snippet is kinda weird, what is it you're trying to achieve? You hop, you sleep 15 seconds & then you hop again if your player exists & player == null (who is player?) Quote Link to comment Share on other sites More sharing options...
ryank645 Posted June 19, 2019 Author Share Posted June 19, 2019 the problem persists even without the do while loop, although not as may threads are created. the snippet is trying to hop every 15 seconds until a certain player is found, player being a variable. the while myPlayer().isVisible is to stop execution when logged out for hopping too may times Quote Link to comment Share on other sites More sharing options...
Hybris Posted June 19, 2019 Share Posted June 19, 2019 (edited) 15 minutes ago, ryank645 said: the problem persists even without the do while loop, although not as may threads are created. the snippet is trying to hop every 15 seconds until a certain player is found, player being a variable. the while myPlayer().isVisible is to stop execution when logged out for hopping too may times Why are you multi threading? You should place your conditions in if-statements, something like this if(player == null && myPlayer.isVisible){ //Hop } Edited June 19, 2019 by Hybris Quote Link to comment Share on other sites More sharing options...
ryank645 Posted June 19, 2019 Author Share Posted June 19, 2019 (edited) i had the if-statement previously before the do loop, the issue was still there however i have reverted the changes. i don't know multiple threads are being created that's my problem. the script produces the error "Script executor is taking too long to suspend; restarting now..." but doesn't kill the old thread so they both run at the same time. is there any way to check the number of threads running and kill them? if not then how do i prevent this error. Edited June 19, 2019 by ryank645 Quote Link to comment Share on other sites More sharing options...
Hybris Posted June 19, 2019 Share Posted June 19, 2019 (edited) Make sure u use the script skeleton, if you put the if statement in the onLoop there shouldn't be a problem as far as I know. You also need to make sure the script is sleeping while you're trying to log, otherwise it'll loop & you'll get multiple tries. You can use conditional sleeps so it'll make sure you are hopped before waking up again. https://osbot.org/forum/topic/127193-conditional-sleep-with-lambda-expressions/ If it still doesn't work, post the code you have & I'll take a look at it. Edited June 19, 2019 by Hybris Quote Link to comment Share on other sites More sharing options...