Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Errors with Multi-threading java


    kamilo

    Recommended Posts

    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:

    mwP2Gx3.png

    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

    Link to comment
    Share on other sites

    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...

    Link to comment
    Share on other sites

    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:

    mwP2Gx3.png

    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?

    Link to comment
    Share on other sites

    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

    Link to comment
    Share on other sites

    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.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.