SMFShop > Items

Fortune Cookie item!

(1/1)

Coolgem:
This one's different then my previous items. This one does not require any input from the admin. It is a fortune cookie that tells users their fortune. Makes sense.  :D Let me know what you think.

Save as fortune.php

Code:

--- Code: ---<?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_fortune 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 = 'coolgem923';
      // The author's email address
      $this->authorEmail = 'private';
      
      // --- Values changeable from within the SMFShop admin panel ---
      // The name of the item
      $this->name = "Fortune Cookie";
      // The item's description
      $this->desc = "What's your fortune?";
      // The item's price
      $this->price = 50;

      // --- Unchangeable 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 no inputs.
      $this->require_input = false;
      
      $this->can_use_item = true;
   }
   
   function onUse()
   {
      $result = Rand (1,8); 

if ($result ==1) 

Return "You may be rich."; 


if ($result ==2) 

Return "Evil things are coming your way..."; 


if ($result ==3) 

Return "You will find a little suprise from your friend."; 


if ($result ==4) 

Return "Your long-lost friend will see you again."; 


if ($result ==5) 

Return "Your favorite thing may fall off a cliff and you will never see it again."; 


if ($result ==6) 

Return "You will win the lottery."; 


if ($result ==7) 

Return "You will turn into a humble king."; 


if ($result ==8) 

Return "You will journey to a land far away of peace and quiet."; 

}
}
?>
--- End code ---

ariescapes:
>.> I'm late to the game!
I love this item! I want to use if for roleplaying, modifying it to random events or prompts. However, I can only have it once, not as multiple "items" with different fortunes. Any suggestions?

Navigation

[0] Message Index

Go to full version