Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Simple Script Reset timer

iblindfool Weary
Registered User
Join date: 13 Feb 2005
Posts: 9
05-07-2008 23:04
looking for a simple script that on a nightly basis runs a reset script command? Like at midnight plus a short random few minutes so all the scripts wont hit the server at precisely the same time?

I just wondered if there was a way to elegantly create an event that doesnt spend alot of time comparing itself to current time.. Hope I make sense? Just point me to the best function for this type of thing...

TIA!!
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-07-2008 23:19
How's this? Time dilation should help to add a few random minutes in addition to that provided explicitly in the script. This has not yet been compiled, so it may require a small syntax fix or two.
CODE

float S_PER_DAY = 86400.0; // 24*60*60
float MAX_RANDOM_DELAY = 600.0; // 10 min

default
{
state_entry()
{
float currTime = llGetWallclock();
float timeUntilReset = S_PER_DAY-currTime+llFrand(MAX_RANDOM_DELAY);
llSetTimerEvent(timeUntilReset);
}

timer()
{
llResetScript();
}
}
iblindfool Weary
Registered User
Join date: 13 Feb 2005
Posts: 9
05-07-2008 23:42
Hi Hewee,

That certainly seems refined!! Compiled into the larger script with no issue whatsoever.. TY!!

Great Forum!!