Mysidia Adoptables Support Forum  

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

Notices

Reply
 
Thread Tools Display Modes
  #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,221
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
  #2  
Old 09-25-2014, 12:29 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 19,319
IntoRain is on a distinguished road
Default

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

__________________


asp.net stole my soul.
Reply With Quote
  #3  
Old 09-25-2014, 12:39 PM
kristhasirah's Avatar
kristhasirah kristhasirah is offline
Member
 
Join Date: Jan 2010
Location: In middle of the nothingness
Posts: 196
Gender: Female
Credits: 28,221
kristhasirah
Default

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
__________________
Reply With Quote
  #4  
Old 09-26-2014, 12:47 PM
ilrak ilrak is offline
Goldfish Fanatic
 
Join Date: Aug 2014
Location: Utah
Posts: 57
Gender: Female
Credits: 11,605
ilrak is on a distinguished road
Default

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?)
Reply With Quote
  #5  
Old 09-26-2014, 12:50 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 19,319
IntoRain is on a distinguished road
Default

Quote:
Originally Posted by kristhasirah View Post
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!
__________________


asp.net stole my soul.
Reply With Quote
  #6  
Old 09-26-2014, 01:03 PM
kristhasirah's Avatar
kristhasirah kristhasirah is offline
Member
 
Join Date: Jan 2010
Location: In middle of the nothingness
Posts: 196
Gender: Female
Credits: 28,221
kristhasirah
Default

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 ^^
__________________
Reply With Quote
  #7  
Old 09-26-2014, 02:29 PM
Missy Master's Avatar
Missy Master Missy Master is offline
Pet-Sim.Online
 
Join Date: Jan 2010
Posts: 475
Gender: Unknown/Other
Credits: 44,802
Missy Master is an unknown quantity at this point
Default

Really love this whole thing, and will be adding it as well, thanks for the good work! :)
Reply With Quote
  #8  
Old 09-26-2014, 02:35 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 19,319
IntoRain is on a distinguished road
Default

Quote:
Originally Posted by kristhasirah View Post
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 ^^
__________________


asp.net stole my soul.
Reply With Quote
  #9  
Old 09-29-2014, 02:01 PM
ilrak ilrak is offline
Goldfish Fanatic
 
Join Date: Aug 2014
Location: Utah
Posts: 57
Gender: Female
Credits: 11,605
ilrak is on a distinguished road
Default

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!

Last edited by ilrak; 09-29-2014 at 02:15 PM.
Reply With Quote
  #10  
Old 09-29-2014, 03:09 PM
parayna's Avatar
parayna parayna is offline
Member
 
Join Date: May 2013
Location: Devon, UK
Posts: 342
Gender: Female
Credits: 16,333
parayna is on a distinguished road
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes

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 06:45 PM.

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