Hi everyone!
This is my first item
It's called Level Up.
What is does is increasing your pets level by xxx.
Also it makes your pet xxx happier.
You can set the amount of levels to rise, number to increase happines by and phrase to output upon use.
To use, copy the code below and save it as Level.php and then upload it to Sources/shop/items/, or download the attached file and rename it to Level.php.
Then upload it to Sources/shop/items/.
<?php
/**********************************************************************************
* SMFShop item *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum *
* =============================================================================== *
* Software Version: SMFShop 3.0 (Build 12) *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007) $ *
* $Id:: Steal.php 79 2007-01-18 08:26:55Z daniel15 $ *
* Software by: DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by: DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at: http://www.dansoftaustralia.net/ *
* *
* Forum software by: Simple Machines (http://www.simplemachines.org) *
* Copyright 2006-2007 by: Simple Machines LLC (http://www.simplemachines.org) *
* 2001-2006 by: Lewis Media (http://www.lewismedia.com) *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under *
* the terms of the provided license as published by Simple Machines LLC. *
* *
* This program is distributed in the hope that it is and will be useful, but *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* See the "license.txt" file for details of the Simple Machines license. *
* The latest version of the license can always be found at *
* http://www.simplemachines.org. *
**********************************************************************************/
if (!defined('SMF'))
die('Hacking attempt...');
class item_Level extends itemTemplate
{
function getItemDetails()
{
$this->authorName = 'Nascar';
$this->authorWeb = 'www.nascar.vlexo.net';
$this->authorEmail = 'admin@nascar.vlexo.net';
$this->name = 'Level Up';
$this->desc = 'This item makes your pet xxx levels better!';
$this->price = 1000;
$this->require_input = true;
$this->can_use_item = true;
}
function getAddInput()
{
global $item_info, $db_prefix;
return 'Amount of levels to rise: <input type="text" name="info1" value="' . $item_info[1] . '" /><br />
Amount to increase happiness by: <input type="text" name="info2" value="' . $item_info[2] . '" /><br />
Phrase to output upon use: (use xNAMEx for pet name, xLEVELx for level and xHAPPYx for happiness level) <input type="text" name="info3" value="' . $item_info[3] . '" /> ';
}
function getUseInput()
{
global $db_prefix, $ID_MEMBER;
$result = db_query("SELECT numpets FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row['numpets'] == 0) {
return "You have no pets. If you use this item it will simply die and you loose money.";
}
$string = "<select name = 'petid'>";
$result = db_query("SELECT * FROM {$db_prefix}shop_pets WHERE ownerid = {$ID_MEMBER}", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result)) {
$string .= "<option value = '{$row['pet_id']}'>{$row['name']}</option>";
}
$string .= "</select>";
return "Select which animal that will be Leveled Up: ".$string;
}
function onUse()
{
global $db_prefix, $ID_MEMBER, $item_info;
if (!isset($_POST['petid'])) {
return "I told you it would die!";
}
else {
$result = db_query("UPDATE {$db_prefix}shop_pets SET level = level + {$item_info[1]}, happy = happy + {$item_info[2]} WHERE pet_id = {$_POST['petid']} AND ownerid = {$ID_MEMBER}", __FILE__, __LINE__);
$result = db_query("SELECT name, level, happy from {$db_prefix}shop_pets WHERE pet_id = {$_POST['petid']} AND ownerid = {$ID_MEMBER}", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
$banana = array();
$explode = explode(' ' , $item_info[3]);
foreach ($explode as $word) {
if ($word == 'xNAMEx') {
$banana[] = $row['name'];
}
elseif ($word == 'xLEVELx') {
$banana[] = $row['level'];
}
elseif ($word == 'xHAPPYx') {
$banana[] = $row['happy'];
}
else {
$banana[] = $word;
}
}
$return = implode(' ', $banana);
return $return;
}
}
}
?>
Hope you like this!