Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.1.x Mods

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2011, 02:38 PM
The Codfin Keeper's Avatar
The Codfin Keeper The Codfin Keeper is offline
A Codfin draws near!
 
Join Date: Jan 2011
Location: Either CT or the Slug's house
Posts: 91
Gender: Male
Credits: 13,546
The Codfin Keeper is on a distinguished road
Default Simple Inventory Script

NOTE: This is just a simple inventory addon/mod, not anything too fancy.

First, log in to phpMyAdmin or wherever you can manage your database and add a new table with the following:


id, int(11), not null, auto_increment
owner, varchar(40), latin1_general_ci, yes (NULL)
itemtype, varchar(40), latin1_general_ci, yes (NULL)
imgurl, varchar(120), latin1_general_ci, yes (NULL)

This allows for ID search if such a mod is made, the owner, what kind of item it is, and its image's URL.

Now create a new page with this script.

PHP Code:
<?php

// **********************************************************************
// Mysidia Adoptables Script: blank.php, the standard dev file
// Copyright 2011 Mysidia Adoptables staff team
// For help and support: http://www.mysidiaadoptables.com/forum/
//
// Redistribution prohibited without written permission
// **********************************************************************


// Wake the sleeping giant

// **********************************************************************
// Basic Configuration Info
// **********************************************************************

include("inc/functions.php");
include(
"inc/config.php");

$themeurl grabanysetting("themeurl");

// **********************************************************************
// Define our top links by calling getlinks()
// **********************************************************************

$links getlinks();

// **********************************************************************
// Define our ads by calling getads()
// **********************************************************************

$ads getads("any");

// **********************************************************************
// Grab any dynamic article content from the content table
// **********************************************************************

$pagecontent getsitecontent("index");
$article_title $pagecontent[title];
$article_content $pagecontent[content];
$article_content nl2br($article_content);

// **********************************************************************
// Grab any settings that we will need for the current page from the DB
// **********************************************************************

$browsertitle grabanysetting("browsertitle");
$sitename grabanysetting("sitename");
$slogan grabanysetting("slogan");

// **********************************************************************
// Check and see if the user is logged in to the site
// **********************************************************************

$loginstatus logincheck();
$isloggedin $loginstatus[loginstatus];
$loggedinname $loginstatus[username];

// **********************************************************************
// End Prepwork - Output the page to the user
// **********************************************************************

$article_title "Your Inventory";

if (
$isloggedin == "yes") {
$article_content "Here you can see a list of items that you have collected.<table width='500' border='2'>
<tr>
    <td width='200'><strong>Picture:</strong></td>
    <td width='230'><strong>Item Type: </strong></td>
    <td width='70'><strong>ID Number:</strong></td>
</tr>"
;
 
$query "SELECT * FROM ".$prefix."useritems WHERE Owner = '$loggedinname'";
$result mysql_query($query);
$num mysql_numrows($result);

$i=0;
while (
$i $num) {

$iid=@mysql_result($result,$i,"ID");
$object=@mysql_result($result,$i,"Item");
$url=@mysql_result($result,$i,"imageurl");


$article_content $article_content."<tr>
    <td><center><img src='"
.$url."'></center></td>
    <td><center>"
.$object."</center></td>
    <td><center>"
.$iid."</center></td>
  </tr>"
;

unset(
$iid);
unset(
$object);

$i $i 1;
}
$article_content $article_content."</table>";

}
else {

$article_content "You must be logged in to view items.";

}
// **********************************************************************
// Begin Template Definition
// **********************************************************************

//Define our current theme
$file $themeurl;

// Do the template changes and echo the ready template
$template file_get_contents($file);

$template replace(':ARTICLETITLE:',$article_title,$template);
$template replace(':ARTICLECONTENT:',$article_content,$template);
$template replace(':ARTICLEDATE:',$article_date,$template);

$template replace(':BROWSERTITLE:',$browsertitle,$template);
$template replace(':SITENAME:',$sitename,$template);

//Define our links
$template replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...

