Jump to content

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


Brian

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.  

Link to comment
Share on other sites

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 🙂 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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