BeBot - An Anarchy Online and Age Of Conan chat automaton

Development => Coding and development discussion => Topic started by: Pharexys on June 10, 2006, 06:16:47 pm

Title: Problem with a check
Post by: Pharexys on June 10, 2006, 06:16:47 pm
Ok so im working on a module, what i want for this module to do is pretty simple.
To be something like:
!sb atrox
returns, all Atrox lvl 205+.
!sb opi
returns, all Opifex lvl 205+.
u get the idea :P

So far.. it works nice, only problems i get is the bot add any lvl to this list, wich aint good :P
So i tryd to edit the pgjoin function, but seems i cant get it to work.. couldnt find any module that do this so i see how this stuff work. So my last option is to ask on this forum i guess
This is the edited function i tryd to do.. dunno what i wrong, becouse i dont really know much about coding.


Code: [Select]
/*
This gets called if someone joins the privgroup
*/
function pgjoin($name)
{
    $joiner = $this -> bot -> whois -> lookup($name);
    $res = ($joiner -> breed == "Atrox" ) && $joiner -> level >= 205;
    $res1 = ($joiner -> breed == "Solitus" ) && $joiner -> level >= 205;
          if (!empty($res))
                        return true;
                else
                        return $this -> bot -> db -> query("INSERT INTO sb_list (name, breed) VALUES ('" . $joiner['name'] . "', '" . $joiner['breed'] . "')");
         
          if (!empty($res1))
                        return true;
                else
                        return $this -> bot -> db -> query("INSERT INTO sb_list (name, breed) VALUES ('" . $joiner['name'] . "', '" . $joiner['breed'] . "')");
         
}

Oh and other problem i get is that when i do !sb atrox or any other breed,
he restarts and tells me this :
Code: [Select]
Fatal error: Call to a member function select() on a non-object in C:\bebot\r
aidbot\modules\Count_SB.php on line 43

Line 43 is pretty much good, nothing bad i can see on it.
Code: [Select]
$infos = $this -> bot -> db -> select("SELECT * FROM " . $this -> bot -> get_tablename("sb")
. " ORDER BY breed ASC");

So i think there is something wrong here:

Code: [Select]
elseif (preg_match("/^" . $this -> bot -> commpre . "sb (.*)$/i", $msg, $info))
$this -> bot -> send_pgroup($this -> sb($info[1]));
But when i look on this line.. i cant understand anything hehe
so i dont really know what to modify or not :P

Title: Re: Problem with a check
Post by: Alreadythere on June 10, 2006, 06:39:04 pm
If you are using the whois cache I posted it should be $joiner['breed'] and $joiner['level'] instead of $joiner -> breed and $joiner -> level.

Other point, why not use only one if check like
Code: [Select]
if (($joiner['breed'] == 'Atrox' || $joiner['breed'] == 'Solitus') && ($joiner['level'] >= 205)) { /*adding here*/}
PS: just trying some first hints, haven't checked around for much more errors ;)
Title: Re: Problem with a check
Post by: Pharexys on June 10, 2006, 07:01:32 pm
Ok modified to:

Code: [Select]
function pgjoin($name)
{
    $joiner = $this -> bot -> whois -> lookup($name);
    if (($joiner['breed'] == 'Atrox' || $joiner['breed'] == 'Solitus' || $joiner['breed'] == 'Opifex' || $joiner['breed'] == 'Nanomage') && ($joiner['level'] >= 205))
         
                        return $this -> bot -> db -> query("INSERT INTO sb_list (name, breed) VALUES ('" . $joiner['name'] . "', '" . $joiner['breed'] . "')");
                else
                        return false;
               
         
}

and now the check works,
Only problem i have is that when i do !sb opi or any other breed, it restarts :(

gonna update file on ftp also
Title: Re: Problem with a check
Post by: Alreadythere on June 10, 2006, 08:00:52 pm
If you add any of the 4 breeds, why are you checking for them? Just check level then ;)
Title: Re: Problem with a check
Post by: Alreadythere on June 10, 2006, 08:01:51 pm
And crash - you got to rename the count function to sb, as you are calling $this -> sb($info[1]).
Title: Re: Problem with a check
Post by: Pharexys on June 10, 2006, 08:08:14 pm
aight thanks man, got it work now :D
only got a problem with shortcuts seems he doest find em or something, gonna try solve it.
SimplePortal 2.3.7 © 2008-2025, SimplePortal