View Single Post
  #16  
Old 01-07-2010, 07:18 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by DustyPorViva View Post
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 View Post
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);
  }

__________________

Last edited by Chompy; 01-07-2010 at 07:53 PM..
Reply With Quote