L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 01, 2008, 02:02:59 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Coding and development discussion > Topic: Impql module
Pages: [1]   Go Down
« previous next »
Print
Author Topic: Impql module  (Read 230 times)
0 Members and 1 Guest are viewing this topic.
Diablo
Rookie
**
Offline Offline

Posts: 67


Impql module
« on: August 22, 2007, 03: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:
$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.";
}
}

}

}
?>
Logged
Parfet
Rookie
**
Offline Offline

Posts: 33


Re: Impql module
« Reply #1 on: August 22, 2007, 04:10:10 PM »

I see what you did, too much complexity

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

Gender: Male
Posts: 877



WWW
Re: Impql module
« Reply #2 on: August 22, 2007, 04: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, 04:20:03 PM by Temar » Logged

MSN messenger: chris_smith96 at hotmain dot com
Xfire: chriss96
Diablo
Rookie
**
Offline Offline

Posts: 67


Re: Impql module
« Reply #3 on: August 22, 2007, 04:17:25 PM »

Just deleting that section fixed it everything works now. Thanks
Logged
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Coding and development discussion > Topic: Impql module
« previous next »
 
Jump to:  

Recent
[request] Raid timers
by Alreadythere
[Today at 11:42:32 AM]

Shared DB online list
by Temar
[Today at 01:55:47 AM]

relay colors
by Temar
[Today at 01:54:56 AM]

BeBot v0.6.0 released
by Alreadythere
[November 30, 2008, 05:32:00 PM]

Change to Bid.php
by Temar
[November 30, 2008, 11:41:44 AM]

OnlineOrg
by Jiheld
[November 29, 2008, 12:44:27 PM]

Silly Newbie Question.
by Temar
[November 29, 2008, 12:00:02 PM]

massive_pvp_time_table 1
by gerborg
[November 29, 2008, 06:55:35 AM]

Bot not see Guild Chat
by Delvar
[November 28, 2008, 08:30:34 AM]

Starting Bot
by Allisande
[November 28, 2008, 07:08:21 AM]
Stats
Members
Total Members: 1243
Latest: Whackoeng
Stats
Total Posts: 11143
Total Topics: 1505
Online Today: 21
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 1
Guests: 16
Total: 17

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.378 seconds with 28 queries. (Pretty URLs adds 0.024s, 4q)
Loading...