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

kristhasirah 09-29-2014 06:42 PM

the code will change your adopt to other type: like for example, you change where it say "moonlight fairy dragon" for one of your type of adopt, lets say a cat, so you now have a item that transforms any adopt in a cat, unless you have limited the types in the item creation, then only the selected adopts can be changed in a cat

but it can be used in the way you say, probably you need to change this:
array("type" => 'Moonlight Fairy Dragon')... maybe change it for array("imageurl"=> 'the image url of the adopt') or something like that, im not sure, havent tried that way...in theory it will only change the image of your adopt and you wont need to create X amount of adopt just to change the color of 1 adopt... but theres also the alt item, wich changes your adopt in his/her alt version, unless you are not adding the alternate image for your adopts.
but i have no idea how to code it or edit it so you can only add the function once... right now you need to copy and paste as many time you want for each adopt you want to change in to another type or color and you will end whit a very large item_functions file, unless you dont mind that.

sorry if i dont make sense >_>

parayna 09-30-2014 01:54 AM

Oh, no, you do make sense. So in the item functions file, for every, say, 'skin', you would need to create a new item function? Seems a complicated way of doing things, but I have been waiting for something like this to come out for years! (Ever since I first found the script XD) I might mess about with it on my test site later. Just make a few adoptables and that item then mess around with them :P

kristhasirah 09-30-2014 09:55 AM

decided to go and test my theory and here is the working code:

PHP Code:

function items_Skin($item$adopt){
          
$mysidia Registry:: get("mysidia"); 
        
        
$imageurl $adopt->imageurl;
        
$currentLevel $adopt->currentlevel;
           
        
//Let's check if the adoptable is using this custom skin. 
        
if($imageurl == "http://yoursite.com/picuploads/png/nameorcodeoftheimage.png") { 
            
//The adoptable is already using this custom skin
            
$note "Your adoptable is using this custom skin."
        } 
        
//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("imageurl" => 'http://yoursite.com/picuploads/png/nameorcodeoftheimage.png'),"aid='{$adopt->aid}' and owner ='{$item->owner}'"); 
            
$note "Your adoptable {$adopt->name} is now using a new custom skin."
            
//Update item quantity... 
            
$delitem $item->remove();  
        } 
        return 
$note



I changed all the $type in the code because you already can chose who will use the item at the Item creation page, also to make sure the user wont be using the item twice in the same adopt by mistake and loose the item.
the only problem i see is that if for some reason the user want the adopt to have their original skin(don't know why someone would want to do that) they cant... so i would post a warning in the description of the adopt saying that all changes are permanent XD Unless you can code something to make them return to their original form =)

you can still use the code that intoRain edited, if you want to exclude a special type of adopt, just change the part that start from "else{"

parayna 09-30-2014 10:36 AM

Ooh, so if I used that one I could create custom skins?? :D Yay! Thank you ^_^ (I can use it right? :P I'll be making a credit page anyway so I can give you a shout out!)

So, to use it, do you just copy and paste the code for every custom skin? Or is that a seperate item function that you can then use on items and when they are put on your adopts it changes them?

If so, coool :D What you could do is, as well as the warning, make people pay a certain amount of virtual money (or real, if you wanted to) to have their adopts reverted back to their original state? And only admins can do it. Just throwing ideas out there XD

kristhasirah 09-30-2014 10:55 AM

well the code is the function for the items... in this case for 1 Item, you must open the function/function_items.php and just copy/paste the code before the "?>" and replace the imageurl with the image you want, not forget to change the: function items_Skin($item, $adopt){ by replacing the _Skin with the name of each custom, that way you wont be confused. also remember to edit the class_privateitem.php to add the new case for each code you create and replace "Skin" with the name of custom:
case "itemsSkin":
$message = items_Skin($this, $owned_adoptable);
break;

and add them to your database in the table adopts_items_function by adding a new row for each custom skin =)

well is a nice idea you have for reverting back the adopt, but if you cant be online all the time, members can start complaining... i know there should be a way to edit the code and revert the adopts back to their original image, but cant figure out how to update the imageurl table back to "NULL"... because for now it just write null as the url and give an x image for the adopt >_>

parayna 09-30-2014 12:08 PM

Yeah, I can see how they would start complaining XD And for the code, I might have to play around on my test site.. (it's the only way I'll be able to learn how to do it properly XD) but thanks for telling me how, as I would have had no idea o.O

kristhasirah 09-30-2014 12:39 PM

i will try and see if i can find anything to make the code revert the image =)
also fixed the case...
i copied one of the ones i had and forgot to change 1 part: = items_Type it should be: = items_Skin and you just do the same and replace the Skin whit the name of the custom
sorry about that >_>

parayna 09-30-2014 01:07 PM

That's fine XD I am just happy that you bothered enough to attempt to write a code! (And succeed) I suck at coding XD I need to practise or take some sort of online class/school thing... hmm. There's a thought! :pleased:

kristhasirah 09-30-2014 02:40 PM

manage to make the reverting code work ^^

here is the finished one:
functions/functions_items.php
PHP Code:

function items_originalS($item$adopt){
          
$mysidia Registry:: get("mysidia"); 
        
        
$imageurl $adopt->imageurl;
        
$currentLevel $adopt->currentlevel;
        
                   
//Let's check if the adoptable is using his/her original color. 
        
if($imageurl == NULL) { 
            
//The adoptable is already using his/her original color
            
$note "Your adoptable is using his/her original color."
        } 
        
//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("imageurl" => NULL),"aid='{$adopt->aid}' and owner ='{$item->owner}'");
            
$note "Your adoptable {$adopt->name} is now using his/her original color."
            
//Update item quantity... 
            
$delitem $item->remove();  
        } 
        return 
$note



class/class_privateitem.php
case
PHP Code:

case "itemsoriginalS":
$message items_originalS($this$owned_adoptable);
break; 

it was so simple... i just had to remove the cotes '' from NULL to make it work o_O it was the only change i made to the code, this will revert back the adopt to his/her original image or alternate image depending which one was using before the change of skin.
by the way you can change what it says in the $note= to anything you want or you think it will go with your site =)

