Archive > AO official modules

Central Items Database (With Icons)

(1/10) > >>

Vhab:
Made this plugin for someone that requested here on the boards.
But I figured I'd properly release it over here too.

This plugin allows you to search vhabot's central items database from ingame.
This database is located at a remote location and won't require installing or updating on your side.
It supports searching for specific QL's and will display the item icon.
At the top there are several configuration settings you can change to suit it more to your liking

Preview of the output:



--- Code: ---<?
/*
 * Central Items Database v1.1, By Vhab
 * Latest version can always be found at: http://bebot.link/index.php/topic,380.0.html
 * Details about the database itself: http://aodevs.com/index.php/topic,84.0.html
 */
$VhItems = new VhItems($bot);

$commands["tell"]["items"] = &$VhItems;
$commands["pgmsg"]["items"] = &$VhItems;
$commands["gc"]["items"] = &$VhItems;

class VhItems
{
var $icons = 'true';
var $color_header = 'DFDF00';
var $color_highlight = '97BE37';
var $color_normal = 'CCF0AD';
var $server = 'http://items.vhabot.net/';
var $max = 50;

var $bot;
function VhItems (&$bot)
{
$this->bot = &$bot;
}
function tell($name, $msg)
{
$this->bot->send_tell($name, $this->process_command($name, $msg));
}
function pgmsg($name, $msg)
{
$this->bot->send_pgroup($this->process_command($name, $msg));
}

function gc($name, $msg)
{
$this->bot->send_gc($this->process_command($name, $msg));
}

function process_command($name, $msg)
{
if (preg_match('/^'.$this->bot->commpre.'items/i', $msg, $info)) {
$words = trim(substr($msg, strlen($this->bot->commpre.'items')));
if (!empty($words)) {
$parts = explode(' ', $words);
if (count($parts) > 1 && is_numeric($parts[0])) {
$ql = $parts[0];
unset($parts[0]);
$search = implode(' ', $parts);
} else {
$ql = 0;
$search = $words;
}
$url  = $this->server;
$url .= '?bot=BeBot';
$url .= '&output=aoml';
$url .= '&max='.$this->max;
$url .= '&search='.urlencode($search);
$url .= '&ql='.$ql;
$url .= '&icons='.$this->icons;
if ($this->color_header)
$url .= '&color_header='.$this->color_header;
if ($this->color_highlight)
$url .= '&color_highlight='.$this->color_highlight;
if ($this->color_normal)
$url .= '&color_normal='.$this->color_normal;

$result = file_get_contents($url);
if (!empty($result))
return $result;
else
return "Unable to query database";
} else {
return "Usage: items [quality] [item]";
}
} else {
$this -> bot -> send_help($name);
}
}
}
?>
--- End code ---

Khalem:
This is now the default items plugin for BeBot.
Thanx Vhab.

Naturalistic:
Yeah, looks great.

*shakes fist at the select few who took credit for "making" that plugin*

joey12344:
Uber vhab :) Glad you put it into bebot

Naturalistic:
Oddly, this module won't work properly with PHP 5.1.4.

The " 4 items found -Click here- " gets displayed, but nothing is showed inside the blob.

Any ideas what needs to be fixed? I can't find anything as to what's wrong with it.

Navigation

[0] Message Index

[#] Next page

Go to full version