SMF Shop

SMFShop => Completed Additions => Items => Topic started by: ladychaos on September 10, 2009, 05:33:47 am

Title: Magic Eight Ball Item
Post by: ladychaos 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. (http://i203.photobucket.com/albums/aa252/LadyChaos_photos/Eight-Ball-32x32.gif)

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"

}
}
?>
Title: Re: Magic Eight Ball Item
Post by: Chinaren on September 20, 2009, 06:58:02 pm
Cool, works well.  Thanks!
Title: Re: Magic Eight Ball Item
Post by: steve51184 on February 08, 2010, 02:27:22 pm
does this work on smf 2.0 rc2?
Title: Re: Magic Eight Ball Item
Post by: steve51184 on August 22, 2010, 07:59:56 am
6.5 month bump ;)
Title: Re: Magic Eight Ball Item
Post by: RugratsFan2 on June 12, 2011, 09:23:52 pm
Awesome this is working great!