SMF Shop
SMFShop => Bugs => Topic started by: JusPlay77 on February 29, 2008, 01:22:51 am
-
SMF 1.1.4
SMF Shop 3.0 (Build 12)
Cage.php
<?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_Cage extends itemTemplate
{
function getItemDetails()
{
$this->authorName = 'Basilbeard';
$this->authorWeb = 'www.nomicville.com';
$this->authorEmail = 'basilbeard@nomicville.com';
$this->name = 'Pet Cage';
$this->desc = 'Increase your max pets by one!';
$this->price = 500;
$this->require_input = true;
$this->can_use_item = true;
}
function getAddInput()
{
global $item_info, $db_prefix;
return 'Max number of max pets: <input type="text" name="info1" value="' . $item_info[1] . '" /><br />';
}
function getUseInput()
{
global $db_prefix, $ID_MEMBER, $item_info;
$result = db_query("SELECT maxpets FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row['maxpets'] >= $item_info[1]) {
return "You already have too many pets to use this item. Using it will just result in item loss.";
}
else {
return "Are you sure you want to use this item?";
}
}
function onUse()
{
global $db_prefix, $ID_MEMBER, $item_info;
$result = db_query("SELECT maxpets FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row['maxpets'] >= $item_info[1]) {
return "Told you so!";
}
else {
$maxpets = $row['maxpets'] + 1;
$result = db_query("UPDATE {$db_prefix}members SET maxpets = maxpets + 1 WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "You can now own up to {$maxpets} pets";
}
}
}
?>
Yes, I searched and found 4 topics on the subject of cage. I tried to change some variables around in the code several times now, and I am just completely baffled by how I am supposed to allow my members to have a maximum of 5 pets.
--
This is what happens when I try to use the item (I have 1 pet btw)...
This item requires further input. Please complete the fields below, and then press "Use Item"
You already have too many pets to use this item. Using it will just result in item loss.
And of course using the item results in it disappearing from inventory and not changing anything.
-
Have you tried to change this
if ($row['maxpets'] >= $item_info[1])
to
if ($row['maxpets'] > $item_info[1])
-
Just tried that now.. didn't work :( - Thank you though for the attempt. Hopefully this error can be figured out soon!
-
Can you post the error ?
-
It's not a script error.. It's just not saying what it's supposed too..
This item requires further input. Please complete the fields below, and then press "Use Item"
You already have too many pets to use this item. Using it will just result in item loss.
Is what comes up. It should say:
You can now own up to X pets
-
Try this:
Wherever it says $item_info[1]
change to : $item_info[5]
-
That was the first thing that I tried I'm afraid.. I found another code on the forums here:
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
| (c) 2006 DanSoft Australia |
| http://www.dansoftaustralia.net/ |
\**********************************************/
class item_PetCage extends itemTemplate {
function getItemDetails() {
$this->authorName = "The Great Orator";
$this->authorWeb = "http://www.dragontalk.net/";
$this->authorEmail = "admin@dragontalk.net";
$this->name = "Increase Pet Ownership";
$this->desc = "Increase Number of pets owned by xxx";
$this->price = 500;
$this->require_input = false;
$this->can_use_item = true;
}
// See 'AddToPostCount.php' for info on how this works
function getAddInput() {
return "Number of additional pets to allow: <input type='text' name='info1' value='5' />";
}
function getUseInput() {
return "";
}
function onUse() {
global $db_prefix, $ID_MEMBER, $item_info;
$MaxPets = db_query("SELECT maxpets
FROM {$db_prefix}members
WHERE ownerid = {$ID_MEMBER}",__FILE__, __LINE__);
$MaxPetsReached = mysql_fetch_assoc($result);
if ($MaxPetsReached != 10){
$result = db_query("UPDATE {$db_prefix}members
SET maxpets = maxpets + {$item_info[1]}
WHERE ownerid = {$ID_MEMBER}",__FILE__, __LINE__);
return "You can now own {$item_info[1]} additional pets!";
}
else{
return "You have too many pets already...."
}
}
}
?>
But it had something wrong with line 44
-
change from
return "You have too many pets already...."
to
return "You have too many pets already....";
-
Fatal error: Cannot instantiate non-existent class: item_cage in /home/content/./././................html/smf/Sources/shop/Shop-Inventory.php(154) : eval()'d code on line 1
Got that now after the change.
-
Ok that is easy to fix:
change this
class item_PetCage extends itemTemplate {
to
class item_cage extends itemTemplate {
and remember to change the filename to
cage.php
-
Thanks much! That does make perfect sense (can't believe I didn't see it)
...
Dunno if it works though or not, I have another error now (which came out of nowhere)...:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's the best! Built for Battle!',
hunger = 8,
age = 1,
' at line 7
File: /home/content/x/x/x/xxxxxxx/html/smf/Sources/shop/pet_engine.php
Line: 305
Issue Found Here: [ SERIOUS ISSUE WITH pet_engine.php ] (http://www.daniel15.com/forum/index.php/topic,1533.msg7846.html#new)