kamilo 7 Posted November 19, 2021 Basically running a thread constantly to detect skulled players... I was noticed a skulled player but my script didnt notify shit.. i got skeptical. Triple checked code, and i found out that somewhere along the line my thread randomly stops working.. At first i thought maybe if i pause the script it might mess it up but no pause doesnt effect the thread running in background @Override public void run() { while (isRunning) { if (inWilderness(player)) ) { MethodProvider.log("..."); if (isSkulled(player)) MethodProvider.log("inDanger..."); } else { try { Thread.sleep(2000); MethodProvider.log("Enemy Detector Thread sleeping (2s) -- Not in Wilderness..."); } catch (InterruptedException e) { MethodProvider.log("Error at inWilderness (thread): " + e.toString()); } } } //**Put a output log at the end of the loop to see if the loop ends somehow MethodProvider.log("Exisiting out of while loop.."); } But oddly enough the loop doesn't exit cuz i dont see the "Exisiting out of while loop." log. Has anyone dealt with this please help... Here's the screeshot of console: As you can see it randomly stops scanning, i dont see any error messages even though i've logged them properly. I can't seem to figure it out.. please help
kamilo 7 Author Posted November 19, 2021 As far as i know threads are endless, i was manually hopping around while testing my script and maybe it has something to do with that not sure as of yet. But yeah...
kamilo 7 Author Posted November 19, 2021 Found this topic: https://stackoverflow.com/questions/11927248/java-thread-stops-with-no-exception Changing my "exception' to 'throwable' letss see if it shines some light
kamilo 7 Author Posted November 19, 2021 Also, is there a check i can add to not scan if the screen hasnt done loadinng (hopping)
Neffarion 486 Posted November 19, 2021 1 hour ago, kamilo said: Basically running a thread constantly to detect skulled players... I was noticed a skulled player but my script didnt notify shit.. i got skeptical. Triple checked code, and i found out that somewhere along the line my thread randomly stops working.. At first i thought maybe if i pause the script it might mess it up but no pause doesnt effect the thread running in background @Override public void run() { while (isRunning) { if (inWilderness(player)) ) { MethodProvider.log("..."); if (isSkulled(player)) MethodProvider.log("inDanger..."); } else { try { Thread.sleep(2000); MethodProvider.log("Enemy Detector Thread sleeping (2s) -- Not in Wilderness..."); } catch (InterruptedException e) { MethodProvider.log("Error at inWilderness (thread): " + e.toString()); } } } //**Put a output log at the end of the loop to see if the loop ends somehow MethodProvider.log("Exisiting out of while loop.."); } But oddly enough the loop doesn't exit cuz i dont see the "Exisiting out of while loop." log. Has anyone dealt with this please help... Here's the screeshot of console: As you can see it randomly stops scanning, i dont see any error messages even though i've logged them properly. I can't seem to figure it out.. please help Please show the whole code, where is "player" coming from?
kamilo 7 Author Posted November 20, 2021 18 hours ago, Neffarion said: Please show the whole code, where is "player" coming from? kk, well i just put my code inside try and catch block and that seems to fix it! thanks so much for your help
Neffarion 486 Posted November 20, 2021 1 hour ago, kamilo said: kk, well i just put my code inside try and catch block and that seems to fix it! thanks so much for your help You shouldn't be doing that but alright
kamilo 7 Author Posted November 20, 2021 2 hours ago, Neffarion said: You shouldn't be doing that but alright how come?
Neffarion 486 Posted November 21, 2021 18 hours ago, kamilo said: how come? Wrapping everything in a try catch block is just lazy, overall bad design, and it will affect the performance of your script. You should be finding the source of the issue and deal with it accordingly.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.