Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Tutorials and Tips

Notices

Reply
 
Thread Tools Display Modes
  #11  
Old 10-17-2016, 07:49 AM
lotus's Avatar
lotus lotus is offline
Member
 
Join Date: Oct 2016
Posts: 7
Gender: Female
Credits: 1,043
lotus is on a distinguished road
Default

Actually, this can be used for backgrounds and foregrounds/decors for pets using a background and foreground layer using div.

Last edited by lotus; 10-17-2016 at 08:45 PM.
Reply With Quote
  #12  
Old 10-17-2016, 07:03 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 79,249
Dinocanid is on a distinguished road
Default

Can someone explain to me a bit more of how I use this? I followed the tutorial, but I'm confused about what you put in the item image field in the adminCP when making the item, and once I get the item in my inventory I can't use it, it just says N/A. Also, where would I put the "img src" codes? In class_ownedadoptable?
Reply With Quote
  #13  
Old 12-14-2016, 01:42 PM
Ittermat's Avatar
Ittermat Ittermat is offline
The awesomesauce
 
Join Date: Feb 2016
Location: in front of my laptop
Posts: 272
Gender: Female
Credits: 38,599
Ittermat is on a distinguished road
Default

Hi there Im trying to get them to appear below something but it keeps giving me an error-

This is my petview.php
but Im trying to get it to appear below the pet- and right above the play, manage, freeze, etc links.

PHP Code:
 <?php 
class PetView extends View

    public function 