parayna 10-01-2014 12:03 PM

Oh, my... thanks so much!! :D yay ^_^

AndromedaKerova 11-10-2014 04:20 AM

Is it possible to add a check if the pet is using its alt image and if it IS then make it use an alternative of the skin to match?

If it ISN'T then it alters it to the first defined image.

Same for the reverter. It would need to know if its an alt image so it could revert it back to it.

This is just in case people still want alts as well as skins.

kristhasirah 11-10-2014 07:56 AM

If you want an item to change the adopt to his/her alt version and return back to the normal one, the script already have one function that does that.
But i think is possible to code that opcion... saddly i dont know how code that, the changes i did where based on pure luck and because they where kind of small.

AndromedaKerova 11-10-2014 04:05 PM

I'll see if I can get the basic image alter and the reverter installed and do a bit of fiddling and see if I can get my idea added. If I can, I'll post the revision. ^_^

AndromedaKerova 11-10-2014 06:43 PM

[strike]I have an error with the item. I installed the skin version as directed but when I try and access my items page to use it on my pet, the page appears blank.

I have to manually remove the item using the ACP to be able to get to the inventory page again.[/strike]

*Edit*
Ok, I fixed that issue.

New problem is when I try to use the reverter or the changer on the pet, it now returns this:
The item function is invalid

Happens for both items.

AndromedaKerova 11-10-2014 08:37 PM

I've had a go at making an alternate check + alternate setter from the skin changer but it refuses to work.
Not sure what I did wrong. Still learning this stuff.

PHP Code:

