View Single Post
  #36  
Old 04-03-2017, 10:17 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,459
kristhasirah
Default

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 ^^

Last edited by kristhasirah; 04-03-2017 at 10:20 AM.
Reply With Quote