BeBot - An Anarchy Online and Age Of Conan chat automaton
Development => Coding and development discussion => Topic started by: Diablo on August 22, 2007, 10:21:36 pm
-
Hello im trying to update this old module i had from other bot and needed some help. The module responds but no output is shown so not sure if the results are coming out right. Any help would be great thanks. Im still new to the bot so getting more use to how it works.
$impql = new Impql($bot);
$commands["tell"]["impql"] = &$impql;
$commands["pgmsg"]["impql"] = &$impql;
$commands["gc"]["impql"] = &$impql;
/*
The Class itself...
*/
class Impql
{
var $bot;
/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function Impql (&$bot)
{
$this -> bot = &$bot;
$this -> bot -> accesscontrol -> create('all', 'impql', 'GUEST');
$this -> help['description'] = "Performs implant skill calculation";
$this -> help['command']['impql <expression>'] = "Shows the result of the matematical <expression>";
}
/*
This gets called on a tell with the command
*/
function tell($name, $msg)
{
if (preg_match("/^".$this -> bot -> commpre. "impql ([0-9]+)/i", $msg, $info))
$this -> bot -> send_tell($name, $this -> do_impql($info[1]));
else
$this -> bot -> send_help($name);
}
/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "impql (.+)/i", $msg, $info))
$this -> bot -> send_pgroup($this -> do_impql($info[1]));
}
/*
This gets called on a msg in the guildchat with the command
*/
function gc($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "impql (.+)/i", $msg, $info))
$this -> bot -> send_gc($this -> do_impql($info[1]));
}
/*
This calculates the implant quality level
*/
function do_impql($impql)
{
if(preg_match("/^impql ([0-9]+)$/i", $message, $arr)) {
if($arr[1] <= 220) {
$ql = $arr[1];
$ability = ($ql * 2) + 4;
$treatment = (($ql/10) * 47) + 7;
if($ql > 50)
{
$treatment = $treatment + 1;
}
if($ql > 70)
{
$treatment = $treatment + 1;
}
if($ql > 130)
{
$treatment = $treatment + 1;
}
if($ql > 170)
{
$treatment = $treatment + 1;
}
if($ql > 200)
{
$ability = $ability + 20;
$treatment = $treatment + 50;
}
if($ql > 205)
{
$ability = $ability + 40;
$treatment = $treatment + 50;
}
if($ql > 219)
{
$ability = $ability + 50;
$treatment = $treatment + 55;
}
return "A QL <font color=#ffff00>" .$ql. "</font> implant will require a skill of <font color=#ffff00>" .$ability. "</font> in an ability and a skill of <font color=#ffff00>" .$treatment. "</font> in treatment.";
}
}
}
}
?>
-
I see what you did, too much complexity
delete these lines altogether, as they are unnecessary:
if(preg_match("/^impql ([0-9]+)$/i", $message, $arr)) {
if($arr[1] <= 220) {
$ql = $arr[1];
and change this:
function do_impql($impql)
to this:
function do_impql($ql)
match braces to conform to syntax and it should work as intended
-
if(preg_match("/^impql ([0-9]+)$/i", $message, $arr)) {
your telling it to check $message dont u mean $impql
but prob better to do the function gc and pgroup like tell and remove the preg_match from the function as it not needed if the check is done already
$this -> bot -> send_help($name);
wont this sent the entire help .. wont the help for module better? or maybe a simple reply with what it should be like
-
Just deleting that section fixed it everything works now. Thanks