Author Topic: How do I Increase Max Pets Permitted.  (Read 6061 times)

Offline JusPlay77

How do I Increase Max Pets Permitted.
« on: February 29, 2008, 01:22:51 am »
SMF 1.1.4
SMF Shop 3.0 (Build 12)

Cage.php
Code: [Select]
<?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)...

Quote
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.
« Last Edit: March 01, 2008, 08:16:05 am by JusPlay77 »

Offline Faust

Re: How do I Increase Max Pets Permitted.
« Reply #1 on: February 29, 2008, 02:18:15 am »
Have you tried to change this

Quote
if ($row['maxpets'] >= $item_info[1])

to

if ($row['maxpets'] > $item_info[1])

Offline JusPlay77

Re: How do I Increase Max Pets Permitted.
« Reply #2 on: February 29, 2008, 02:32:54 am »
Just tried that now.. didn't work :( - Thank you though for the attempt.  Hopefully this error can be figured out soon! 

Offline Faust

Re: How do I Increase Max Pets Permitted.
« Reply #3 on: February 29, 2008, 02:42:17 am »
Can you post the error ?

Offline JusPlay77

Re: How do I Increase Max Pets Permitted.
« Reply #4 on: February 29, 2008, 02:45:09 am »
It's not a script error.. It's just not saying what it's supposed too..

Quote
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

Offline Faust

Re: How do I Increase Max Pets Permitted.
« Reply #5 on: February 29, 2008, 02:49:55 am »
Try this:
Wherever  it says
Quote
$item_info[1]
change to : $item_info[5]

Offline JusPlay77

Re: How do I Increase Max Pets Permitted.
« Reply #6 on: February 29, 2008, 03:11:19 am »
That was the first thing that I tried I'm afraid.. I found another code on the forums here:

Code: [Select]
<?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
« Last Edit: February 29, 2008, 08:05:10 am by JusPlay77 »

Offline Faust

Re: How do I Increase Max Pets Permitted.
« Reply #7 on: February 29, 2008, 05:13:26 am »
change from
return "You have too many pets already...."
to
Code: [Select]
return "You have too many pets already....";

Offline JusPlay77

Re: How do I Increase Max Pets Permitted.
« Reply #8 on: February 29, 2008, 08:04:51 am »
Quote
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.

Offline Faust

Re: How do I Increase Max Pets Permitted.
« Reply #9 on: February 29, 2008, 12:54:40 pm »
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

Offline JusPlay77

Re: How do I Increase Max Pets Permitted.
« Reply #10 on: March 01, 2008, 08:15:13 am »
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)...:

Quote
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 ]
« Last Edit: March 01, 2008, 08:18:07 am by JusPlay77 »