Author Topic: Need help with making an Item  (Read 14666 times)

Offline OrangeStar

Need help with making an Item
« on: December 20, 2006, 02:17:00 pm »
Hi, i need help making a item. I am new to smf.

The name of the item is: Garden Mixers: The New Revolution

The description is: Exclusive and Rare Badges that can be won. The exciting part is that YOU get to pick which Badges you want to win!

Price: 50000

And one you use the item I need it to say

Thank You for purching Garden Mixers: The Revolution!

In 10 Seconds, you will be redirected to a special webpage were you will choose what Badges you want to win!

DO NOT GIVE THIS WEBPAGE OUT. IF YOU DO AND YOU ARE CAUGHT, YOU WILL BE FACED WITH A 100,000 GARDEN BUX FINE AND A 2 DAY BAN FROM BADGE GARDEN.
<meta HTTP-EQUIV="REFRESH" content="10; url=http://www.WEBSITEHERE.HOST.com/xxxxxxxxxxxx/xxx.html">

Offline feeble

Re: Need help with making an Item
« Reply #1 on: December 20, 2006, 02:28:29 pm »
umm, why would you just load the page up when the user "uses" the item.

like the page details are in the on_use function of the item

Offline OrangeStar

Re: Need help with making an Item
« Reply #2 on: December 20, 2006, 02:29:26 pm »
umm, why would you just load the page up when the user "uses" the item.

like the page details are in the on_use function of the item

can you write that as a code for me? I have no idea with coding

Offline Daniel15

Re: Need help with making an Item
« Reply #3 on: December 20, 2006, 05:18:25 pm »
Hi OrangeStar, welcome to the forum :)
Take a look at the testitem2.php file if you wish to create your own item. Basically, the getUseInput() function is called when the user wants to uses the item, and the onUse() function is called once the item is actually being used (when they've entered the information specified in the getUseInput() function).

Depending on the content of the web page you're redirecting to, you may like to put its contents into the getUseInput() function (if the user has a form to submit), or the onUse() function. If you want the results to be emailed to you, check out the 'Email to Admin' item :)

Offline OrangeStar

Re: Need help with making an Item
« Reply #4 on: December 20, 2006, 05:20:17 pm »
okay thanks I will try that

Offline OrangeStar

Re: Need help with making an Item
« Reply #5 on: December 20, 2006, 05:32:52 pm »
Hi OrangeStar, welcome to the forum :)
Take a look at the testitem2.php file if you wish to create your own item. Basically, the getUseInput() function is called when the user wants to uses the item, and the onUse() function is called once the item is actually being used (when they've entered the information specified in the getUseInput() function).

Depending on the content of the web page you're redirecting to, you may like to put its contents into the getUseInput() function (if the user has a form to submit), or the onUse() function. If you want the results to be emailed to you, check out the 'Email to Admin' item :)


help!!!!!!!!!!!!!!!!!! lol

i have no clue what i am doing

Code: [Select]
<?php

/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2006 DanSoft Australia           |
|      http://www.dansoftaustralia.net/        |
\**********************************************/

//File: testitem.php
//      Test Item (gets some inputs, most likely you will base your items on this)

// VERSION: 2.3 (Build 11)
// $Date: 2006-10-21 13:34:18 +1000 (Sat, 21 Oct 2006) $
// $Id: testitem2.php 24 2006-10-21 03:34:18Z 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_testitem2 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 "Daniel15";
// The author's email address
$this->authorEmail "dansoft@dansoftaustralia.net";

        
//VALUES CHANGEABLE FROM WITHIN ADMIN PANEL:
          // The name of the item
          
$this->name "Garden Mixers: The New Revolution";
          
// The item's description
          
$this->desc "Exclusive and Rare Badges that can be won. The exciting part is that YOU get to pick which Badges you want to win!";
          
// The item's price
          
$this->price 50000;

        
//UNCHANGABLE VALUES:
          // Whether inputs are required by this item. In this case, we get some inputs,
          // so set this to 'true'.
          
$this->require_input true;
          
// Set this to 'false' if the item is unusable. This is good for display
          // items.
          
$this->can_use_item true;
    }

    
// This function is called when the user tries to use the item.
    // If your item needs any further user input then you can get that 
    // input here (eg. if it's a "Change username" item then you have
    // to ask the user what they'd like to change their username to).
    // Any text you return will get shown to the user (DON'T ECHO STUFF).
    
function getUseInput() {
        return 
"Thank You for purching Garden Mixers: The Revolution!<br />In 10 Seconds, you will be redirected to a special webpage were you will choose what Badges you want to win!<br /> DO NOT GIVE THIS WEBPAGE OUT. IF YOU DO AND YOU ARE CAUGHT, YOU WILL BE FACED WITH A 100,000 GARDEN BUX FINE AND A 2 DAY BAN FROM BADGE GARDEN.<meta HTTP-EQUIV="REFRESH" content="10url=http://www.badgegarden.mbhosting.com/GardenMixers/Set1.html">";
    
}

    
// This is where all the fun begins. This function is called when 
    // the user actually uses the item. Return stuff, DON'T ECHO!
    
function onUse() {
        return 
"Thank You for purching Garden Mixers: The Revolution!<br />In 10 Seconds, you will be redirected to a special webpage were you will choose what Badges you want to win!<br /> DO NOT GIVE THIS WEBPAGE OUT. IF YOU DO AND YOU ARE CAUGHT, YOU WILL BE FACED WITH A 100,000 GARDEN BUX FINE AND A 2 DAY BAN FROM BADGE GARDEN.<meta HTTP-EQUIV="REFRESH" content="10url=http://www.badgegarden.mbhosting.com/GardenMixers/Set1.html">";
    
}
}

?>


Offline Daniel15

Re: Need help with making an Item
« Reply #6 on: December 20, 2006, 05:43:34 pm »
You'd only want to put that in the onUse() function, not the getUseInput(). Additionally, quotes should be escaped (\"). Try this:
Code: [Select]
<?php

/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2006 DanSoft Australia           |
|      http://www.dansoftaustralia.net/        |
\**********************************************/

//File: testitem.php
//      Test Item (gets some inputs, most likely you will base your items on this)

// VERSION: 2.3 (Build 11)
// $Date: 2006-10-21 13:34:18 +1000 (Sat, 21 Oct 2006) $
// $Id: testitem2.php 24 2006-10-21 03:34:18Z 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_GardenMixers 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 "OrangeStar";

        
//VALUES CHANGEABLE FROM WITHIN ADMIN PANEL:
          // The name of the item
          
$this->name "Garden Mixers: The New Revolution";
          
// The item's description
          
$this->desc "Exclusive and Rare Badges that can be won. The exciting part is that YOU get to pick which Badges you want to win!";
          
// The item's price
          
$this->price 50000;

        
//UNCHANGABLE VALUES:
          // Whether inputs are required by this item. In this case, we get some inputs,
          // so set this to 'true'.
          
$this->require_input false;
          
// Set this to 'false' if the item is unusable. This is good for display
          // items.
          
$this->can_use_item true;
    }

    
// This is where all the fun begins. This function is called when 
    // the user actually uses the item. Return stuff, DON'T ECHO!
    
function onUse() {
        return 
"Thank You for purching Garden Mixers: The Revolution!<br />In 10 Seconds, you will be redirected to a special webpage were you will choose what Badges you want to win!<br /> DO NOT GIVE THIS WEBPAGE OUT. IF YOU DO AND YOU ARE CAUGHT, YOU WILL BE FACED WITH A 100,000 GARDEN BUX FINE AND A 2 DAY BAN FROM BADGE GARDEN.<meta HTTP-EQUIV=\"REFRESH\" content=\"10; url=http://www.badgegarden.mbhosting.com/GardenMixers/Set1.html\">";
    }
}

?>


Save it as Sources/shop/items/GardenMixers.php (or whatever you want, you'll need to change the item_GardenMixers bit to reflect the file name). Then, add it via the SMF Admin Panel.

Offline OrangeStar

Re: Need help with making an Item
« Reply #7 on: December 20, 2006, 05:49:53 pm »
okay thanks, i have 1 little problem, when i am in the admin panel in Add/Edit/Delete Items, I dont see the Garden Mixers item only the ones that came with it

Offline Daniel15

Re: Need help with making an Item
« Reply #8 on: December 20, 2006, 05:55:42 pm »
Did you save it to Sources/shop/items/GardenMixers.php? If so, it should appear in the dropdown box at the top.

Offline OrangeStar

Re: Need help with making an Item
« Reply #9 on: December 20, 2006, 05:59:08 pm »
Did you save it to Sources/shop/items/GardenMixers.php? If so, it should appear in the dropdown box at the top.

yes, this is all I see

Offline OrangeStar

[SOLVED] Need help with making an Item
« Reply #10 on: December 20, 2006, 06:04:50 pm »
god im dumb, i was upload it to shop/items/ not Sources/shop/items/ i see it now thanks!