Jump to content

Script causing insane lag, gets worse over time until it crashes


Recommended Posts

Posted (edited)

https://pastebin.com/xagtE9jK

 

Very simple script, not sure how I am possibly having something "leak" to cause an increased amount of lag starting from minute 1 until it eventually crashes after 20minutes or so. 

 

 

Note: the 

        if(players.myPlayer().isAnimating()){
            log("animating");
            if(random(1,30) == 1){
                if(random(1,2) == 1){
                    log("backspace");
                    getKeyboard().pressKey(8);
                    getKeyboard().releaseKey(8);
                }else{
                    log("random letter");
                    Random r = new Random();
                    char c = (char)(r.nextInt(26) + 'a');
                    new TypeStringEvent(Character.toString(c), false);
                }

            }
        }

block is the only block ever getting executed during lagging portion. 

Edited by Brian
Posted (edited)

Mirror mode or stealth?

Also what OS you using?

 

I've ran your code for about 10 mins now, on mirror mode. The fps is still at the max amount of 50.

Try running simplified blocks, and slowly start adding in more code to see when it starts happening.

Edited by BravoTaco
Posted
29 minutes ago, BravoTaco said:

Mirror mode or stealth?

Also what OS you using?

 

I've ran your code for about 10 mins now, on mirror mode. The fps is still at the max amount of 50.

Try running simplified blocks, and slowly start adding in more code to see when it starts happening.

W10, Mirror Mode.    I changed my random method from

random(..,..)

to

ThreadLocalRandom.current().nextInt(..,..+1)

And it has seemed to have solved the problem.  Very weird :)

 

26 minutes ago, Protoprize said:

NVM Just saw the pastebin

One thing that I have noticed is that you have a 30 second time out on your conditional sleep, I'm pretty sure that has something to do with it  

That code is never reached, just a failsafe.  I removed it and had the same issue.  

Posted
7 minutes ago, Brian said:

W10, Mirror Mode.    I changed my random method from


random(..,..)

to


ThreadLocalRandom.current().nextInt(..,..+1)

And it has seemed to have solved the problem.  Very weird :)

 

Very odd. As the random() method just uses the Random class from java. But atleast its working now 🙂 

Posted (edited)
3 hours ago, BravoTaco said:

Very odd. As the random() method just uses the Random class from java. But atleast its working now 🙂 

Okay, I spoke too soon, it started happening again, I removed everything from my script but the following...  All I am trying to do is stop my account from logging out.  Ugh, have written tons of scripts that are infinetly more complex, why does this one have so many issues :( .. seems to take longer before it runs into issues though.  Before I noticed it after a few minutes, now it runs for about 30 minutes before I start noticing the lag, maybe a hour until crash happens. 

 

@Override
public int onLoop() {
    if(players.myPlayer().isAnimating()){
        getKeyboard().pressKey(8);
        getKeyboard().releaseKey(8);
    }
    return ThreadLocalRandom.current().nextInt(60000, 240000);
 }

 

Edited by Brian
Posted
Quote

public void pressKey(int keyCode)
Sends a KEY_PRESSED event to the key event handler. Note: only for keys that have no 'character'. Do NOT use for Esc key (and probably a couple of other keys).
Parameters:
keyCode - The KeyCode for the key to type.

 

This could be your problem.

 

Try getKeyboard().pressKey(VK_Z) // z constant

Posted
1 hour ago, dreameo said:

 

This could be your problem.

 

Try getKeyboard().pressKey(VK_Z) // z constant

Hmm okay, I see how that could be a program.  It does send a backspace, though looks like it may not be recommended.  If I send a Z key or something it will fill up my chat and eventually stop entering so It will eventually stop keeping me logged in, so will need to find another method to stay logged in if the backspace is the issue.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...