function items_Skin($item$adopt){ 
          
$mysidia Registry:: get("mysidia");  
         
        
$imageurl $adopt->imageurl;
        
$currentLevel $adopt->currentlevel
            
        
//Let's check if the adoptable is using this custom skin.  
        
if($imageurl == "http://yoursite.com/picuploads/png/nameorcodeoftheimage.png") {  
        else if(
$imageurl == "http://yoursite.com/picuploads/png/nameorcodeoftheimageALT.png") {
            
//The adoptable is already using this custom skin 
            
$note "Your adoptable is using this custom skin.";  
        }  
        
//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("usealternates" => 'no'), "imageurl" => 'http://yoursite.com/picuploads/png/nameorcodeoftheimage.png'),"aid='{$adopt->aid}' and owner ='{$item->owner}'");  
            
$note "Your adoptable {$adopt->name} is now using a new custom skin.";  
        else{               
            
$mysidia -> db -> update("owned_adoptables", array("usealternates" => 'yes'), "imageurl" => 'http://yoursite.com/picuploads/png/nameorcodeoftheimageALT.png'),"aid='{$adopt->aid}' and owner ='{$item->owner}'");  
            
$note "Your adoptable {$adopt->name} is now using a new custom skin.";  
            
//Update item quantity...  
            
$delitem $item->remove();   
        }  
        return 
$note

Thankfully my tests with the reverter have revealed that if the pet was using its alt form, it will return to it. If the pet is not alternate then it returns to that state.

That means it's just the actual skin changer that needs fiddling with to make work. \0/

IntoRain 11-10-2014 09:07 PM

Quote:

Originally Posted by AndromedaKerova (Post 31514)
I've had a go at making an alternate check + alternate setter from the skin changer but it refuses to work.
Not sure what I did wrong. Still learning this stuff.

PHP Code:

function items_Skin($item$adopt){ 
          
$mysidia Registry:: get("mysidia");  
         
        
$imageurl $adopt->imageurl;
        
$currentLevel $adopt->currentlevel
            
        
//Let's check if the adoptable is using this custom skin.  
        
if($imageurl == "http://yoursite.com/picuploads/png/nameorcodeoftheimage.png") {  
        else if(
$imageurl == "http://yoursite.com/picuploads/png/nameorcodeoftheimageALT.png") {
            
//The adoptable is already using this custom skin 
            
$note "Your adoptable is using this custom skin.";  
        }  
        
//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("usealternates" => 'no'), "imageurl" => 'http://yoursite.com/picuploads/png/nameorcodeoftheimage.png'),"aid='{$adopt->aid}' and owner ='{$item->owner}'");  
            
$note "Your adoptable {$adopt->name} is now using a new custom skin.";  
        else{               
            
$mysidia -> db -> update("owned_adoptables", array("usealternates" => 'yes'), "imageurl" => 'http://yoursite.com/picuploads/png/nameorcodeoftheimageALT.png'),"aid='{$adopt->aid}' and owner ='{$item->owner}'");  
            
$note "Your adoptable {$adopt->name} is now using a new custom skin.";  
            
//Update item quantity...  
            
$delitem $item->remove();   
        }  
        return 
$note

Thankfully my tests with the reverter have revealed that if the pet was using its alt form, it will return to it. If the pet is not alternate then it returns to that state.

That means it's just the actual skin changer that needs fiddling with to make work. \0/

I don't think your if's/else's and brackets are closing well. For example you have this else-if

PHP Code:

 else-if($imageurl == "http://yoursite.com/picuploads/png/nameorcodeoftheimageALT.png") {
                
//The adoptable is already using this custom skin 
                
$note "Your adoptable is using this custom skin.";  
            } 

inside this if

PHP Code:

 if($imageurl == "http://yoursite.com/picuploads/png/nameorcodeoftheimage.png") { 

which is not making sense because if it passes the first if for the normal image you already know what imageurl is and it is not the ALT image for sure. You also have an else without closing it

Sorry, I'm not sure what you want to do yet, so I can't help more than this :/

AndromedaKerova 11-10-2014 09:22 PM

I'm only a beginner with coding. My aim is to expand on the skin changer. To make it ask if the pet is using an alt image and if it is, instead of painting the regular, it would paint an alternative of the custom skin to match better with the original.

Without that, it makes the alt pet just look like every other pet that has this item used on it. Seems to lose its altness while the database keeps the value.

Examples:
BEFORE
AFTER

Rhiadra is the one using the alt image but after painting it appears not to be.

Next thing I want to attempt is making it check if the pet is male or male/alt then make it set respective images for them too.

IntoRain 11-10-2014 09:54 PM

So if it's using an alt image, it uses another alt image? And if it's using the common image, use the alt image?

AndromedaKerova 11-10-2014 09:57 PM

The way it works currently is it paints a certain species the new image. It overrides the alt image though the data is still in the DB for the alt pet. I want the image to set a second if the pet is an alt so it "looks" like its still an alt.

Obviously regular users would no longer know if the pet is alt or not in the current way.

parayna 12-11-2014 08:42 AM

Hmm, that's true ... would be cool if that was somehow included ^_^

Kyttias 12-11-2014 10:36 AM

So the end result everyone is wanting is:

normal && female && design A = use image A
alt && female && design A = use image B
normal && male && design A = use image C
alt && male && design A = use image D

But I'm guessing you don't just want one design, but, potentially, many designs? In the case above, if "design A" were "midnight sparkles" then you'd be able to have a pet with this design on both male and female pets, alternate or not.

It's like paintbrushes back on Neopets, only, you also have to take rarer alternate versions of a pet species into consideration, too. If a user is blessed with a rare alternate, they want it to still look just as special when it has its design applied!

I think what's going to need to be done is an entirely new approach. You'll want a new column in the database to hold the design names.

I'll see if I can look into this soon, but it may take a while. ^^ I was actually kind of wanting something similar.

parayna 12-11-2014 12:09 PM

Oh, OK. XD Yeah, I think that is kind of what people are wanting. So basically I think there would be 4 different images taken for one item... a male and female normal image, and an alt male and female image.. I think that's what it would be..

Kyttias 12-11-2014 12:42 PM

Because I've got the alternate gender mod working on my site, I don't have two types of females and two types of males, (alts that is), I just have females and males, and those are the alts.

female && design A = use image A
male && design A = use image B

Without the alt gender mod it would be possible, but you'd have to make each gender it's own species again. The alt gender mod just replaces the alt system... So I'd rather focus on this?

So I guess my first post there was misleading.

What it will actually be is just this:

normal && design A = use image A
alt && design A = use image B

In any case, it will work for people using the gender mod and not. But it won't magically make the gender mod have alts again. It'll just make sure the appropriate gender gets the appropriate image, just like it would make alt or not get the appropriate image.

parayna 12-11-2014 12:57 PM

Oh, alright. Now I understand C: Sounds good! ^_^

AndromedaKerova 04-24-2015 05:41 PM

Sorry to revive an older thread but I'm still interested in this.

I now use the alt gender mod so my alt images are only for males while females use the normal one.

I want to keep that obviously but it should be a single potion/brush paints the species a different one of two images according to alt/gender status.

With multiple items created this way, one could effectively have a lot of new designs/colours for that single species without needing to actually have a "many alt images" kind of mod.

kristhasirah 04-03-2017 10:17 AM

I know this is an old thread but wanted to update the code for a change of skin ^^
Probably not the best way of doing it but it works:

PHP Code:

function items_Skin($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$type $adopt->type;
  
$currentLevel $adopt->currentlevel;
        if(
stripos($type"Dragon") !== FALSE){
           switch(
$type){
                case 
"Red Fairy Dragon"
        
$note "<h1>{$adopt->name} wont eat the food</h1><script>$(\"h1:contains('Action Completed!')\").remove();</script>{$adopt->name} turns in to ashes the food... Be prepared that look means that is planing to make you fall in a prank."; break;
                case 
"Moon Fairy Dragon"
        
$note "<h1>{$adopt->name} wont eat the food</h1><script>$(\"h1:contains('Action Completed!')\").remove();</script>{$adopt->name} blinds you... When you can once again see clearly {$adopt->name} cant be found..."; break;
                default: 
        
$note "<h1>{$adopt->name} wont eat the food</h1><script>$(\"h1:contains('Action Completed!')\").remove();</script>{$adopt->name} gives you a mean look, and turns in to ashes the food! Only the ponies eat that thing";
        }
        }
        else if(
$currentLevel 10){
            
$note "Your adoptable is not at level 10 yet.";
        }
        else if(
$type == "Fairy Pony"){
            
$note "Your adoptable is not chosen to use this skin.";
        }
else {
$delitem $item->remove();
  
$imageurl $mysidia -> db -> select ("owned_adoptables", array("imageurl"), "aid='{$adopt->aid}' and owner ='{$item->owner}'") -> fetchColumn();
        if(
stripos($type"Pony") !== FALSE){ 
                   switch(
$type){ 
        case 
"Starnight Pony"
        switch(
$gender){
                case 
"f"
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;  
                 }
                 break;       
        default: 
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;
                 }               
                  
$mysidia->db->update("owned_adoptables", array("imageurl" => $imageurl,), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$note "Success! The <b>{$item->itemname}</b> has worked its magic. {$adopt->name} now is using a new color.";
return 
$note;
}
//END Case starnight Pony
       
case "Fire Pony"
        switch(
$gender){
                case 
"f"
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;  
                 }
                 break;       
        default: 
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;
                 }               
                  
$mysidia->db->update("owned_adoptables", array("imageurl" => $imageurl,), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$note "Success! The <b>{$item->itemname}</b> has worked its magic. {$adopt->name} now is using a new color.";
return 
$note;
}
//END Case Fire Pony

        
default: 
        switch(
$gender){
                case 
"f"
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;  
                 }
                 break;       
        default: 
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;
                 }               
                  
$mysidia->db->update("owned_adoptables", array("imageurl" => $imageurl,), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$note "Success! The <b>{$item->itemname}</b> has worked its magic. {$adopt->name} now is using a new color.";
return 
$note;
}
//END Default
return $note;
}
//END Type 
}//END Stripos
}//END ELSE
return $note
}
//END Function 

