Archive > AoC 0.6.x Custom/Unofficial modules

Offline AA training timer module

<< < (2/8) > >>

Yite:
NOTE: These are code snippets, to use them copy them into the main module. If you are not sure about that leave it for now and wait for an updated module (if Getrix want this to be part of his module that is)

I added a new function showall (code below) basically returns a blob with the times of all alts as well.


--- Code: ---     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]);}
$output = "<Center>##ao_infoheadline##:::: Offline timer info for $main and alts ::::##end##</Center>\n\n";

$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_cooldown   = $aa[4];
                $today  = time();
                $diff = $this->get_time_difference($today, $timeraa_end);

                $output .= "$main has ".$diff['days']." days, ".$diff['hours']." hour, ".$diff['minutes']." min, ".$diff['seconds']." sec left until cooldown.\n";
            }
        }
        else { $output .= "$main has no timer set.\n"; }

$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_cooldown   = $aa[4];
                $today  = time();
                $diff = $this->get_time_difference($today, $timeraa_end);
                $output .= "$charname has ".$diff['days']." days, ".$diff['hours']." hour, ".$diff['minutes']." min, ".$diff['seconds']." sec left until cooldown.\n";
              }
    }
    else { $output .= "$charname has no timer set.\n"; }
  }
}
}
$output = $this -> bot -> core("tools") -> make_blob("AA timers for $main", $output);
return $output;
}
--- End code ---

It will also need an extra case in the sub_handler:


--- Code: ---            case 'showall':
                return($this -> timer_show_all($name, $com['args']));
            break;
--- End code ---


Usage: (As I didn't update the help)
!timeraa showall [character]

It will find the character's main and then list all timers in a blob, if no character is specified it will show for the person who typed the command.

Getrix:
Thanx Yite.
I modified it abit to support some changes i did in calculation in b1.0.2

// b1.0.3 Added "timeraa showall <nick>" to include alts of a chars. (Thanks to Yite@BeBot Forum)

URL: http://dump.sjef.biz/aoc/bebot/TimerAA/TimerAA.phps

dillinger:
Yeah, very nice and useful module, thanx @ Getrix! This makes the AA overview much easyer, even with 8 lvl 80 chars!  ;)

GBH:
Yay showall saved me todays bit of coding too!

You guys rock or something ;)

G

Yite:
It 'cost' me a few hours until I found that the select statement provided an array of arrays.

What I would like to still do on the showall is:
* filter out non 80's (non 80's can't train on time)
* sort the output by skill time left (probably a matter of putting the output strings in an array and sorting it

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version