Mysidia Adoptables Support Forum  

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

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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: 29,034
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
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mys v1.3.4 Item Function: Gender Change Potion Kyttias Mys v1.3.x Mods 21 10-12-2016 07:52 PM
Calling a function in a function from the same class page Hwona Questions and Supports 2 04-25-2015 08:41 AM
Item Function Is Invalid Hwona Questions and Supports 31 09-27-2014 09:27 PM
Item Function Suggestions NobodysHero Suggestions and Feature Requests 5 06-23-2014 03:45 AM


All times are GMT -5. The time now is 11:53 PM.

Currently Active Users: 710 (0 members and 710 guests)
Threads: 4,080, Posts: 32,024, 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