View Single Post
  #1  
Old 09-25-2014, 08:53 AM
kristhasirah's Avatar
kristhasirah kristhasirah is offline
Member
 
Join Date: Jan 2010
Location: In middle of the nothingness
Posts: 196
Gender: Female
Credits: 28,995
kristhasirah
Default Item Function: change the type of an adopt

10/01/2014:
Final code for changing the adopt type to a new adopt type, and limited to only the max level
thanks once again to IntoRain for helping me with the code here is the final code:
open: functions/functions_items.php and paste this code before the ?>

IMPORTANT!!! Replace any Moonlight Fairy Dragon, for the Type of the adopt you have selected as the new Type!!! Also i use for my site a max level of 10 replace it for your max level number!!!
And edit the $notes = with the info you think fits better your site
PHP Code:
function items_Type($item$adopt){
          
$mysidia Registry:: get("mysidia"); 
        
        
$type $adopt->type;
        
$currentLevel $adopt->currentlevel;
           
        
//Let's check if the adoptable is a Moonlight Fairy Dragon. 
        
if($type == "Moonlight Fairy Dragon") { 
            
//The adoptable is already a Moonlight Fairy Dragon 
            
$note "Your adoptable is a Moonlight Fairy Dragon."
        } 
        
//Let's check if the adoptable is below level 10. 
        
else if($currentLevel 10){
            
$note "Your adoptable is not at level 10 yet.";
        }
        
//Adoptable has all the requirements, let's update it 
        
else{            
            
$mysidia -> db -> update("owned_adoptables", array("type" => 'Moonlight Fairy Dragon'),"aid='{$adopt->aid}' and owner ='{$item->owner}'"); 
            
$note "Your adoptable {$adopt->name} is now a Moonlight Fairy Dragon."
            
//Update item quantity... 
            
$delitem $item->remove();  
        } 
        return 
$note

open the class/class_privateitem.php and add this after the last case break;
PHP Code:
case "itemsType":
$message items_Type($this$owned_adoptable);
break; 
and last you will need to open your database to add the item to the adopt_items_funtions table, is easy: just insert a new row, you can use the other items as example to fill the info

you can find some edit to the code in this thread:
change the image of a specific adopt for a custom image:
(this will change the adopt image to any image you have selected, this means any adopt that use this item will have that specific image, to prevent this you must select the id of the adopt types that can use it or are compatible in the item creation page)
function/function_items.php
http://www.mysidiaadoptables.com/for...7&postcount=13
class/class_privateitem.php case:
http://www.mysidiaadoptables.com/for...9&postcount=15

you must copy and paste the code for each custom skin you will add, also remember to select which adopt will be able to use the item in the item creation page, or any adopt will have the custom skin.

Revert the image of the adopt back to his/her original image(this is to use as part of the custom image code)
function/function_items.php and class/class_privateitem.php case:
http://www.mysidiaadoptables.com/for...3&postcount=19

remember you must add the info in the database too, so you can select and use the item function in the item creation page

Original older post
thanks to Wallie987 and IntoRain for the gender item: http://www.mysidiaadoptables.com/for...er+item&page=3 I manage to edit it and make a different function code and like the title says i need a little help with it. The thing is that the current code is working like a charm, and it does what is supposed to do: Change the Type of any adopt to a Specific Adopt, great for a evolution item, but what i really want or need is:
For the code to also check if the adopt is at the max level in my case level 10.

this is the code:
PHP Code:
function items_Type($item$adopt){
        
$mysidia Registry:: get("mysidia");
        
//Let's check if the adoptable is a Moonlight Fairy Dragon.
        
$type $mysidia -> db -> select ("owned_adoptables", array("type"), "aid='{$adopt->aid}' and owner ='{$item->owner}'") -> fetchColumn();  
        if(
$type == "Moonlight Fairy Dragon") {
            
//The adoptable is already a Moonlight Fairy Dragon
            
$note "Your adoptable is a Moonlight Fairy Dragon.";
        }
        else{
            
//The adoptable is another type. It's type can be switched to a Moonlight Fairy Dragon.
            
switch($adopt->type){
                case 
"$type":
                    
$mysidia -> db -> update("owned_adoptables", array("type" => 'Moonlight Fairy Dragon'),"aid='{$adopt->aid}' and owner ='{$item->owner}'");
                    
$note "Your adoptable {$adopt->name} is now a Moonlight Fairy Dragon.";
            
//Update item quantity...
            
$delitem $item->remove();
            break;
            default:
            
$note "It appears your adoptable can't use the potion.";
}
        }
        return 
$note;

so if any one can help me and edit/add the missing piece of code for checking the level of the adopt and make it that only the adopts are at max level can use it I will be very grateful.

Please take in mind that any instruction or idea to fix it will be in vain... I can only copy/paste already created codes and make small edits... i cant make anything from scratch even if my life was depending on it =( but i can make some pixel or digital items as a thanks for helping me with the code.

For those that want to use the code for their site, the code is working just need to replace the "moonlight fairy dragon" with the adopt type you want and if you want to make it more specific and only target a certain adopt, just change the $type in
PHP Code:
case "$type"
with the target type, it must look something like this:
PHP Code:
case "Adopts type"
Once again:
Thanks Wallie987 and IntoRain for the gender item.
__________________

Last edited by kristhasirah; 10-01-2014 at 04:02 PM. Reason: the code is fixed and working
Reply With Quote