*/ $version = "b1.0.3 - 2010-06-09"; // b1.0.3 Added "timeraa showall " to include alts of a chars. (Thanks to Yite@BeBot.Forum) // b1.0.2 Recoded diff calculation and some minor text changes // b1.0.1 Command access fixed and change in database. Clean of old structur needed (DROP #__timer_aa) // b1.0.0 First release. /* * BeBot - An Anarchy Online & Age of Conan Chat Automaton * Copyright (C) 2004 Jonas Jax * Copyright (C) 2005-2007 Thomas Juberg Stensås, ShadowRealm Creations and the BeBot development team. * */ $Donate = new TimerAA($bot); $Donate -> version = $version; class TimerAA extends BaseActiveModule { var $version; function __construct (&$bot) { /* Constructor: Hands over a referance to the "Bot" class. */ //Initialize the base module parent::__construct(&$bot, get_class($this)); $this -> bot -> db -> query("CREATE TABLE IF NOT EXISTS " . $this -> bot -> db -> define_tablename("timer_aa", "true") . " ( `timeraa_id` int(11) NOT NULL AUTO_INCREMENT, `timeraa_username` varchar(255) DEFAULT NULL, `timeraa_start` varchar(255) DEFAULT NULL, `timeraa_end` varchar(255) DEFAULT NULL, `timeraa_cooldown` int(11) DEFAULT NULL, PRIMARY KEY (`timeraa_id`))"); //$this -> update_table(); $this -> register_command('all', 'timeraa', 'MEMBER'); $this -> help['description'] = "This module helps you keep track of Offline AA time training."; $this -> help['command']['timeraa show '] = "Show how long time left on AA training."; $this -> help['command']['timeraa showall '] = "Show how long time left on AA training on all chars for user."; $this -> help['command']['timeraa set 18'] = "Set the training time for current AA. Only use hours."; $this -> help['notes'] = "(C) Module By Getrix@Fury\n"; } function command_handler($name, $msg, $origin) { /* Unified message handler $source: The originating player $msg: The actual message, including command prefix and all $type: The channel the message arrived from. This can be either "tell", "pgmsg" or "gc" */ $com = $this->parse_com($msg); switch($com['com']) { case 'timeraa': return($this -> sub_handler($name, $com, 1)); break; default: return "Error 1"; break; } } function sub_handler($name, $com, $type) { switch($com['sub']) { case 'set': return($this -> timer_set($name, $com['args'])); break; case 'show': return($this -> timer_show($name, $com['args'])); break; case 'showall': return($this -> timer_show_all($name, $com['args'])); break; default: //return($this -> donate($name, $com['sub'])); return("Not added"); break; } } function timer_set($name, $args) { $arr = explode(" ", $args); $timeraa_username = mysql_real_escape_string($name); $timeraa_cooldown = mysql_real_escape_string($arr[0]); $timeraa_start = time(); $timeraa_end = $this->utime_add($timeraa_start, $timeraa_cooldown); if (!is_numeric($timeraa_cooldown)) { return $timeraa_cooldown." is not a number"; } $chk_time = $this -> bot -> db -> select("SELECT * FROM #___timer_aa WHERE timeraa_username='$name'"); if (empty($chk_time)) { $sql = "INSERT INTO #___timer_aa (timeraa_username, timeraa_cooldown, timeraa_start, timeraa_end) VALUES ('$timeraa_username', '$timeraa_cooldown', '$timeraa_start', '$timeraa_end')"; } else { $sql = "UPDATE #___timer_aa SET timeraa_username='$timeraa_username', timeraa_cooldown='$timeraa_cooldown', timeraa_start='$timeraa_start', timeraa_end='$timeraa_end' WHERE timeraa_username='$name'"; } $this -> bot -> db -> query($sql); return "Timer AA set for $timeraa_username with Cooldown $timeraa_cooldown "; } function timer_show($name, $args) { if (!empty($args)) { $name = mysql_real_escape_string($args); } $chk_time = $this -> bot -> db -> select("SELECT * FROM #___timer_aa WHERE timeraa_username='$name'"); if (!empty($chk_time)) { foreach ($chk_time as $aa) { $timeraa_start = $aa[2]; $timeraa_end = $aa[3]; $timeraa_ends = date("M d H:i:s",$timeraa_end); $timeraa_cooldown = $aa[4]; $today = time(); $diff = $this->get_time_difference($today, $timeraa_end); return "Offline AA Training Timer for $name ends $timeraa_ends ($diff left of ".$timeraa_cooldown."hrs)"; } } else { return "No timer set"; } } function timer_show_all($name, $args) { if (!empty($args)) { $name = mysql_real_escape_string($args); } $findmain = $this -> bot -> db -> select("SELECT main FROM alts WHERE alts.alt='$name'"); if (empty($findmain)) {$main=$name;} else {$main = current($findmain[0]);} $main = ucfirst($main); $output = "
##ao_infoheadline##:::: Offline timer info for $main and alts ::::##end##
".$this->brfix(2); $chk_time = $this -> bot -> db -> select("SELECT * FROM #___timer_aa WHERE timeraa_username='$main'"); if (!empty($chk_time)) { foreach ($chk_time as $aa) { $timeraa_start = $aa[2]; $timeraa_end = $aa[3]; $timeraa_ends = date("M d H:i:s",$timeraa_end); $timeraa_cooldown = $aa[4]; $today = time(); $diff = $this->get_time_difference($today, $timeraa_end); $output .= "$main ends $timeraa_ends ($diff left of ".$timeraa_cooldown."hrs)".$this->brfix(); } } else { $output .= "$main has no timer set.".$this->brfix(); } $altlist = $this -> bot -> db -> select("SELECT alt FROM alts WHERE alts.main='$main'"); if (!empty($altlist)) { foreach ($altlist as $charlist) { foreach ($charlist as $charname) { $chk_time = $this -> bot -> db -> select("SELECT * FROM #___timer_aa WHERE timeraa_username='$charname'"); if (!empty($chk_time)) { foreach ($chk_time as $aa) { $timeraa_start = $aa[2]; $timeraa_end = $aa[3]; $timeraa_ends = date("M d H:i:s",$timeraa_end); $timeraa_cooldown = $aa[4]; $today = time(); $diff = $this->get_time_difference($today, $timeraa_end); $output .= "$charname ends $timeraa_ends ($diff left of ".$timeraa_cooldown."hrs)".$this->brfix(); } } else { $output .= "$charname has no timer set.".$this->brfix(); } } } } $output = $this -> bot -> core("tools") -> make_blob("AA timers for $main", $output); return $output; } function utime_add($unixtime, $hr=0, $min=0, $sec=0, $mon=0, $day=0, $yr=0) { $dt = localtime($unixtime, true); $unixnewtime = mktime( $dt['tm_hour']+$hr, $dt['tm_min']+$min, $dt['tm_sec']+$sec, $dt['tm_mon']+1+$mon, $dt['tm_mday']+$day, $dt['tm_year']+1900+$yr ); return $unixnewtime; } function get_time_difference( $start, $end ) { $uts['start'] = $start ; $uts['end'] = $end ; if( $uts['start']!==-1 && $uts['end']!==-1 ) { if( $uts['end'] >= $uts['start'] ) { $diff = $uts['end'] - $uts['start']; if( $days=intval((floor($diff/86400))) ) $diff = $diff % 86400; if( $hours=intval((floor($diff/3600))) ) $diff = $diff % 3600; if( $minutes=intval((floor($diff/60))) ) $diff = $diff % 60; $diff = intval( $diff ); $diffs = array(); if ($days != "0") { $diffs['days'] = $days; } if ($hours != "0") { $diffs['hours'] = $hours; } if ($minutes != "0") { $diffs['minutes'] = $minutes; } if ($seconds != "0") { $diffs['seconds'] = $diff; } foreach ($diffs as $key=>$df) { $diff_text .= $df." ".$key." "; } return $diff_text; } else { return "0"; } } else { return "Invalid date/time data detected"; } return( false ); } function update_table() { $this -> bot -> db -> set_version("timeraa", 2); } function brfix($count=1) { if ($count == 2) { $br = "

";} elseif ($count == 3) { $br = "


"; } else { $br = "
"; } return $br; } } ?>