Author Topic: Coding a item  (Read 2608 times)

Offline speak121

Coding a item
« on: July 01, 2007, 08:02:02 pm »
Hi!, first sorry for my english... is poor.

I'm doing a item to SMFShop, i used the AddInput function to request a value to administrator.

The problem is when admin goes to edit the item in his SMFShop, the value put in the AddInput disappear.

How can I do to do this value permanent in the item?

Offline Daniel15

Re: Coding a item
« Reply #1 on: July 03, 2007, 01:54:10 pm »
The fields in getAddInput need to be called info1, info2, info3, and info4 (there's a maximum of 4). Also, the function should be coded like this:
Code: [Select]
function getAddInput()
{
global $item_info;
if ($item_info[1] == 0)
$item_info[1] = 100;

return 'Amount to decrease by: <input type="text" name="info1" value="' . $item_info[1] . '" />';
}
If the user is editing the item, the current values are stored in the $item_info array. If they're adding a new item, the values in this array will be blank, and you'll probably need to set a default (as shown in the code snipplet above).

To actually use the values when the item is used, you use the $item_info array in the onUse() function.

Hope this helps you :)

Offline inkstains

Re: Coding a item
« Reply #2 on: July 14, 2007, 06:55:53 pm »
maybe i'm confused but i think he means editing the item through the admin panel and being able to edit the values you initially put in when you set up the item.

basically just add this code near the top of your item

$this->addInput_editable = true;

just near

$this->require_input = true;
$this->can_use_item = true;