Quote:
Originally Posted by DustyPorViva
Not in a way that's healthy for the script, though. From my experience the sleep will function like a return, breaking everything after it, even if you reset the timeout.
|
Sleep() should not return and break everything after. Sleep() will freeze/pause the script for the given time, and then continue.
Also..
Quote:
Originally Posted by DustyPorViva
Can't put a sleep in timeouts 
|
that is like saying you can't put sleep() in any loops (timeout, scheduleevent, while, for) ;D
PHP Code:
function onCreated() {
this.var1 = "This is echoed when timeout events occurs.";
this.var2 = "This is echoed 5 seconds later";
setTimer(1);
}
function onTimeout() {
echo(this.var1);
sleep(5);
echo(this.var2);
setTimer(1);
}
// above functions identical to the script below:
function onCreated() {
this.var1 = "This is echoed when timeout events occurs.";
this.var2 = "This is echoed 5 seconds later";
scheduleEvent(1, "Timeout2", 0);
}
function onTimeout2() {
echo(this.var1);
sleep(5);
echo(this.var2);
scheduleEvent(5, "Timeout2", 0);
}
// above functions identical to the script below:
function onCreated() {
this.var1 = "This is echoed when timeout events occurs.";
this.var2 = "This is echoed 5 seconds later";
this.loop = function() {
echo(this.var1);
sleep(5);
echo(this.var2);
sleep(1);
this.loop();
};
this.loop();
}
// above functions identical to the script below:
function onCreated() {
this.var1 = "This is echoed when timeout events occurs.";
this.var2 = "This is echoed 5 seconds later";
while(!waitfor(this, "timeout", 1)) {
echo(this.var1);
sleep(5);
echo(this.var2);
}
}