Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Help with a item function (http://www.mysidiaadoptables.com/forum/showthread.php?t=4663)

kristhasirah 09-25-2014 08:53 AM

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.

IntoRain 09-25-2014 12:29 PM

I'm glad we were able to help ^^ Adding the following will let you check if the adoptable is at level 10:

PHP Code:

//rest of your code here
 
$type $mysidia -> db -> select ("owned_adoptables", array("type"), "aid='{$adopt->aid}' and owner ='{$item->owner}'") -> fetchColumn(); 
  
$currentLevel $adopt->currentlevel;//add this

        
if($type == "Moonlight Fairy Dragon") { 
            
//The adoptable is already a Moonlight Fairy Dragon 
            
$note "Your adoptable is a Moonlight Fairy Dragon."
        }
      
//add these three lines:
      
else if($currentLevel 10){
            
$note "Your adoptable is not at level 10 yet.";     
      }
     
//rest of your code here 

That version in that thread ended up being a bit messy due to repeated comparisons xD This is a clean version if you prefer to use it:

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



kristhasirah 09-25-2014 12:39 PM

THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! It works perfectly!!!!
if you need some items (pixel or digital) just tell me and i will happily make them for you =D

ilrak 09-26-2014 12:47 PM

Ooh I love this mod idea! Do you mind if I use it and try to make it a randomized one (so it will change to a random color of the breed?)

IntoRain 09-26-2014 12:50 PM

Quote:

Originally Posted by kristhasirah (Post 31198)
THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! It works perfectly!!!!
if you need some items (pixel or digital) just tell me and i will happily make them for you =D

I don't have a site currently, but thank you! ^^ I'm glad it worked!

kristhasirah 09-26-2014 01:03 PM

ilrak: i dont see any problem with that, and i think it would be cool to have a random color changer
and IntoRain: if you decided to start making a site just tell me and i will gladly make those items for you =) or i can make something else for you ^^

Missy Master 09-26-2014 02:29 PM

Really love this whole thing, and will be adding it as well, thanks for the good work! :)

IntoRain 09-26-2014 02:35 PM

Quote:

Originally Posted by kristhasirah (Post 31218)
ilrak: i dont see any problem with that, and i think it would be cool to have a random color changer
and IntoRain: if you decided to start making a site just tell me and i will gladly make those items for you =) or i can make something else for you ^^

Thank you! I really appreciate that ^^

ilrak 09-29-2014 02:01 PM

So, I tried doing this code as-is first to see if I could get it to work on my site before trying a random changer and I'm running into this error:

Quote:

Parse error: syntax error, unexpected '}' in /home/auratusg/public_html/functions/functions_items.php on line 237
This is what the code looks like for the function:
EDIT: Nevermind. There were one too many brackets. Now I just need to try and fix the invalid function error and then I'm set!

parayna 09-29-2014 03:09 PM

Would there be a way to adapt this code so that you can make an item that changes an adoptable into something else? (I mean like reuse it multiple times, on different items, for different kinds of adopts) That way you could have 'skins' for your adopts or something... correct me if I am wrong and this is already what it does XD I don't totally understand XD


All times are GMT -5. The time now is 07:47 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.