Jump to content

Handling lag?


Recommended Posts

Posted (edited)

Hey, I made a post about this before, but here's another question. When I run 4-8 clients on one pc, scripts (generally) behave correctly. 

I tested then 35 clients on a pc and scripts start being stuck, etc.

To see what's up, I did a little test and noticed that the usual response time of methods is greatly increased, example:

1. Trade player

2. sleep 200ms.

2. loop -> log trade.isCurrentlyTrading(); => FALSE

3. After 1.8 secs => TRUE.

 

This applies to almost all methods.

So my question again is, how do you handle such inconsistency except by adding longer sleeps?

P.S. I use conditional sleeps, but that can't be applied everywhere.

Thanks!

Edited by Johnxtrem
Posted

1. If you think your scripts are starting to get stuck somewhere, since it's a private script, you can add longer sleeps to fit your needs. That's where trial and error comes into play for making a possibly flawless scripts. 

2. Especially for mule trades, it's advisable to make use of conditional sleeps.

3. If you lag is an issue, just add a longer sleep time, i don't see any harm to it. It's better than a stucked script.

Posted

You can definitely use conditional sleeps here.

if (trade.isCurrentlyTrading()) {
 	//do trade stuff 
} else {
	if (trade player) {//if we successfully try to trade with the player
		new ConditionalSleep(10000) {//sleep for 10 seconds or until condition is met
			@Override
			public boolean condition() throws InterruptedException {
				return trade.isCurrentlyTrading();
			}
		}
	}
}

 

  • Like 2

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