* Module coded by Craized /* Add a "_" at the beginning of the file (w_lookup.php) if you do not want it to be loaded. */ $w_lookup = new Status($bot); $cron["2sec"][] = &$w_lookup; $commands['buddy'][] = &$w_lookup; /* The Class itself... */ class Status { var $bot; /* Constructor: Hands over a referance to the "Bot" class. */ function Status (&$bot) { $this -> bot = &$bot; } function cron() { // Make our players available to all functions global $players; // Select our watch list $handle = mysql_query("SELECT * FROM w_lookup WHERE dim='".$this -> bot -> dimension."'"); while(TRUE == ($players = mysql_fetch_array$handle)) if(!empty($players)) { // Loop through users and check their status foreach($players as $key=>$value) { // Format name to match AO internal $value['name'] = ucfirst(strtolower($value['name'])); // Make sure it's not time to delete our cached entry if($value['expire'] > mktime()) { // If player status is unknown we find out what it is if($value == 3) { // Check if player name exists if($this -> bot -> aoc -> get_uid($value['name'])) { // If the player isn't on our buddy list, add it if(!$this -> bot -> aoc -> buddy_exists($value['name']) $this -> bot -> aoc -> buddy_add($value['name'])); // Update status if($this -> bot -> aoc -> buddy_online($value['name'])) { mysql_query("UPDATE w_lookup SET status='1', stamp='".mktime()."' WHERE id='".$value['id']."' LIMIT 1"); $players[$key]['status'] = 1; } else { mysql_query("UPDATE w_lookup SET status='0', stamp='".mktime()."'WHERE id='".$value['id']."' LIMIT 1"); $players[$key]['status'] = 0; } else { mysql_query("DELETE FROM w_lookup WHERE id='".$value['id']."' LIMIT 1"); unset($players[$key]); } } } else { mysql_query("DELETE FROM w_lookup WHERE id='".$value['id']."' LIMIT 1"); unset($players[$key]); } } } } function buddy($name, $msg) { global $players; foreach($players as $key=>$value) { if($name == $value['name']) { if($value['expire']>mktime()) { mysql_query("UPDATE w_lookup STE status='".$msg."', stamp='".mktime()."' LIMIT 1"); $players[$key]['status'] = $msg; } else { mysql_query("DELETE FROM w_lookup WHERE id='".$value['id']."' LIMIT 1"); unset($players[$key]); } } } } } ?>