Archive > AoC 0.6.x Custom/Unofficial modules

Magic Eightball

(1/1)

TBK:
Module to display Magic Eightball quotes.

Usage:


--- Code: ---!eightball
--- End code ---


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


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



--- Code: ---<?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(&$bot, get_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;     
    }
}
?>

--- End code ---

Kyr:
There's a bug in here that won't affect anything.


--- Code: ---      $returnstr = str_replace("*dmg*",$dmg,$returnstr);
      $returnstr = str_replace("*creds*",$dmg,$returnstr);

--- End code ---

should be

--- Code: ---      $returnstr = str_replace("*dmg*",$dmg,$returnstr);
      $returnstr = str_replace("*creds*",$creds,$returnstr);

--- End code ---

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

Navigation

[0] Message Index

Go to full version