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: Problem with a check  (Read 2526 times)

0 Members and 1 Guest are viewing this topic.

Offline Pharexys

  • BeBot Apprentice
  • ***
  • Posts: 117
  • Karma: +0/-0
Problem with a check
« 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

« Last Edit: June 10, 2006, 08:50:03 pm by Pharexys »

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Problem with a check
« Reply #1 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 ;)
« Last Edit: June 10, 2006, 06:41:00 pm by Alreadythere »

Offline Pharexys

  • BeBot Apprentice
  • ***
  • Posts: 117
  • Karma: +0/-0
Re: Problem with a check
« Reply #2 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

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Problem with a check
« Reply #3 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 ;)

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Problem with a check
« Reply #4 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]).

Offline Pharexys

  • BeBot Apprentice
  • ***
  • Posts: 117
  • Karma: +0/-0
Re: Problem with a check
« Reply #5 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.

 

* 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: 488
  • 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