Cyber Syndicate
<center><p style='font-size:120%;'><strong>Welcome to Cyber Syndicate!<strong></p>

You are visiting as a guest; please <strong>register</strong> or <strong>log in</strong>.

Being logged in provides many benefits, including access to the useful <strong>Methods forum</strong>, posting permissions, and voting permissions.

<strong>Enjoy.</strong></center>
Cyber Syndicate
<center><p style='font-size:120%;'><strong>Welcome to Cyber Syndicate!<strong></p>

You are visiting as a guest; please <strong>register</strong> or <strong>log in</strong>.

Being logged in provides many benefits, including access to the useful <strong>Methods forum</strong>, posting permissions, and voting permissions.

<strong>Enjoy.</strong></center>
Cyber Syndicate
Would you like to react to this message? Create an account in a few clicks or log in to continue.



 
HomeLatest imagesRegisterLog in

 

 Sleep() until...

Go down 
4 posters
AuthorMessage
RedmenNL
Member
Member



Posts : 2
Join date : 2011-02-28

Sleep() until... Empty
PostSubject: Sleep() until...   Sleep() until... Icon_minitimeMon Feb 28, 2011 11:17 am

I've got a little problem with my script:

I want my script to stop sleeping after it is done teleporting to my house, but the time it takes to teleport is not always the same(internet, computer speed). Can I sleep until the portal is on screen?

RedmenNL
Back to top Go down
b0xb0x
Administrator
Administrator



Posts : 130
Join date : 2011-02-25
Age : 28
Location : California

Sleep() until... Empty
PostSubject: Re: Sleep() until...   Sleep() until... Icon_minitimeMon Feb 28, 2011 6:44 pm

You could use a while statement. It isn't the greatest, but it works. The only problem is if for whatever reason the script gets interrupted while teleporting, you are out of luck and it crashes.
Code:
while (houseArea.contains(Players.getLocal().getLocation()) sleep(100);
Back to top Go down
https://cybersyndicate.forumotion.com
TaffTech
Administrator
Administrator



Posts : 72
Join date : 2011-02-27

Sleep() until... Empty
PostSubject: Re: Sleep() until...   Sleep() until... Icon_minitimeMon Feb 28, 2011 8:51 pm

Or use a for loop.
for(int timeout = 0; timeout < 10 && !houseArea.contains(Players.getLocal().getLocation()); timeout++){
sleep(500,1000);
}

The timeout is important, otherwise you could get stuck with an infinite loop...
But yeah, it loops while timeout < 10 and the houseArea doesn't contain your location, at the end of each loop it iterates timeout.

Hopefully that helped.
Back to top Go down
RedmenNL
Member
Member



Posts : 2
Join date : 2011-02-28

Sleep() until... Empty
PostSubject: Re: Sleep() until...   Sleep() until... Icon_minitimeTue Mar 01, 2011 1:32 am

Thanks!
Back to top Go down
UberMouse
Member
Member



Posts : 5
Join date : 2011-02-25

Sleep() until... Empty
PostSubject: Re: Sleep() until...   Sleep() until... Icon_minitimeFri Mar 04, 2011 12:11 am

int timeout = 0;
while(stuff && ++timeout <= xx (15 is usually good))
sleep(100);
That way if it fails you won't get stuck in a while loop forever and is failsafed to exit after 1.5 seconds.
Back to top Go down
TaffTech
Administrator
Administrator



Posts : 72
Join date : 2011-02-27

Sleep() until... Empty
PostSubject: Re: Sleep() until...   Sleep() until... Icon_minitimeFri Mar 04, 2011 12:20 am

UberMouse wrote:
int timeout = 0;
while(stuff && ++timeout <= xx (15 is usually good))
sleep(100);
That way if it fails you won't get stuck in a while loop forever and is failsafed to exit after 1.5 seconds.

I prefer for loops, but each to his own I guess.
Back to top Go down
Sponsored content





Sleep() until... Empty
PostSubject: Re: Sleep() until...   Sleep() until... Icon_minitime

Back to top Go down
 
Sleep() until...
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Cyber Syndicate :: Development :: Scripting Help-
Jump to: