Author Topic: Pack of Items  (Read 5316 times)

Offline Raider-8

Pack of Items
« on: June 07, 2012, 06:37:31 am »
In the admin, you can select the item what will be get on use, with the amount of the item.

Code: [Select]
<?php

    
/**********************************************************************************
    * SMFShop item - Por LG (Raider-8)                                                *
* Pack de Items   *
    **********************************************************************************/
    
if (!defined('SMF'))
die('Hack DETECTED');


    class 
item_pack_items extends itemTemplate
    
{
function getItemDetails()
{
$this->authorName 'Raider-8';
$this->authorWeb '';
$this->authorEmail 'raider-8@live.com';
$this->name 'Package of [ITEMS]';
$this->desc 'ĄGet X amount of ITEMS!';
$this->price 0;
$this->require_input false;
$this->can_use_item true;
$this->addInput_editable true;
}
function 
getAddInput() 
{
global $item_info$smcFunc$db_prefix;
if(empty($item_info[2])) {
$val 5;
} else {
$val $item_info[2];
}
if(!empty($item_info[1])) {
$elector '<b>[ITEM CAN NOT BE EDITED AFTER CREATED]</b>';
} else {
$elector '
<select name="info1">'
;
$results $smcFunc['db_query'](''"
SELECT *
FROM {db_prefix}shop_items"
);
while ($row $smcFunc['db_fetch_assoc']($results))
$elector .= '
<option value="' 
$row['id'] . '">' $row['name'] . '</option>';

$elector .= '
</select>'
;
}
return 'Item what will contains the package (DO NOT EDITABLE AFTER CREATED): '.$elector.'
<br />
Amount: <input type="text" name="info2" value="'
.$val.'"/>
<br />
<hr><center><b>Raider-8 ITEM</b></center>'
;
}
function 
onUse()
    {
    global 
$context$db_prefix$ID_MEMBER$item_info$smcFunc;
$cantidad=$item_info[2];
for ($i 0$i $cantidad$i += 1) { 
$sql $smcFunc['db_query'](''"INSERT INTO {db_prefix}shop_inventory (ownerid,itemid) VALUES ('".$context['user']['id']."','".$item_info[1]."')");
    }
return 'Now, you got the '.$cantidad.' items.';
}
}
?>



Excuse me fot the english and the traduction, but i'm spanish.

Offline minfas

Re: Pack of Items
« Reply #1 on: November 18, 2012, 09:48:08 pm »
dont working. Error: ERROR: Could not create instance of 'kortos' item!

Offline Mr E S Stranger

Re: Pack of Items
« Reply #2 on: December 05, 2012, 10:45:28 pm »
dont working. Error: ERROR: Could not create instance of 'kortos' item!

I fixed the same issue by changing "class item_pack_items" to "class item_packitems", then save the file as packitems.php.

Hope this helps.

Offline Raider-8

Re: Pack of Items
« Reply #3 on: December 08, 2012, 10:27:49 pm »
dont working. Error: ERROR: Could not create instance of 'kortos' item!

The item should be saved like "pack_items.php"

Offline Coolgem

Re: Pack of Items
« Reply #4 on: April 13, 2013, 11:42:15 am »
It works perfectly on my installation! Wonderful job! Bravo! Bravo! :angel:
« Last Edit: April 13, 2013, 11:45:03 am by Coolgem »