collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Magic Eightball  (Read 6205 times)

0 Members and 1 Guest are viewing this topic.

Offline TBK

  • BeBot User
  • **
  • Posts: 26
  • Karma: +0/-0
Magic Eightball
« on: June 20, 2010, 04:18:18 am »
Module to display Magic Eightball quotes.

Usage:

Code: [Select]
!eightball

1. Download the file
2. Move it to custom/module/
3. Restart the bot


Download: http://www.mediafire.com/?mwbmi6sb7lptql2


Code: [Select]
<?php
/*
* eightball.php - A Social Module
*
* Developed by Sicarius Legion of Amra
* a Age of Conan Guild on the Hyrkania server
*
*/
   
/*
Add a "_" at the beginning of the file (_eightball.php) if you do not want it to be loaded.
*/
 
$eightball = new EightBall($bot);

/*
The Class itself...
*/
class EightBall Extends BaseActiveModule {
var $bot;
var $eightball;
var $returnstr;


    
/*
      Constructor:
        Hands over a referance to the "Bot" class.
    */
    
function __construct (&$bot) {
parent::__construct(&$botget_class($this));

$this -> register_command("all""eightball""MEMBER");

$this -> help['description'] = "Shows eightball quotes.";
$this -> help['command']['eightball']="Use !eightball to generate a random eightball quote";
    }

function command_handler($name$msg$origin) {
$output "";

if (preg_match("/^eightball$/i"$msg$info)) {
$output $this -> get_eightball($name);
}
return $output;
}
   
   
    
/*
      This gets called on a msg in the guildchat with the command
    */
    
function irc($name$msg) {
$returnstr $this -> get_eightball($name);
$this -> bot -> send_gc($returnstr);
$this -> bot -> send_irc("""""3" $returnstr);
    }

  
    
/*
      Build response
    */
    
function get_eightball($name) {
$eightball = array(
"As I see it, yes",
"It is certain",
"It is decidedly so",
"Most likely",
"Outlook good",
"Signs point to yes",
"Without a doubt",
"Yes",
"Yes - definitely",
"You may rely on it",
"Reply hazy, try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful"
);

// You can add more possible responses to the array above.
$dmg rand(100,999);
$creds rand(10000,9999999);
$returnstr $eightball[rand(0,sizeof($eightball)-1)];
$returnstr str_replace("*name*",$name,$returnstr);
$returnstr str_replace("*dmg*",$dmg,$returnstr);
$returnstr str_replace("*creds*",$creds,$returnstr);
return $returnstr;     
    }
}
?>

« Last Edit: August 19, 2010, 03:00:40 pm by TBK »

Offline Kyr

  • BeBot Apprentice
  • ***
  • Posts: 177
  • Karma: +0/-0
Re: Magic Eightball
« Reply #1 on: June 20, 2010, 07:18:28 am »
There's a bug in here that won't affect anything.

Code: [Select]
      $returnstr = str_replace("*dmg*",$dmg,$returnstr);
      $returnstr = str_replace("*creds*",$dmg,$returnstr);

should be
Code: [Select]
      $returnstr = str_replace("*dmg*",$dmg,$returnstr);
      $returnstr = str_replace("*creds*",$creds,$returnstr);

But like I said, it doesn't have any affect unless you add your own return values that actually use these randomly created values.

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 171
  • 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