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

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-28-2017, 11:03 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 133,206
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: http://mysidiaadoptables.com/forum/s...ead.php?t=4741

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>
              <b>
{$item->itemname}</b><br> Own &times;{$item->quantity}<br>"FALSE));
           
                
$useForm = new FormBuilder("useform""inventory/uses""post");
                
$useForm->setLineBreak(FALSE);
                
$useForm->buildPasswordField("hidden""action""use")
                        ->
buildPasswordField("hidden""itemname"$item->itemname)
                        ->
buildButton("Manage""use""use");
                
$document->add($useForm);
                
                
$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();
        
        if(
$mysidia->input->post("aid")){
            
$message = (string)$this->getField("message");
            
$document->setTitle($mysidia->lang->global_action_complete);
            
$document->addLangvar($message);
            return;        
        }
        
        
$petMap $this->getField("petMap");
        
$document->setTitle("Manage Item");
        
$document->add(new Comment("<center><b>{$itemname}</b><br>
<img src='
{$image}'/><br>
<b>Owned:</b> 
{$quantity}</center>"));
if(
$consumable) {
    
$document->add(new Comment("<h2>Use</h2>"));
        
$document->addLangvar($mysidia->lang->select);        
        
$chooseFrom = new Form("chooseform""uses""post");
        
        
$adoptable = new DropdownList("aid");
        
$adoptable->add(new Option("None Selected""none"));
        if(
$petMap->size() > 0){
            
$iterator $petMap->iterator();
            while(
$iterator->hasNext()){
                
$adopt $iterator->nextEntry();
                
$adoptable->add(new Option($adopt->getValue(), $adopt->getKey()));
            }
        }        
        
$chooseFrom->add($adoptable);
        
        
$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($chooseFrom);}
else{
             
$document->add(new Comment("<button style='cursor:not-allowed;' type='button'>Unusable</button><br><br>"FALSE));
            }
        
        
//SELL FORM//
        
$price $mysidia->db->select("items", array("price"), "itemname='{$mysidia->input->post("itemname")}'")->fetchColumn();
        
$sellback $price 2;
            if(
$item->function == "Key") {
            
$document->add(new Comment("
            <button style='cursor:not-allowed;' type='button'>Unsellable</button> "
FALSE));
            }    
            else {
                
$sellForm = new FormBuilder("sellform""sell""post");
                
$sellForm->setLineBreak(FALSE);
                
$sellForm->buildPasswordField("hidden""action""sell")
                         ->
buildPasswordField("hidden""itemname"$mysidia->input->post("itemname"));
                
$quantity = new TextField("quantity");
                
$quantity->setSize(3);
                
$quantity->setMaxLength(3);
                
$quantity->setLineBreak(FALSE);

                
$sell = new Button("Sell""sell""sell");
                
$sell->setLineBreak(FALSE);

                
$sellForm->add($quantity);
                
$sellForm->add($sell);
        
$document->add(new Comment("<h2>Sell for {$sellback} {$mysidia->settings->cost} Each</h2>"));
                            
$document->add($sellForm);
    }}
    
    public function 
sell(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        
$document->setTitle($this->lang->global_transaction_complete);
        
$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!
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
 


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 12:53 PM.

Currently Active Users: 842 (0 members and 842 guests)
Threads: 4,081, Posts: 32,031, 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