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!
**Use this version if you're using the Alternate Gender Images mod:
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.
*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:
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:
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:
case "Gender":
$message = items_gender($this, $owned_adoptable);
break;
Last edited: