Mysidia Adoptables Support Forum  

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

Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 12-28-2017, 11:03 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
Join Date: Aug 2011
Location: NY
Posts: 996
Gender: Male
Credits: 40,411
Abronsyth is on a distinguished road
Default Item Pages

I wanted to make my inventory pages nice and clean, plus make greater use of the item system (as my site requires users to assign items to pets). So I came up with this and, after a lot of screeching in frustration, I have it working. It still needs some work in spifying it up and streamlining the process, but I have seen folks bring it up before so figured I'd share it as-is.

First! I cannot recall if it is dependent on Kyttias's mod, but it may very well be so note you'll want to install this mod first:

Okay, so let's get started. The good news is you do not have to touch your database at all (whew!).

Assuming you have Kyttias' mod installed, the first part we're going to edit is how we display items in the inventory. Open up inventoryview.php and scroll to where you see the notation; # Rendering items now
Now I replaced everything between that note, and the closing bracket ( } ) for this line; for($i = 0; $i < $iids->length(); $i++){.
PHP Code:
$document->add(new Comment("<div class=\"s_panel sc_item\">
            <img rel=\"tooltip\" title=\"
{$usage}\" src=\"{$item->imageurl}\"/><br>
{$item->itemname}</b><br> Own &times;{$item->quantity}<br>"FALSE));
$useForm = new FormBuilder("useform""inventory/uses""post");
$document->add(new Comment("</div>"FALSE)); 
What this does is makes it so we see the item's image, name, how many you own, and a "Manage" button. The manage button is clickable but totally useless right now.

Now we're going to replace EVERYTHING between the END of the INDEX function and the START of the TOSS function with this messy chunk of code;
PHP Code:
    public function uses(){
$mysidia Registry::get("mysidia");
$document $this->document;
$itemname $mysidia->input->post("itemname");    
$image $mysidia->db->select("items", array("imageurl"), "itemname='{$mysidia->input->post("itemname")}'")->fetchColumn();
$consumable $mysidia->db->select("items", array("consumable"), "consumable='yes'")->fetchColumn();
$quantity $mysidia->db->select("inventory", array("quantity"), "itemname='{$itemname}'" AND "owner='{$mysidia->user->username}'")->fetchColumn();
$message = (string)$this->getField("message");
$petMap $this->getField("petMap");
$document->setTitle("Manage Item");
$document->add(new Comment("<center><b>{$itemname}</b><br>
<img src='
$consumable) {
$document->add(new Comment("<h2>Use</h2>"));
$chooseFrom = new Form("chooseform""uses""post");
$adoptable = new DropdownList("aid");
$adoptable->add(new Option("None Selected""none"));
$petMap->size() > 0){
$iterator $petMap->iterator();
$adopt $iterator->nextEntry();
$adoptable->add(new Option($adopt->getValue(), $adopt->getKey()));
$chooseFrom->add(new PasswordField("hidden""itemname"$mysidia->input->post("itemname")));
$chooseFrom->add(new PasswordField("hidden""validation""valid"));
$chooseFrom->add(new Button("Choose this pet""submit""submit"));
$document->add(new Comment("<button style='cursor:not-allowed;' type='button'>Unusable</button><br><br>"FALSE));
$price $mysidia->db->select("items", array("price"), "itemname='{$mysidia->input->post("itemname")}'")->fetchColumn();
$sellback $price 2;
$item->function == "Key") {
$document->add(new Comment("
            <button style='cursor:not-allowed;' type='button'>Unsellable</button> "
            else {
$sellForm = new FormBuilder("sellform""sell""post");
$quantity = new TextField("quantity");

$sell = new Button("Sell""sell""sell");

$document->add(new Comment("<h2>Sell for {$sellback} {$mysidia->settings->cost} Each</h2>"));
    public function 
$mysidia Registry::get("mysidia");
$document $this->document;
$document->addLangvar("{$this->lang->sell}{$mysidia->input->post("quantity")} {$mysidia->input->post("itemname")} {$this->lang->sell2}");
What this does is create a page to manage that item. It shows the item's name, image, and quantity owned. It also shows two forms, a Use form, and a Sell form. The use form only works if the item is consumable, otherwise it states "unusable," and the sell form does NOT work for "Key" items. To use it, it shows a drop-down of the user's pets. To sell it the page shows the price it's worth, and lets the user put the quantity to sell in the box. (Don't worry, they cannot sell more than they own).

That's all there is to it! I know the code itself is messy and the manage page could use some beautifying, but I'll leave that to you.

If you have questions/comments/etc just post and I'll get to it when I am able

Happy new year, y'all!
Reply With Quote

Thread Tools
Display Modes

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

All times are GMT -5. The time now is 07:03 PM.

Currently Active Users: 276 (0 members and 276 guests)
Threads: 3,943, Posts: 31,409, Members: 15,530
Welcome to our newest members, ancrsbys01.

What's New?

What's Hot?

What's Popular?

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