profile(){ 
        
$mysidia Registry::get('mysidia'); 
        
$d $this->document
        
$adopt $this->getField('adopt'); 
        
$isdead $adopt->isdead
        
$name $adopt->getName(); 
        
$title 'Viewing '
        if (
$isdead) { 
            
$title '<img src="/picuploads/dead.png"> Here Lies '
            
$name .= ' <img src="/picuploads/dead.png">'
        } 
        else{ 
            if (
$adopt->getOwner() == 'SYSTEM') { 
                
$title '<img src="/picuploads/shackle.png"> ' $title
                
$name .= '<img src="/picuploads/shackle.png">'
            } 
        } 
        if (
$adopt->getOwner() == $mysidia->user->username$title 'Managing '
        
$d->setTitle(' '); 
        
$d->addLangVar('<table border=1px><tr><td valign="top">'); 
        
$d->addLangvar("<b>{$title}{$name}</b><hr>"); 
        if (
$isdead == false) { 
            if (
$adopt->getOwner() == 'SYSTEM') { 
                
$d->addLangVar("Owned by <a href='/profile/view/POUND'>The Pound</a><br><br>"); 
            }else{ 
                
$d->addLangVar("Owned by <a href='/profile/view/{$adopt->getOwner()}'>{$adopt->getOwner()}</a><br><br>"); 
            } 
        } 
        if (
$isdead) { 
            
$d->addLangvar("<div style='background:url({$mysidia->path->getAbsolute()}picuploads/paw.png); position:relative; height:248px; width:268px;'><div style='background:url({$mysidia->path->getAbsolute()}picuploads/wreath.png);height:248px; width:268px;position:absolute;z-index:30;'></div><div style='position:absolute;z-index:2;left:50px;bottom:10px'>".$adopt->getImage("gui") .'</div></div>'); 
        }else{ 
            if (
$adopt->class == 'Colorful'){ 
            
$d->addLangvar($adopt->getImage('gui')); 
            }else{ 
                
$d->add($adopt->getImage('gui')); 
                     
            } 
        } 
     
        if (
$isdead){ 
            
$d->addLangvar('</div>'); 
        } 
         
        if (
$adopt->isdead == false){ 
            if(
$adopt->isfrozen() == 'no'){ 
                
$d->addLangvar("<br><a href='/levelup/click/{$adopt->aid}'>Play</a>"); 
            }else{ 
                
$d->addLangvar('<br>Frozen'); 
            } 
        } 
         
        
$freeze 'Freeze'
        if (
$adopt->isFrozen() == 'yes'$freeze 'Unfreeze'
        if (
$mysidia->user->username == $adopt->getOwner()){ 
         
            
$d->addLangVar(" | <a href='/myadopts/manage/{$adopt->aid}'>Manage</a> | <a href='/myadopts/bbcode/{$adopt->aid}'>Codes</a> | <a href='/myadopts/freeze/{$adopt->aid}'>$freeze</a><br><a href='/pound/pound/{$adopt->aid}'>Pound $name</a><br> <a href='/pet/release/{$adopt->aid}'>Release $name</a>"); 
        } 
        
$d->addLangVar('</td><td valign="top">'); 

        
$d->add(new Comment('<div id="tabs" class="c-tabs no-js"><div class="c-tabs-nav">',false)); 

        if (
$adopt->class != 'Colorful') { 
            
$d->addLangVar("<a href='#' class='c-tabs-nav__link'>Bio</a><a href='#' class='c-tabs-nav__link'>About</a>"); 
            
$d->addLangVar("</div><div class='c-tab is-active'><div class='c-tab__content'>{$adopt->getBio()}</div></div><div class='c-tab'> 
                <div class='c-tab__content'>
{$adopt->getDescription()}</div></div>"); 
             
        }else{ 
            
$d->addLangVar("<a href='#' class='c-tabs-nav__link'>Bio</a><a href='#' class='c-tabs-nav__link'>Skills</a><a href='#' class='c-tabs-nav__link'>Lineage</a><a href='#' class='c-tabs-nav__link'>Offspring</a><a href='#' class='c-tabs-nav__link'>Stats</a>"); 
            
$d->addLangVar("</div><div class='c-tab is-active'> 
                <div class='c-tab__content'>"
); 
            if (
$mysidia->user->username == $adopt->getOwner()){ 
                
$d->addLangvar('<a href="/myadopts/updatebio/'.$adopt->aid.'">Click Here to Update Bio</a><br><br>'); 
            } 
            
$d->addLangvar("{$adopt->getBio()}</div></div> 
                <div class='c-tab'><div class='c-tab__content'><b>Trophies:</b> 
{$adopt->trophies}<br><br>
                    <b>Sense:</b> 
{$adopt->sense}<br> 
                    <b>Speed:</b> 
{$adopt->speed}<br> 
                    <b>Strength:</b> 
{$adopt->strength}<br> 
                    <b>Stamina:</b> 
{$adopt->stamina}<br></div></div>"); 

            
// Lineage 
            
include('pedigree.php'); 

            
$offspring = []; $parent 'sire_id'
            if (
$adopt->getGender() == 'f'$parent 'dam_id'
            
$offspring $mysidia->db->select('owned_adoptables', [], "$parent = {$adopt->aid}")->fetchAll(PDO::FETCH_CLASS,'OwnedAdoptable'); 

            
$d->addLangVar("<div class='c-tab'><div class='c-tab__content'><b>Offspring</b>"); 
            if (
count($offspring) == 0$d->addLangVar('<hr>None.'); 
            foreach (
$offspring as $baby) { 
                
$d->addLangVar("<hr><a href='/pet/profile/{$baby->aid}'>{$baby->name}<br><img src='{$baby->getImage()}'></a>"); 
            } 
             
            
$d->addLangVar('</div></div>'); 

            
$d->addLangVar("<div class='c-tab'><div class='c-tab__content'>"); 
            
$d->addLangvar("<b>Personality:</b> {$adopt->personality()}<br> 
                <b>Happiness:</b> 
{$adopt->happiness}/50<br> 
                <b>Hunger:</b> 
{$adopt->hunger}/50<br> 
                <b>Thirst:</b> 
{$adopt->thirst}/50<br> 
                <b>Closeness:</b> 
{$adopt->closeness}/50<br> 
                "
); 
                 
            
$d->add($adopt->getStats()); 
            if (
$adopt->breeder != null) { 
                
$d->addLangvar("<br><br><b>Breeder:</b> <a href='/profile/view/{$adopt->breeder}'>{$adopt->breeder}</a>"); 
                 
            } 
             

            
$d->addLangvar("</div></div>"); 
        } 
        
$d->addLangVar('</td></tr></table>'); 

        
$d->add(new Comment
            
"<script src='/js/otherTabs.js'></script> 
            <script> 
                var myTabs = tabs({ 
                    el: '#tabs', 
                    tabNavigationLinks: '.c-tabs-nav__link', 
                    tabContentContainers: '.c-tab' 
                }); 

                myTabs.init(); 
            </script>"
FALSE)); 
    } 

    public function 
release(){ 
        
$d $this->document
        
$adopt $this->getField('adopt'); 
        
$d->setTitle($this->lang->release); 
        
$d->addLangvar($adopt->getName().'<br>'.$adopt->getImage('gui').'<br><br>'); 
        
$d->addLangvar($this->lang->release_warning); 
        
$d->addLangvar('<br><br><form method="post" action="/myadopts/release/'.$adopt->aid.'"><label for="password">Type your password below to confirm:</label><br><input type="password" name="password"><br><input type="submit" value="Release Pet?"></form>'); 
    } 

    public function 
bio(){ 
     
        
$d $this->document
        
$adopt $this->getField('adopt'); 
         
        
$d->setTitle('Update Bio'); 
        
$d->addLangvar($adopt->getName().'<br>'.$adopt->getImage('gui').'<br><br>'); 
        
$d->addLangvar('<form method="post"><textarea name="bio">'.$adopt->bio.'</textarea><br><input type="submit" value="Update Bio" name="submit"></form>'); 
           
    } 
     

}
Thanks in advance ^^;

Edit: Another question- how exactly do you set the companions and items to a pet?

EDIT 2-:

After installing this I also seem to be having a problem with "key" items working..
It gives me this error: Fatal error: Call to undefined function items_key() in /home/atrocity/public_html/classes/class_privateitem.php on line 109

Heres my items functions.php

PHP Code:
<?php

// File ID: functions_items.php
// Purpose: Provides specific functions defined for items

function items_valuable($item$adopt){
  if (
check_stats() == true){
    
$note "{$item->itemname} has been used on {$adopt->name}.";
    
$item->remove(); 
    return 
$note;
  }
  return 
"The item {$item->itemname} is a valuable item, which cannot be used on any adoptable but may sell for a good deal of money.";
}
function 
items_chiku1($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$mysidia->db->update("owned_adoptables", array("type" => 'Chiku-Banzai'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "The item has been successfully used on your adoptable, it is now a {$adopt->type}!<br>";
  
//Update item quantity...
  
$delitem $item->remove(); 
  return 
$note;

function 
items_luv1($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$mysidia->db->update("owned_adoptables", array("type" => 'Luv-Bug'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "The item has been successfully used on your adoptable, it is now a {$adopt->type}!<br>";
  
//Update item quantity...
  
$delitem $item->remove(); 
  return 
$note;

function 
items_zoey1($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$mysidia->db->update("owned_adoptables", array("type" => 'Zoey'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "The item has been successfully used on your adoptable, it is now a {$adopt->type}!<br>";
  
//Update item quantity...
  
$delitem $item->remove(); 
  return 
$note;

function 
items_smoke1($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$mysidia->db->update("owned_adoptables", array("type" => 'Smoke'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "The item has been successfully used on your adoptable, it is now a {$adopt->type}!<br>";
  
//Update item quantity...
  
$delitem $item->remove(); 
  return 
$note;


function 
items_level1($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$newlevel $adopt->currentlevel $item->value;
  
$lev $mysidia->db->select("levels", array(), "adoptiename='{$adopt->type}' and thisislevel ='{$newlevel}'")->fetchObject();
  
    
//Check if the adoptable's level is already at maximum.    
  
if(!is_object($lev)){
    
// object not created, the level is already at maximum.
    
$note "Unfortunately, your selected adoptable's level cannot be raised by using item {$item->itemname}.";
  }
  else{
    
//Update item quantity...
    
$delitem $item->remove();
    
//Execute the script to update adoptable's level and clicks.
    
$mysidia->db->update("owned_adoptables", array("currentlevel" => $newlevel"totalclicks" => $lev->requiredclicks), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
    
$note "Congratulations, the item {$item->itemname} raised your adoptable's level by {$item->value}";
  }
  return 
$note;
}

function 
items_level2($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$newlevel $item->value;
  
$lev $mysidia->db->select("levels", array(), "adoptiename='{$adopt->type}' and thisislevel ='{$newlevel}'")->fetchObject();

    
//Check if the adoptable's level is already at maximum.    
  
if(!is_object($lev)){
    
// object not created, the level is already at maximum.
    
$note "Unfortunately, your selected adoptable's level cannot be raised by using item {$item->itemname}.";
  }
  else{
    
//Update item quantity...
    
$delitem $item->remove(); 
    
//Execute the script to update adoptable's level and clicks.
    
$mysidia->db->update("owned_adoptables", array("currentlevel" => $newlevel"totalclicks" => $lev->requiredclicks), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
    
$note "Congratulations, the item {$item->itemname} increases your adoptable's level to {$item->value}";
  }
  return 
$note;
}

function 
items_level3($item$adopt){
  
$mysidia Registry::get("mysidia");
  
//Update item quantity...
  
$delitem $item->remove();
    
//Execute the script to update adoptable's level and clicks.
  
$mysidia->db->update("owned_adoptables", array("currentlevel" => 0"totalclicks" => 0), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "Congratulations, the item {$item->itemname} has reset the level and clicks of your adoptable.";
  return 
$note;
}

function 
items_click1($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$newclicks $adopt->totalclicks $item->value;
  
$mysidia->db->update("owned_adoptables", array("totalclicks" => $newclicks), "aid='{$adopt->aid}'and owner='{$item->owner}'");
  
$note "By using {$item->itemname}, the adoptable's total number of clicks has raised by {$item->value}<br>";
  
//Now lets check if the adoptable has reached a new level.
  
  
$ownedAdopt = new OwnedAdoptable($adopt->aid);
  if(
$ownedAdopt->hasNextLevel()){
      
//new level exists, time to check if the total clicks have reached required minimum clicks for next level.
     
$nextLevel $ownedAdopt->getNextLevel();
     
$requiredClicks $nextLevel->getRequiredClicks();
     if(
$newclicks >= $requiredClicks and $requiredClicks != and $requiredClicks != ""){
        
// We need to level this adoptable up...
        
$mysidia->db->update("owned_adoptables", array("currentlevel" => $nextLevel->getLevel()), "aid ='{$adopt->aid}' and owner='{$item->owner}'");             
        
$note .= "And moreover, it has gained a new level!";
     }
  }
  
//Update item quantity...
  
$delitem $item->remove(); 
  return 
$note;
}

function 
items_click2($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$newclicks $item->value;
  
$mysidia->db->update("owned_adoptables", array("totalclicks" => $newclicks), "aid='{$adopt->aid}'and owner='{$item->owner}'");
  
$note "By using {$item->itemname}, the adoptable's total number of clicks has raised by {$item->value}<br>";
  
//Now lets check if the adoptable has reached a new level.
  
  
$ownedAdopt = new OwnedAdoptable($adopt->aid);
  if(
$ownedAdopt->hasNextLevel()){
      
//new level exists, time to check if the total clicks have reached required minimum clicks for next level.
     
$nextLevel $ownedAdopt->getNextLevel();
     
$requiredClicks $nextLevel->getRequiredClicks();
     if(
$newclicks >= $requiredClicks and $requiredClicks != and $requiredClicks != ""){
        
// We need to level this adoptable up...
        
$mysidia->db->update("owned_adoptables", array("currentlevel" => $nextlevel), "aid ='{$adopt->aid}' and owner='{$item->owner}'");      
        
$note .= "And moreover, it has gained a new level!";
     }
  }

  
//Update item quantity...
  
$delitem $item->remove(); 
  return 
$note;
}

function 
items_click3($item$adopt){ 
  
$mysidia Registry::get("mysidia");
  
$date date('Y-m-d'); 
  
$mysidia->db->delete("vote_voters""adoptableid = '{$adopt->aid}' and date='{$date}'");
  
//Update item quantity...
  
$delitem $item->remove(); 
  
$note "By using item {$item->name}, you have make your adoptables eligible for clicking by everyone again!";
  return 
$note;
}

function 
items_breed1($item$adopt){
  
$mysidia Registry::get("mysidia");
  
// Update the lastbred info.
  
$mysidia->db->update("owned_adoptables", array("lastbred" => 0), "aid ='{$adopt->aid}' and owner='{$item->owner}'");    
  
$note "The item has been successfully used on your adoptable, it can breed again!<br>";
  
//Update item quantity...
  
$delitem $item->remove(1$item->owner);  
  return 
$note;
}

function 
items_breed2($item$adopt){
  
$mysidia Registry::get("mysidia");
  
// Note this function exists but is not useful until Mys v1.3.2, when adoptables can carry/attach items.
  
$mysidia->db->update("owned_adoptables", array("lastbred" => 0), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "The item has been successfully used on your adoptable, it can breed again!<br>";
  
//Update item quantity...
  
$delitem $item->remove(); 
  return 
$note;
}
function 
items_alts1($item$adopt){
  
$mysidia Registry::get("mysidia");
  
// First lets check if alternative image exists for an adoptable at this level.
  
$lev $mysidia->db->select("levels", array(), "adoptiename='{$adopt->type}' and thisislevel ='{$adopt->currentlevel}'")->fetchObject();
  if(
$lev->alternateimage == ""){
      
// The alternate image does not exist, cannot convert adoptable into its alternate form
    
$note "It appears that your adoptable does not have an alternate image at its given level...<br>";
  }
  
  else{
      
// The alternate image exists, conversion between primary and alternate image is possible.
    
switch($adopt->usealternates){
      case 
"yes"
        
$mysidia->db->update("owned_adoptables", array("usealternates" => 'no'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");        
        
$note "Your adoptable has assume the species primary form.";
        break;
      default:
        
$mysidia->db->update("owned_adoptables", array("usealternates" => 'yes'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");       
        
$note "Your adoptable {$adopt->name} has assume the species alternate form.";
    }
    
//Update item quantity...
    
$delitem $item->remove();    
    return 
$note;    
}

function 
items_alts2($item$adopt){
  
$note "This feature will be available soon after we redesign the adoptable class, enjoy!";
  return 
$note;
}

function 
items_recipe($item$adopt){
  if (
check_stats($item) == false){
    return 
"The item {$item->itemname} is a recipe item, which is only useful if you are preforming alchemy.";
  }
  
$note "The item {$item->itemname} is a recipe item, which is more useful if you are performing alchemy. However your {$adopt->name} has greedily used it up anyway!";
  
$item->remove();
  return 
$note;
}

function 
items_name1($item$adopt){
  
$note "umm just realized that people can change adoptables names freely, will have to think about it later.";
  return 
$note;
}

function 
items_name2($item$adopt){
  
$note "For now the items can only be used on adoptables, so user-based item usage will be implemented later.";
  return 
$note;
}

/* Increase players pet storage size */
function items_space($item) {
  
$mysidia Registry::get("mysidia");
  
$max $mysidia->user->getStatus()->max_pets;
  
$limit $mysidia->getSettings()->maximumpets;
  if (
$max >= $limit) return $mysidia->lang->global_sitewide_maximum_pets_reached;
  
$newMax $max+$item->value;
  if (
$newMax $limit) return "Sorry but you can't use {$item}, it'd increase your size beyond the site pet limits.";

  
$mysidia->db->update('users_status', ['max_pets'=>$newMax], "username='{$mysidia->user->username}'");
  
$delitem $item->remove();
  return 
$mysidia->lang->global_size_increase_item_used;
}

function 
items_key($item) {
  if (
check_stats($item) == false) {
    return 
"This {$item->itemname} can not be used on your pet.";
  }
  
$item->remove(); 
  return 
$item->itemname ' has been used.';
}


function 
check_stats($item) {
  
$stats = ['hunger''thirst''closeness''happiness'];
  foreach (
$stats as $s) {
    if (
$item->$s != 0) {
      return 
TRUE;
    }
  }
  function 
items_unbindingcompanion($item$adopt){
  
$mysidia Registry::get("mysidia");
  
  if (
$adopt->companion != "nocompanion") {  
    
$itemgive = new StockItem($adopt->companion);  
    
$itemgive->append(1$mysidia->user->username);  
    } 

  
$mysidia->db->update("owned_adoptables", array("companion" => 'nocompanion'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "You use the <b>{$item->itemname}</b> on your pet, breaking the bond between it and its companion. The companion has been returned to your inventory!<br /><br /> <a href='/inventory'><button type='button'>Return to Inventory</button></a><br>";
  
//Update item quantity...
  
$delitem $item->remove(); 
  return 
$note;



function 
items_unbindingitem($item$adopt){
  
$mysidia Registry::get("mysidia");
  
  if (
$adopt->item != "noitem") {  
    
$itemgive = new StockItem($adopt->item);  
    
$itemgive->append(1$mysidia->user->username);  
    } 

  
$mysidia->db->update("owned_adoptables", array("item" => 'noitem'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "You use the <b>{$item->itemname}</b> on your pet, breaking the bond between it and its held item. The held item has been returned to your inventory!<br /><br /> <a href='/inventory'><button type='button'>Return to Inventory</button></a><br>";
  
//Update item quantity...
  
$delitem $item->remove(); 
  return 
$note;
}  
function 
items_companion($item$adopt){
  
$mysidia Registry::get("mysidia");
  
  if (
$adopt->companion != "nocompanion") {  
    
$itemgive = new StockItem($adopt->companion);  
    
$itemgive->append(1$mysidia->user->username);  
    } 
    
  
$companion $item->itemname;
  
$mysidia->db->update("owned_adoptables", array("companion" => $companion), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "You have given your pet a <b>{$item->itemname}</b>! It will now show up in your pet's profile. <br /><br /> <a href='http://mysgardia.com/inventory'><button type='button'>Return to Inventory</button></a><br>";
  
//Update item quantity...
  
$delitem $item->remove(); 
  return 
$note;
}  
  return 
FALSE;
}
}
?>
Im really sorry that I suck at this so much x.x Im trying honest.

EDIT: I was trying to make it so that there was a seperate button for "Giving items to pets" For the Held items and pet companions because I have some items that can actually be used that I'd like them o be able to hold without using them for the stats.... This is what I tried to Do in my Inventoryview.php... in the Use area..

PHP Code:
   # Rendering items now
            
$document->add(new Comment("
                <div class=\"s_panel sc_item\">
                    <img rel=\"tooltip\" title=\"
{$item->description} <em>{$usage}</em>\" src=\"{$item->imageurl}\"/><br/>
                    <b>
{$item->itemname}</b><br> Own &times;{$item->quantity}<br/>"FALSE));

            
# If item is consumable, add use button
            
if ($item->consumable == "yes") {
                
$useForm = new FormBuilder("useform""inventory/uses""post");
                
$useForm->setLineBreak(FALSE);
                
$useForm->buildPasswordField("hidden""action""uses")
                    ->
buildPasswordField("hidden""itemname"$item->itemname)
                    ->
buildButton("Use""use""use");
                
$document->add($useForm);
            }
             if (
$item->helditem == "yes") {
                
$useForm = new FormBuilder("useform""inventory/uses""post");
                
$useForm->setLineBreak(FALSE);
                
$useForm->buildPasswordField("hidden""action""uses")
                    ->
buildPasswordField("hidden""itemname"$item->itemname)
                    ->
buildButton("Give to Pet""Give to Pet""Give to Pet");
                
$document->add($useForm);
            }
       if (
$item->companion == "yes") {
                
$useForm = new FormBuilder("useform""inventory/uses""post");
                
$useForm->setLineBreak(FALSE);
                
$useForm->buildPasswordField("hidden""action""uses")
                    ->
buildPasswordField("hidden""itemname"$item->itemname)
                    ->
buildButton("Give to Pet""Give to Pet""Give to Pet");
                
$document->add($useForm);
            } 
Im really trying to figure this out.. x.x

Last edited by Ittermat; 12-14-2016 at 10:09 PM.
Reply With Quote
  #14  
Old 12-20-2016, 02:00 PM
parayna's Avatar
parayna parayna is offline
Member
 
Join Date: May 2013
Location: Devon, UK
Posts: 342
Gender: Female
Credits: 22,707
parayna is on a distinguished road
Default

I seem to be having a little issue with it. If I add the companions through the PHP myadmin bit it works perfectly, but when trying to do it through the inventory and use the item it gives me a blank page. Is there something I need to add to an inventory page, or is it something else that's wrong? (Other items still work, so I know it's only with these functions )
Reply With Quote
  #15  
Old 12-21-2016, 11:53 AM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 57,835
tahbikat is on a distinguished road
Default

Sorry guys, I would try to help with this but I don't have access to the mysidia script at the moment. Hopefully someone else can help.
Reply With Quote
  #16  
Old 12-23-2016, 12:31 PM
parayna's Avatar
parayna parayna is offline
Member
 
Join Date: May 2013
Location: Devon, UK
Posts: 342
Gender: Female
Credits: 22,707
parayna is on a distinguished road
Default

I'm not sure if anyone will be around to help (and it's fine if not) but just in case others are getting the same error it is basically telling me that the function items_companion() is undefined and so won't let me use the item. I've put all the files onto my remote server so I can see the errors, as my online one has them turned off xD
Reply With Quote
  #17  
Old 12-23-2016, 01:59 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 133,570
Abronsyth is on a distinguished road
Default

Did you make sure to include the function in functions/functions_items.php ?
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #18  
Old 12-23-2016, 02:16 PM
parayna's Avatar
parayna parayna is offline
Member
 
Join Date: May 2013
Location: Devon, UK
Posts: 342
Gender: Female
Credits: 22,707
parayna is on a distinguished road
Default

Yeah, the error is actually for class_privateitem (forgot to say lol) and I've checked both that one and functions_items o.O
Reply With Quote
  #19  
Old 12-23-2016, 03:01 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 133,570
Abronsyth is on a distinguished road
Default

Can you post your class_privateitem file?
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #20  
Old 12-23-2016, 04:03 PM
parayna's Avatar
parayna parayna is offline
Member
 
Join Date: May 2013
Location: Devon, UK
Posts: 342
Gender: Female
Credits: 22,707
parayna is on a distinguished road
Default

Sure!

  Spoiler: Code 
PHP Code:
<?php

use Resource\Native\String;

class 
PrivateItem extends Item{
  
// The PrivateItem class, which defines functionalities for items that belong to specific users

  
public $iid;
  public 
$owner;
  public 
$quantity;
  public 
$status;
  
  public function 
__construct($iteminfo$itemowner ""){     
      
// the item is an owned item in user inventory, so retrieve database info to assign properties
      
$mysidia Registry::get("mysidia");
      
      
$fetchmode = (is_numeric($iteminfo))?"iid":"itemname";
      
$whereclause = ($fetchmode == "iid")?"{$fetchmode} = '{$iteminfo}'":"{$fetchmode} ='{$iteminfo}' and owner = '{$itemowner}'";          
      
$row $mysidia->db->select("inventory", array(), $whereclause)->fetchObject();
      if(
is_object($row)){
         
// loop through the anonymous object created to assign properties
         
foreach($row as $key => $val){
            
$this->$key $val;
         }
         
parent::__construct($this->itemname);
      }
      else 
$this->iid 0;      
  }
 
  public function 
getitem(){
      
// This method checks if the item exists in inventory or not, not to be confused with parent class' getitem() class.
      
$mysidia Registry::get("mysidia");
      
$stmt $mysidia->db->select("inventory", array(), "itemname ='{$this->itemname}' and owner ='{$this->owner}'"); 
      return 
$stmt->fetchObject();
  }
 
  public function 
getvalue($quantity 0$discount 0.5){
      
// This method returns the cost of items.
      
      
$value $this->price*$quantity*$discount;
      return 
$value;
  }
  
  public function 
apply($adopt ""$user ""){
      
// This method uses 
      
$mysidia Registry::get("mysidia");
      require_once(
"functions/functions_items.php");
      
      if(
is_numeric($adopt)) $owned_adoptable $mysidia->db->select("owned_adoptables", array(), "aid ='{$adopt}'")->fetchObject();
      if(!empty(
$user)) $theuser $mysidia->db->select("users", array(), "username ='{$user}'")->fetchObject();
      
      
// Now we decide which function to call...
      
switch($this->function){
         case 
"Valuable"
            
$message items_valuable($this$owned_adoptable);
            break;
         case 
"Level1":
            
$message items_level1($this$owned_adoptable);
            break;
         case 
"Level2":
            
$message items_level2($this$owned_adoptable);
            break;
         case 
"Level3":
            
$message items_level3($this$owned_adoptable);
            break;
         case 
"Click1":
            
$message items_click1($this$owned_adoptable);
            break;
         case 
"Click2":
            
$message items_click2($this$owned_adoptable);
            break;
         case 
"Breed1":
            
$message items_breed1($this$owned_adoptable);
            break;
         case 
"Breed2":
            
$message items_breed2($this$owned_adoptable);
            break;
         case 
"Alts1":
            
$message items_alts1($this$owned_adoptable);
            break;
         case 
"Alts2":
            
$message items_alts2($this$owned_adoptable);
            break;
         case 
"Name1":
            
$message items_name1($this$theuser);
            break;
         case 
"Name2":
            
$message items_name2($this$theuser);
            break;
        case 
"Companion":
            
$message items_companion($this$owned_adoptable);
            break; 
        case 
"HeldItem":
            
$message items_helditem($this$owned_adoptable);
            break;  
         default:
            throw new 
ItemException("The item function is invalid");         
        case 
"UnbindingCompanion":
            
$message items_unbindingcompanion($this$owned_adoptable);
            break; 
         case 
"UnbindingItem":
            
$message items_unbindingitem($this$owned_adoptable);
            break;  
      }
      return new 
String($message);
  }  

  public function 
add($quantity 1$owner){

  }

  public function 
sell($quantity 1$owner ""){
      
// This method sells items from user inventory
      
$mysidia Registry::get("mysidia");
      
      
$this->owner = (!empty($owner))?$owner:$this->owner;
      
$earn $this->getvalue($quantity);      
      
$newamount $mysidia->user->money $earn;
      
      if(
$this->remove($quantity)){
         
$mysidia->db->update("users", array("money" => $newamount), "username = '{$this->owner}'");
         return 
TRUE;
      }
      else return 
FALSE;      
  }
  
  public function 
toss($owner ""){
      
$this->remove($this->quantity);
      return 
TRUE;
  }
  
  public function 
remove($quantity 1$owner ""){
      
// This method removes items from user inventory
  
      
$mysidia Registry::get("mysidia");
      
$this->owner = (!empty($owner))?$owner:$this->owner;
      
$newquantity $this->quantity $quantity;
      if(empty(
$this->quantity) or $newquantity 0) return FALSE;
      else{
         switch(
$newquantity){
            case 
0:
               
$mysidia->db->delete("inventory""itemname='{$this->itemname}' and owner='{$this->owner}'");
               break;
            default:
               
$mysidia->db->update("inventory", array("quantity" => $newquantity), "itemname ='{$this->itemname}' and owner='{$this->owner}'");
         }
         return 
TRUE;
      }
  }
  
  public function 
checktarget($aid){
      
// This method checks if the item is usable
      
$adopt = new OwnedAdoptable($aid);
      
$id $adopt->getID();
      
$item_usable FALSE;
      switch(
$this->target){
         case 
"all":
            
$item_usable TRUE;
            break;
         case 
"user":
            
$item_usable TRUE;
            break;
         default:
            
$target explode(",",$this->target);
            if(
in_array($id$target)) $item_usable TRUE;            
      }
      return 
$item_usable;
  }
  
  public function 
randomchance(){
      
// This method returns the item image in standard html form
      
$mysidia Registry::get("mysidia");
      switch(
$this->chance){
         case 
100:
            
$item_usable TRUE;
            break;
         default:
            
$temp mt_rand(0,99);
            
$item_usable = ($temp $this->chance)?TRUE:FALSE;
      }
      return 
$item_usable;      
  }
}
?>


Thanks ^_^
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


All times are GMT -5. The time now is 02:57 PM.

Currently Active Users: 715 (0 members and 715 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