Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.3.x Mods

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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,500
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
 

Tags
change, gender, genders, item functions, items


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
Help with a item function kristhasirah Questions and Supports 35 04-03-2017 10:17 AM
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
Change Cash Function? Hwona Questions and Supports 2 07-14-2014 02:00 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 03:14 PM.

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