4 function timer_loop() {
6 $mtime = microtime(true);
8 foreach ($timers as $id => $timer) {
9 if(($timer['expire'] - 0.00019) <= $mtime) { //we expire a timer 0,19 ms before (to reduce timer desyncs)
10 if((is_array($timer['function']) && method_exists($timer['function'][0],$timer['function'][1])) || (!is_array($timer['function']) && function_exists($timer['function']))) {
11 call_user_func_array($timer['function'],$timer['params']);
20 function timer($seconds,$command,$parameter) {
22 $new['expire'] = microtime(true) + $seconds;
23 $new['function'] = $command;
24 $new['params'] = $parameter;
25 while(isset($timers[$timers['id']])|| !isset($timers['id'])) {
27 if($timers['id'] > 9999999) $timers['id'] = 0;
29 $timers[$timers['id']] = $new;
33 function utimer($seconds,$command,$parameter) {
35 $new['expire'] = microtime(true) + ($seconds / 1000);
36 $new['function'] = $command;
37 $new['params'] = $parameter;
38 while($timers[$timers['id']] || !$timers['id']) {
40 if($timers['id'] > 9999999) $timers['id'] = 0;
42 $timers[$timers['id']] = $new;
46 function kill_timer($id) {