SMFShop > Items
Pack of Items
(1/1)
Raider-8:
In the admin, you can select the item what will be get on use, with the amount of the item.
--- Code: ---<?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.'; }}?>
--- End code ---
Excuse me fot the english and the traduction, but i'm spanish.
minfas:
dont working. Error: ERROR: Could not create instance of 'kortos' item!
Mr E S Stranger:
--- Quote from: minfas on November 18, 2012, 07:48:08 pm ---dont working. Error: ERROR: Could not create instance of 'kortos' item!
--- End quote ---
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.
Raider-8:
--- Quote from: minfas on November 18, 2012, 07:48:08 pm ---dont working. Error: ERROR: Could not create instance of 'kortos' item!
--- End quote ---
The item should be saved like "pack_items.php"
Coolgem:
It works perfectly on my installation! Wonderful job! Bravo! Bravo! :angel:
Navigation
[0] Message Index
Go to full version