View Single Post
  #1  
Old 12-09-2014, 11:37 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,392
Kyttias is on a distinguished road
Arrow Item Function: Gender Change Potion

Item Function: Gender Change Potion for Mysidia 1.3.4
*may work for earlier versions, definitely adaptable, but the db update query bit may need some changing - if it looks like other queries in your version, then this works out fine for you!
**and I didn't immediately see this thread, so while this is technically a duplicate, Wallie's was in the Questions and Supports board, and it's good to have this as a mod clearly visible in the mods board


1 - First we will add our function to the database. Open up your database. In the items_functions table, make note of how many rows there are (check out the ifid column for help), hit the word Copy on the row holding the Level1 function. Fill in the first blank with the next number. If you had 13 item functions, this will be 14. The description seen here is mostly for your sake on the admin side of things.



2 - Next we'll add the function into functions/functions_items.php.
This code updated Feb 9, 2015. If you added it prior to this, please update it!
PHP Code:
function items_gender($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$delitem $item->remove();
  
$gender $adopt->gender;
      switch(
$gender){
                case 
"m":                   
                  
$newgender "f";
                  
$newgender_full "girl";
                    break;
                default: 
                  
$newgender "m";
                  
$newgender_full "boy";
            } 
  
$mysidia->db->update("owned_adoptables", array("gender" => $newgender), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "Success! The <b>{$item->itemname}</b> has worked its magic. {$adopt->name} is now a {$newgender_full}.";
  return 
$note;


**Use this version if you're using the Alternate Gender Images mod:
PHP Code:
function items_gender($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$delitem $item->remove();
  
$gender $mysidia -> db -> select ("owned_adoptables", array("gender"), "aid='{$adopt->aid}' and owner ='{$item->owner}'") -> fetchColumn();
        switch(
$gender){
                case 
"m"
                  
$alts "no";
                  
$newgender "f";
                  
$newgender_full "girl";
                    break;
                default: 
                  
$alts "yes";
                  
$newgender "m";
                  
$newgender_full "boy";
            } 
  
$mysidia->db->update("owned_adoptables", array("gender" => $newgender"usealternates" => $alts), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "Success! The <b>{$item->itemname}</b> has worked its magic. {$adopt->name} is now a {$newgender_full}.";
  return 
$note;

3 - With both these steps complete, you can now Create an Item from the Items section in your AdminCP, as the new function will show on the list of item functions. Don't have an image prepared for your item? You may temporarily make use this image for testing purposes:


4 - Before you can use an item, you will need to make one last change inside classes/class_privateitem.php. Inside public function apply is a switch statement containing the list of item functions. Add your new item to this list.
PHP Code:
case "Gender":
            
$message items_gender($this$owned_adoptable);
            break; 
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 02-09-2016 at 10:45 PM.
Reply With Quote