1
Items / Magic Eight Ball Item
« on: September 10, 2009, 05:33:47 am »
Adds a magic eightball to the shop. You can manually edit the answers if you wish. Here is an eightball icon you can add to your images as well.
Make sure to save script as eightball.php
Make sure to save script as eightball.php
Code: [Select]
<?php
// This is just to make sure that the item is used through SMF, and people aren't accessing it directly
// Additionally, this is used elsewhere in SMF (in almost all the files)
if (!defined('SMF'))
die('Hacking attempt...');
class item_eightball extends itemTemplate
{
// When this function is called, you should set all the item's
// variables (see inside this example)
function getItemDetails() {
// The author's name
$this->authorName = 'LC';
// The author's email address
$this->authorEmail = 'support@ladychaosdnb.com';
// --- Values changeable from within the SMFShop admin panel ---
// The name of the item
$this->name = "Eightball";
// The item's description
$this->desc = "An eightball, ask yes or no questions.";
// The item's price
$this->price = 50;
// --- Unchageable values ---
// These values can not be changed when adding the item, they are stuck on what you set them to here.
// Whether inputs are required by this item. In this case, we get some inputs,
$this->require_input = true;
$this->can_use_item = true;
}
function getUseInput()
{
return 'Your Question: <input type="text" name="Answer" />';
}
function onUse()
{
$result = Rand (1,8);
if ($result ==1)
{
Return "The 8-ball says: Yes";
}
if ($result ==2)
{
Return "The 8-ball says: No";
}
if ($result ==3)
{
Return "The 8-ball says: Ask again later";
}
if ($result ==4)
{
Return "The 8-ball says: Perhaps, perhaps, perhaps";
}
if ($result ==5)
{
Return "The 8-ball says: The future is hazy";
}
if ($result ==6)
{
Return "The 8-ball says: It is certain";
}
if ($result ==7)
{
Return "The 8-ball says: Without a doubt";
}
if ($result ==8)
{
Return "The 8-ball says: There is no chance";
}
}
}
?>