collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Impql module  (Read 1701 times)

0 Members and 1 Guest are viewing this topic.

Offline Diablo

  • BeBot User
  • **
  • Posts: 67
  • Karma: +0/-0
Impql module
« 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.

Code: [Select]
$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.";
}
}

}

}
?>

Offline Parfet

  • BeBot User
  • **
  • Posts: 33
  • Karma: +0/-0
Re: Impql module
« Reply #1 on: August 22, 2007, 11:10:10 pm »
I see what you did, too much complexity

delete these lines altogether, as they are unnecessary:
Code: [Select]
if(preg_match("/^impql ([0-9]+)$/i", $message, $arr)) {
if($arr[1] <= 220) {
$ql = $arr[1];
and change this:
Code: [Select]
function do_impql($impql)to this:
Code: [Select]
function do_impql($ql)match braces to conform to syntax and it should work as intended

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Impql module
« Reply #2 on: August 22, 2007, 11:13:14 pm »
Quote
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

Quote
      $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
« Last Edit: August 22, 2007, 11:20:03 pm by Temar »

Offline Diablo

  • BeBot User
  • **
  • Posts: 67
  • Karma: +0/-0
Re: Impql module
« Reply #3 on: August 22, 2007, 11:17:25 pm »
Just deleting that section fixed it everything works now. Thanks

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 515
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal