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?
August 29, 2008, 08:36:25 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Support > Support for older versions > BeBot 0.3 support > Topic: Help with Buff-Module
Pages: [1]   Go Down
« previous next »
Print
Author Topic: Help with Buff-Module  (Read 1063 times)
0 Members and 1 Guest are viewing this topic.
Catscratch
Freshman
*
Offline Offline

Posts: 6


Help with Buff-Module
« on: July 22, 2007, 06:39:44 AM »

Hi there,

I'm developing a buff-module for bebot. But I've got a problem with the bebot buddy function.

I want that these bot is open for everyone. So a player can add his buffs. Now I want the remove this player, if he goes offline. Therefor I used the buddy function with buddy_add(...).

But in my module, the player is removed immediately after he registers his buff.

I hope someone could help me. I don't know whats wrong.

The buff module:
Code:
<?
/*
* Buffs.php
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
*
*/


$buffs = new buffs($bot);


$commands["tell"]["buffs"] = &$buffs;
$commands["pgmsg"]["buffs"] = &$buffs;




/*
The Class itself...
*/
class Buffs
{
var $bot;
var $buffs;



/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function Buffs (&$bot)
{
$this -> bot = &$bot;
$this -> buffs = array();
}



/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name, $msg)
{
        if (preg_match("/^" . $this -> bot -> commpre . "buffs add (.+)/i", $msg, $info))
        $this -> buffers_add($name, $info[1], 1);
    else if (preg_match("/^" . $this -> bot -> commpre . "buffs del/i", $msg, $info))
        $this -> buffers_del($name, 1);
        else if (preg_match("/^" . $this -> bot -> commpre . "buffs clear/i", $msg, $info))
        $this -> buffers_del_all($name, 1);
        else if (preg_match("/^" . $this -> bot -> commpre . "buffs/i", $msg))
        $this -> bot -> send_pgroup($this -> show_buffers());
}

function tell($name, $msg)
{
        if (preg_match("/^" . $this -> bot -> commpre . "buffs add (.+)/i", $msg, $info))
        $this -> buffers_add($name, $info[1], 2);
    else if (preg_match("/^" . $this -> bot -> commpre . "buffs del/i", $msg, $info))
        $this -> buffers_del($name, 2);
        else if (preg_match("/^" . $this -> bot -> commpre . "buffs clear/i", $msg, $info))
        $this -> buffers_del_all($name, 2);
        else if (preg_match("/^" . $this -> bot -> commpre . "buffs/i", $msg))
        $this -> bot -> send_tell($name, $this -> show_buffers());
}



/*
Add a buffer
*/
function buffers_add($name, $buffs, $nr)
{
$name = ucfirst(strtolower($name));

if ($this -> bot -> aoc -> get_uid($name))
{
$this -> buffs[$name] = $buffs;
if($nr == 1)
$this -> bot -> send_pgroup("<font color=#ffff00>" . $name . "</font> has been added to buffers list. ($buffs) " . $this -> show_buffers());
else
$this -> bot -> send_tell($name, "<font color=#ffff00>" . $name . "</font> has been added to buffers list. ($buffs) " . $this -> show_buffers());
}
else if($nr == 1)
$this -> bot -> send_pgroup("Player <font color=#ffff00>" . $name . "</font> does not exist.");
else if($nr == 2)
$this -> bot -> send_tell($name, "Player <font color=#ffff00>" . $name . "</font> does not exist.");

}


/*
Remove a buffer
*/
function buffers_del($name, $nr)
{
$name = ucfirst(strtolower($name));

if ($name == "All")
{
$this -> buffs = array();
$this -> bot -> send_pgroup("List of buffers has been cleared.");
}
else if ($this -> bot -> aoc -> get_uid($name) != -1)
{
if (isset($this -> buffs[$name]))
{
unset($this -> buffs[$name]);
if($nr == 1)
$this -> bot -> send_pgroup("<font color=#ffff00>" . $name . "</font> has been removed from buffers list. " . $this -> show_buffers());
else
$this -> bot -> send_tell($name, "<font color=#ffff00>" . $name . "</font> has been removed from buffers list. " . $this -> show_buffers());
}
else if($nr == 1)
$this -> bot -> send_pgroup("<font color=#ffff00>" . $name . "</font> is not on list of buffers. " . $this -> show_buffers());
else
$this -> bot -> send_tell($name, "<font color=#ffff00>" . $name . "</font> is not on list of buffers. " . $this -> show_buffers());
}
else if($nr == 1)
$this -> bot -> send_pgroup("Player <font color=#ffff00>" . $name . "</font> does not exist.");
else
$this -> bot -> send_tell($name, "Player <font color=#ffff00>" . $name . "</font> does not exist.");
}

function buffers_del_all($name, $nr)
{
if ($this -> bot -> admin -> in_group($name, "admin"))
{
$this -> buffs = array();
if($nr == 1)
$this -> bot -> send_pgroup("List of buffers has been cleared.");
else
$this -> bot -> send_tell($name, "List of buffers has been cleared.");
}
else if($nr == 1)
$this -> bot -> send_pgroup("You must be an admin to access this command.");
else
$this -> bot -> send_tell($name, "You must be an admin to access this command.");
}



/*
Return the list of buffers
*/
function show_buffers()
{
$buff = array_keys($this -> buffs);
if (empty($buff))
return "No buffers on list.";
else
{
$list = "<font color=CCInfoHeadline>::: List of buffers :::</font>\n\n";
foreach ($buff as $player) {
$tempname = ucfirst(strtolower($player));

$templist .= " - <a href='chatcmd:///tell $player'>$player</a>: ".$this -> buffs[$tempname];

$uid = $this -> bot -> aoc -> get_uid($tempname);

if (!($this -> bot -> aoc -> buddy_exists($uid))) {
$this -> bot -> aoc -> buddy_add($uid);
//$templist .= " #no# ";
} else;
//$templist .= " #yes# ";

if($this -> bot -> aoc -> buddy_online($uid));
// $templist .= "- online\n";
else {
//$templist .= "- offline\n";
if (isset($this -> buffs[$tempname]))
{
unset($this -> buffs[$tempname]);
}
}
$list .= $templist;
}
return $this -> bot -> make_blob("List of Buffers", $list);
}
}

}
?>

The last function (show_buffers) is this one, where this error occurs.
I do "$this -> bot -> aoc -> buddy_add($uid);" and after this I call "if($this -> bot -> aoc -> buddy_online($uid));" and thats always false at the first time. If I call this method after show_buffers was successful, it returns true. But why?

It may be helpful, if you test this module in your own bebot. :-)


Thanks for help,
(and sry for my bad english) Wink

MFG
« Last Edit: July 22, 2007, 11:38:31 AM by Catscratch » Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1018


Re: Help with Buff-Module
« Reply #1 on: July 22, 2007, 06:46:54 AM »

Characters not on the notify list will be removed as buddies right away.

Which mean you'll have to add everyone that is registering to the notify list first.

$this->bot->notify->add($source, $name) is the function for this.
Logged
Catscratch
Freshman
*
Offline Offline

Posts: 6


Re: Help with Buff-Module
« Reply #2 on: July 22, 2007, 08:46:03 AM »

Can you give me an example, how to register right?

I tried: $this -> bot -> notify -> add($this, $uid);

I thought, $source is the source-class, isn't it?

With this code above, the bot restarts at this point.

Thanks.
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1018


Re: Help with Buff-Module
« Reply #3 on: July 22, 2007, 10:26:43 AM »

$this->bot->notify->add("Buff Module", $name);
Logged
Catscratch
Freshman
*
Offline Offline

Posts: 6


Re: Help with Buff-Module
« Reply #4 on: July 22, 2007, 11:36:48 AM »

It's the same as before.

I tried:
Code:
if (!($this -> bot -> aoc -> buddy_exists($uid))) {
$this -> bot -> notify -> add("Buff Module", $uid); // I also tried player's name
$this -> bot -> aoc -> buddy_add($uid);
}

But at this point, the bot restarts.
Logged
Catscratch
Freshman
*
Offline Offline

Posts: 6


Re: Help with Buff-Module
« Reply #5 on: July 24, 2007, 11:30:55 AM »

Ok, I thought that I'm using Bebot 0.3, but I'm using version 0.2x. May this help to find out why this buddy_add function don't work?

I also tried to add this module to the new version 0.4. But there this module isn't loaded. I think I have to tansform something to bring it up in new bebot. But at this time, I don't know exactly what.

Thanks for help.
« Last Edit: July 24, 2007, 11:32:30 AM by Catscratch » Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1018


Re: Help with Buff-Module
« Reply #6 on: July 24, 2007, 01:22:37 PM »

notify->add() takes the player name. But of course it won't work in 0.2, there you'll have to adapt the inc_buddy() function in Bot.php to handle notifies outside of members.

In 0.4 you just need to call the notify->add() function, it does all the ckecking and adding. No need to check the buddy list yourself there.

Just make sure you don't go over 1k buddies, or you'll most likely get disconnected from the chatserver.
Logged
clashbot
Apprentice
***
Offline Offline

Gender: Male
Posts: 149



Re: Help with Buff-Module
« Reply #7 on: January 29, 2008, 12:40:31 PM »

have we got this working so it will work with the .4 version?
Logged
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Support > Support for older versions > BeBot 0.3 support > Topic: Help with Buff-Module
« previous next »
 
Jump to:  

Recent
Dont get any TowerAttack ...
by Ziodberg
[Today at 06:15:35 PM]

Org Relaying
by Nytridr
[Today at 03:43:06 PM]

Auto reinvite not setting...
by Temar
[Today at 02:12:59 PM]

Link 2 Guilds via 2 Bots?
by Nytridr
[Today at 01:19:39 PM]

Question about Logon.php
by Temar
[Today at 07:17:13 AM]

MOTD module from 2.x to 4...
by Karsta
[Today at 04:14:55 AM]

Upcoming Channels
by Temar
[Today at 04:00:07 AM]

Reducing the load on a se...
by Alreadythere
[August 28, 2008, 03:29:35 PM]

Ported Modules
by krommel
[August 28, 2008, 12:01:19 PM]

Communication between gui...
by Temar
[August 27, 2008, 08:28:49 PM]
Stats
Members
Total Members: 949
Latest: pobo
Stats
Total Posts: 10356
Total Topics: 1406
Online Today: 20
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 1
Guests: 37
Total: 38
Chakki

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