$sidebar getsidebar();
$template replace(':SIDEFEED:',$sidebar,$template);

//Get the ad content...
$template replace(':ADS:',$ads,$template);

//Get the slogan info
$template replace(':SLOGAN:',$slogan,$template);


echo 
$template;

// **********************************************************************
// End Template Definition
// **********************************************************************



?>
That is the page for users to view their inventory. You may edit the text on the page and code if you add more parameters to items, and this page's script can be used in other areas, such as the little inventory box on TCKAS' front page.

Now, in order for users to hold items, they need them to begin with, correct? To make a page (or part of a page) hand out an item to the current user, add this script where needed:

PHP Code:
is ($isloggedin == "yes"){
$itemurl "URL_OF_IMAGE_GOES_HERE";
mysql_query("INSERT INTO ".$prefix."useritems VALUES ('','$loggedinname','NAME_OF_ITEM_GOES_HERE','$itemurl')");
}
else{
$article_content $article_content."You must be logged in to receive this item.";

And it adds the item into the table of users' items with the logged in user (doesn't add the item if the recipient is a guest), the item's name, and the image URL, which displays on the inventory page or wherever the inventory shows.

If I missed anything, please tell me, as well as if you find any glitches. This is my first major modification, so it can be improved. So give me feedback

EDIT: btw, if you need a replacement image or temporary image for an item, you may use what I made;


Code:
http://img37.imageshack.us/img37/1815/74598913.png
__________________

