BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => BeBot 0.2 support => Topic started by: Solerna on December 06, 2005, 03:04:44 am

Title: function pgleave
Post by: Solerna on December 06, 2005, 03:04:44 am
ok trying to remove ppl from rolls when they leave the bot was trying with this.

Code: [Select]
function pgleave($name) {
$num = 0;
foreach($this -> loot as $slot) {
$num++;
unset($this -> loot[$num][$name]);
}
  }


However that instantly crashes the bot as soon as someone leaves the group.

if I rename the function and use it as the result of a command, it works as intended.

The error I get is:

"Fatal error: Call to a member function on a non-object in C:\bebot\Bot.php on line 455"

Code: [Select]
   function inc_pgleave($args)
    {
      $user = $this -> aoc -> get_uname($args[1]);

      $this -> log("PGRP", "LEAVE", $user . " left privategroup.");

      if (!empty($this -> commands["pgleave"]))
      {
        $keys = array_keys($this -> commands["pgleave"]);
        foreach ($keys as $key)
          $this -> commands["pgleave"][$key] -> pgleave($user);
      }
    }


Line 455 being:

Code: [Select]

          $this -> commands["pgleave"][$key] -> pgleave($user);


I was playing around trying with

Code: [Select]
if (isset($this -> loot[$num][$name])){
        unset($this -> loot[$num][$name]);
}


Giving the sameresult. Crash with the same error msg. Did not try this one as reaction to a command though.

Now any ideas anyone?
Title: function pgleave
Post by: Blondengy on December 06, 2005, 06:19:26 pm
Sounds like a typo at the very top where you register the functions (the $commands[....] stuff)

Could you copy&paste that?
Title: function pgleave
Post by: Solerna on December 06, 2005, 07:01:50 pm
U mean this?

Code: [Select]
$commands["pgleave"][] = &$thisclass;


Edit: And I see it myself >.< Stoopid meh
And it all works like a charm.
Title: function pgleave
Post by: Blondengy on December 06, 2005, 07:50:12 pm
/me smiles

Glad it was as simple as that. :)
SimplePortal 2.3.7 © 2008-2025, SimplePortal