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
-
ok trying to remove ppl from rolls when they leave the bot was trying with this.
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"
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:
$this -> commands["pgleave"][$key] -> pgleave($user);
I was playing around trying with
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?
-
Sounds like a typo at the very top where you register the functions (the $commands[....] stuff)
Could you copy&paste that?
-
U mean this?
$commands["pgleave"][] = &$thisclass;
Edit: And I see it myself >.< Stoopid meh
And it all works like a charm.
-
/me smiles
Glad it was as simple as that. :)