How this code works? well is kind of simple :
PHP Code:

        if(stripos($type"Dragon") !== FALSE){
           switch(
$type){
                case 
"Red Fairy Dragon"
        
$note "<h1>{$adopt->name} wont eat the food</h1><script>$(\"h1:contains('Action Completed!')\").remove();</script>{$adopt->name} turns in to ashes the food... Be prepared that look means that is planing to make you fall in a prank."; break;
                case 
"Moon Fairy Dragon"
        
$note "<h1>{$adopt->name} wont eat the food</h1><script>$(\"h1:contains('Action Completed!')\").remove();</script>{$adopt->name} blinds you... When you can once again see clearly {$adopt->name} cant be found..."; break;
                default: 
        
$note "<h1>{$adopt->name} wont eat the food</h1><script>$(\"h1:contains('Action Completed!')\").remove();</script>{$adopt->name} gives you a mean look, and turns in to ashes the food! Only the ponies eat that thing";
        }
        }
        else if(
$currentLevel 10){
            
$note "Your adoptable is not at level 10 yet.";
        } 
        else if(
$type == "Fairy Pony"){
            
$note "Your adoptable is not chosen to use this skin.";
        } 

This part makes the selected adopt unable to get a skin change and also limit the use to pets that are level 10<-- you can change this to the max level you are using.
the second else if($type == "Fairy Pony"){ <-- makes unable that specific type of pony unable to use the potion
The type of my adopts always have "Pony" Or "Dragon" : if(stripos($type, "Dragon") !== FALSE){ <-- stripos is used for searching in type for the word "dragon" and makes those adopts unable to use the potion.
switch($type){
case "Red Fairy Dragon": <-- you can change this part for the full type of your creature if you want to give them a specific message.
default: <--- this is used for the rest of the adopts.

PHP Code:

else {
$delitem $item->remove();
  
$imageurl $mysidia -> db -> select ("owned_adoptables", array("imageurl"), "aid='{$adopt->aid}' and owner ='{$item->owner}'") -> fetchColumn();
        if(
stripos($type"Pony") !== FALSE){ 
                   switch(
$type){ 
        case 
"Starnight Pony"
        switch(
$gender){
                case 
"f"
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;  
                 }
                 break;       
        default: 
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;
                 }               
                  
$mysidia->db->update("owned_adoptables", array("imageurl" => $imageurl,), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$note "Success! The <b>{$item->itemname}</b> has worked its magic. {$adopt->name} now is using a new color.";
return 
$note;
}
//END Case starnight Pony
       
case "Fire Pony"
        switch(
$gender){
                case 
"f"
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;  
                 }
                 break;       
        default: 
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;
                 }               
                  
$mysidia->db->update("owned_adoptables", array("imageurl" => $imageurl,), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$note "Success! The <b>{$item->itemname}</b> has worked its magic. {$adopt->name} now is using a new color.";
return 
$note;
}
//END Case Fire Pony

        
default: 
        switch(
$gender){
                case 
"f"
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;  
                 }
                 break;       
        default: 
                
$num rand(1,2);
                 switch (
$num) { 
                 case 
1$imageurl "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
                 case 
2$imageurl "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;
                 }               
                  
$mysidia->db->update("owned_adoptables", array("imageurl" => $imageurl,), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$note "Success! The <b>{$item->itemname}</b> has worked its magic. {$adopt->name} now is using a new color.";
return 
$note

and this part is where the the image is changed
same as the first stripos this: if(stripos($type, "Pony") !== FALSE){ allows only the adopts that have pony in their type to use the potion
The switch($gender){
case "f": <-- this is used for checking if the adopt is female and give it the selected image, the default one is used for the male.

I combined parts of the codes that kyttias shared with us (gender change potion and shops items)

This part: $num = rand(1,2);
switch ($num) {
is for randomly chose the image the adopt will be using
and lastly:
case 1: $imageurl = "http://yoursitegoeshere.com/picuploads/png/cc956394e43c60dc8df3be2e5557fe40.png"; break;
case 2: $imageurl = "http://yoursitegoeshere.com/picuploads/png/65a41dd82fbcb9a7e269dcbdef7249ec.png"; break;
is where you add the image used for the adopt ^^

It dont matter if you are using the alternate image for the female. once the NULL is replaced with an url image, the adopt will stop using the alternate image and start using the new one.

For this code to fully work you need to edit the class_privateitem
and add
PHP Code:

         case "Skin":
            
$message items_Skin($this$owned_adoptable);
            break; 

and in your database search for adopts_items_function and copy any of the already there functions and change the name for skin and add a small description telling you what the item does.
in this post is the code for reversing the effect of the skin:
http://mysidiaadoptables.com/forum/s...3&postcount=19

i know the names i use for the items are lame, so change it to one that fit with your tastes ^^
Feel Free to change/edit the code so it can fit with your site, you can add more images by adding more case: and changing the rand.

Hope this can be useful for someone ^^


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

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