Jump to content

widget delay


Recommended Posts

Posted

i have a script for tanning, but when character trades with NPC there is huge(5 sec) delay in which the character doesnt tan hides :

any help would be appreciated biggrin.png

conditions:

	if (inventory.isEmptyExcept(995))
			//just withdraws hides to initiate script
			return State.BANK;
		 if(inventory.contains(1743)&&bank.isOpen())
			//if there is tanned hides and bank is open it deposits them/ withdraws untanned hides	
			 return State.BANKB;
		 
		 if(inventory.contains(1743))
			//returns to bank from tanner to open it	
			 return State.BACK;
		 
		 if(ellis!=null&&inventory.contains(1739))
			//tans hides when at tanner	
			 return State.TAN;
		if(inventory.contains(1739))
			//goes to tanner from bank
			return State.WALK;
		
		 

tan action:

case TAN:
			NPC ellis = npcs.closest("Ellis");
			ellis.interact("Trade"); 
			sleep(random(10, 15));
			getWidgets().getWidgetContainingText("Hard leather").interact("Tan All");
			  sleep(random(50, 200));
			break; 
Posted (edited)
case TAN:
        RS2Widget w = getWidgets().getWidgetContainingText("Hard leather");
        if (w != null && w.isVisible()) {
              w.interact("Tan All");
        } else {
	NPC ellis = npcs.closest("Ellis");
        if (ellis != null && ellis.exists()) {
	    ellis.interact("Trade"); 
            //either put a conditional sleep until interface is open here, or just stick with a static sleep and let state machine do the work eg:
            sleep(random(400,500) + random(400,500));
        } else {
            sleep(random(400,500) + random(400,500));
        }
	break; 

Re-written tan case... change the tan condition in the getState to:

 if(ellis!=null&& ellis.exists() && inventory.contains(1739))
			//tans hides when at tanner	
			 return State.TAN;
Edited by Apaec
  • 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...