Yacker
Quote:
Originally Posted by Mankey Pokemon Card when another one is on top of it
([33) Ka\______
Does 40 damage\___
counter on Mankey. \______

Last edited by The Codfin Keeper; 02-23-2011 at 02:56 PM.
Reply With Quote
  #2  
Old 02-23-2011, 03:40 PM
Lunaria Lunaria is offline
Member
 
Join Date: Feb 2011
Posts: 20
Gender: Male
Credits: 1,238
Lunaria is on a distinguished road
Default

this was very helpful, thanks! :3
Reply With Quote
  #3  
Old 02-23-2011, 04:50 PM
The Codfin Keeper's Avatar
The Codfin Keeper The Codfin Keeper is offline
A Codfin draws near!
 
Join Date: Jan 2011
Location: Either CT or the Slug's house
Posts: 91
Gender: Male
Credits: 13,546
The Codfin Keeper is on a distinguished road
Default

I'm glad it helped you.
__________________

Yacker
Quote:
Originally Posted by Mankey Pokemon Card when another one is on top of it
([33) Ka\______
Does 40 damage\___
counter on Mankey. \______
Reply With Quote
  #4  
Old 02-23-2011, 05:28 PM
Sasoragon's Avatar
Sasoragon Sasoragon is offline
Beginniner Coder :D
 
Join Date: Jan 2011
Location: In the Myadopts Support Forums
Posts: 29
Gender: Female
Credits: 7,136
Sasoragon is on a distinguished road
Default

YOU POSTED IT!

This is definitely going to be useful.

I LOL'd at the text version of the smiley. XDDDDD
/off-topic
__________________
These smilies... are epic sauce.
Favorite smiley:
= :OHSH*TALION:

Now working on:
Daycare Mod. 40% Complete.

Grand Opening: :D
Reply With Quote
  #5  
Old 02-23-2011, 05:54 PM
The Codfin Keeper's Avatar
The Codfin Keeper The Codfin Keeper is offline
A Codfin draws near!
 
Join Date: Jan 2011
Location: Either CT or the Slug's house
Posts: 91
Gender: Male
Credits: 13,546
The Codfin Keeper is on a distinguished road
Default

Yus, I finally posted it.

Now all we need is an awesome face smiley...
__________________

Yacker
Quote:
Originally Posted by Mankey Pokemon Card when another one is on top of it
([33) Ka\______
Does 40 damage\___
counter on Mankey. \______
Reply With Quote
  #6  
Old 03-21-2011, 03:20 PM
AlexC's Avatar
AlexC AlexC is offline
Moderator
 
Join Date: Dec 2009
Location: Canada
Posts: 753
Gender: Unknown/Other
Credits: 78,219
AlexC is an unknown quantity at this point
Default

I'm having a problem with this script, it's not showing up and telling me I have an error on line 113, which is the following;

$template = file_get_contents($file); It's saying it can't find the file?
Reply With Quote
  #7  
Old 03-22-2011, 04:08 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 492,110
Hall of Famer is on a distinguished road
Default

Well this script is incompatible with Mys v1.2.x, you will have to make slight modifications for it to work. Simply take out the site information at the beginning and template definition at the bottom of this script file and it should work just fine.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #8  
Old 03-22-2011, 09:52 AM
AlexC's Avatar
AlexC AlexC is offline
Moderator
 
Join Date: Dec 2009
Location: Canada
Posts: 753
Gender: Unknown/Other
Credits: 78,219
AlexC is an unknown quantity at this point
Default

I tried doing that and it looked okay, but then it kept saying I wasn't logged in every time I visited. Someone helped me edit the script a little, i'll try again.
Reply With Quote
  #9  
Old 03-22-2011, 04:07 PM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 37,862
fadillzzz is an unknown quantity at this point
Default

Quote:
Originally Posted by Gloometh View Post
I tried doing that and it looked okay, but then it kept saying I wasn't logged in every time I visited. Someone helped me edit the script a little, i'll try again.
Well, did you remember to include the functions.php file?
Reply With Quote
  #10  
Old 03-22-2011, 04:35 PM
AlexC's Avatar
AlexC AlexC is offline
Moderator
 
Join Date: Dec 2009
Location: Canada
Posts: 753
Gender: Unknown/Other
Credits: 78,219
AlexC is an unknown quantity at this point
Default

my inventory script looks like this right now;

Code:
<?php

include("inc/functions.php");
include("inc/config.php");

//***************//
//  START SCRIPT //
//***************//

$themeurl = grabanysetting("themeurl");
$links = getlinks();
$ads = getads("any");
$pagecontent = getsitecontent("index");
$article_title = $pagecontent[title];
$article_content = $pagecontent[content];
$article_content = nl2br($article_content);

$article_title = "Your Inventory";

if ($isloggedin == "yes") {
$article_content = "Here you can see a list of items that you have collected.<table width='500' border='2'>
<tr>
    <td width='200'><strong>Picture:</strong></td>
    <td width='230'><strong>Item Type: </strong></td>
    <td width='70'><strong>ID Number:</strong></td>
</tr>";
 
$query = "SELECT * FROM ".$prefix."useritems WHERE Owner = '$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);

$i=0;
while ($i < $num) {

$iid=@mysql_result($result,$i,"ID");
$object=@mysql_result($result,$i,"Item");
$url=@mysql_result($result,$i,"imageurl");


$article_content = $article_content."<tr>
    <td><center><img src='".$url."'></center></td>
    <td><center>".$object."</center></td>
    <td><center>".$iid."</center></td>
  </tr>";

unset($iid);
unset($object);

$i = $i + 1;
}
$article_content = $article_content."</table>";

}
else {

$article_content = "You must be logged in to view items.";

}
//***************//
//  OUTPUT PAGE  //
//***************//

echo showpage($article_title, $article_content, $date);

?>
the page is now showing up, but the layout is out of whack - it has large text, and it says "Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/gloometh/public_html/inventory.php on line 30" near the top of the page.

the page looks fine when i'm logged out though.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blank Inventory Page ilrak Questions and Supports 5 09-23-2014 10:03 PM
Simple adopts superdude44 Adoptables Buzz 2 06-03-2013 06:09 PM
limited inventory idea schepers12 Suggestions and Feature Requests 3 05-19-2013 06:28 PM
Simple Feature Abronsyth Suggestions and Feature Requests 3 03-31-2013 09:48 AM
Simple adopts superdude44 Adoptables Sites Showcase 7 05-01-2012 10:49 PM


All times are GMT -5. The time now is 04:49 PM.

Currently Active Users: 680 (0 members and 680 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636