Author Topic: Captain Basilbeard's Unoffical Item Creation Guide(Part 2 is out)  (Read 20947 times)

Offline tazpot

Re: Captain Basilbeard's Unoffical Item Creation Guide(Part 2 is out)
« Reply #15 on: May 11, 2006, 07:35:27 am »
Cheers chris i will try it in the morning  O0

Offline Basil Beard

Re: Captain Basilbeard's Unoffical Item Creation Guide(Part 2 is out)
« Reply #16 on: May 11, 2006, 10:23:17 pm »
Yup. If you scroll down you'll notice I fixed that =P. Silly typos <_<
Arrrrr!

Offline Ecko

Re: Captain Basilbeard's Unoffical Item Creation Guide(Part 2 is out)
« Reply #17 on: October 13, 2006, 10:53:52 am »
I get no error when I use my item, but I get this error if I go to it directly:


Fatal error: Class item_firescroll: Cannot inherit from undefined class itemtemplate in

Here it is:

Code: [Select]
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2005 DanSoft Australia           |
|      http://www.dansoftaustralia.com/        |
\**********************************************/

//File: testitem.php
//      Test Item (requires NO input)

//VERSION: 1.1 (Build 4)
//DATE: 10th April 2005
// $Id: testitem.php 3 2006-07-08 10:01:21Z daniel15 $

//your class should always be called item_filename, eg. if your file is 
//myCoolItem.php then the class should be called 'item_myCoolItem'. This 
//class should always extend itemTemplate.
class item_FireScroll extends itemTemplate {
    
    
//when this function is called, you should set all the item's
    //variables (see inside this example)
    
function getItemDetails() {

        
//VALUES CHANGABLE FROM WITHIN ADMIN PANEL:
          //the name of the item
          
$this->name "Firebending Scroll";
          
//the item's description
          
$this->desc "Learn a new attack! Or an old one...!";
          
//the item's price
          
$this->price 500;
          
        
//UNCHANGABLE VALUES:
          //whether the item requires input or not. In this case, we don't need
          //any input
          
$this->require_input false;
          
//set this to 'false' if the item is unusable. This is good for display
          //items.
          
$this->can_use_item true;
    }

    
//since this item requires no input, we don't need to have a getUseInput function
    //here (see the testitem2.php file if you want to make an item that needs input.


    //the is where all the fun begins. This function is called when 
    //the user actually uses the item. Return stuff, DON'T ECHO!
    
function onUse() {
         
$quotes file('fireattacks.txt');
         return (
$quotes[rand(0count($quotes) -1)]);
 
    }
}


?>


Offline Daniel15

Re: Captain Basilbeard's Unoffical Item Creation Guide(Part 2 is out)
« Reply #18 on: October 13, 2006, 07:14:48 pm »
Quote
I get no error when I use my item, but I get this error if I go to it directly:


Fatal error: Class item_firescroll: Cannot inherit from undefined class itemtemplate in
You're not meant to go to the item directly, as that will always happen (indeed, I should have implemented better error handling in the items).

Adding something like this just above the 'class item_FireScroll' line would prevent the ugly message (just make sure that the file is indeed called 'FireScroll.php':
Code: [Select]
if (eregi("FireScroll.php",$_SERVER['PHP_SELF'])) die("You can't run this directly!");
Basically, this checks if you're running FireScroll.php, and if you are, show an error. When you're using the item, the user is actually accessing index.php, so the error won't be displayed.
« Last Edit: October 13, 2006, 07:18:25 pm by daniel15 »

Offline Ecko

Re: Captain Basilbeard's Unoffical Item Creation Guide(Part 2 is out)
« Reply #19 on: October 14, 2006, 04:22:10 am »
Lol, when I meant I get no error when I use the item, I also meant to put that nothing happens.

It's supposed to return a line from fireattacks.txt, but it does not. Help pls?

Offline Ecko

Re: Captain Basilbeard's Unoffical Item Creation Guide(Part 2 is out)
« Reply #20 on: October 14, 2006, 04:37:51 am »
Edit:

I changed it by using an array instead of making it read from a file. Longer, but it works so meh.

Now I just need it to send that same message to both the user and Admin :X

Offline inkstains

Re: Captain Basilbeard's Unoffical Item Creation Guide(Part 2 is out)
« Reply #21 on: March 22, 2007, 12:52:59 am »
hi

how can you use more than four function getAddInput() ? and why does the limitation exist?

awesome tutorial btw Basil Beard

cheers
« Last Edit: March 23, 2007, 07:12:33 am by inkstains »

Offline Daniel15

Re: Captain Basilbeard's Unoffical Item Creation Guide(Part 2 is out)
« Reply #22 on: March 24, 2007, 10:43:16 am »
Quote
how can you use more than four function getAddInput() ? and why does the limitation exist?
The limitation is because of how I've coded the getAddInput() values - They're stored in 4 seperate database fields in the smf_shop_items table (hence the limitation). I'll try to work on storing these in a better format, which should allow an unlimited number of values :)