Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 07-23-2013, 12:07 AM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 58,172
Hwona is on a distinguished road
Default Item Function Is Invalid

Hello, I was thinking about trying to make a new item function, but whenever I try to use an item, it says the item function is invalid. Can someone help or point me in the right direction? :3

Yes, I created a new row in adopts_items_functions.

Here's the code:
PHP Code:
function items_genderf($item$adopt){
        
$mysidia Registery:: get("mysidia");
        
//Let's check if the adoptable is already female.
        
$gender $mysidia -> db -> select ("gender") -> fetchObject();
        if(
$gender "f") {
            
//The adoptable is already female
            
$note "Your adoptable is already female.";
        }
        else{
            
//The adoptable is male. It's gender can be switched to female.
            
switch($adopt->gender){
                case 
"f":
                    
$mysidia -> db -> update("owned_adoptables", array("gender" => 'f'),"aid='{$adopt->aid}' and owner ='{$item->owner}'");
                    
$note "Your adoptable {$adopt->name} is now female.";
            }
            
//Update item quantity...
            
$delitem $item->remove();
        }
        return 
$note;
        } 
It's suppossed to plug into the existing functions_items script, so I didn't include the php tags.

Last edited by Hwona; 07-23-2013 at 10:29 AM.
Reply With Quote
  #2  
Old 07-23-2013, 03:46 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 488,519
Hall of Famer is on a distinguished road
Default

Are you sure the function name matches the naming convention? Take a screenshot from PHPMyadmin and I will see how to help you.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #3  
Old 07-23-2013, 03:49 PM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 58,172
Hwona is on a distinguished road
Default Re

Thanks - taking pic... I thought it would be more like an issue with the code.

Edit here it is :3:


Last edited by Hwona; 07-23-2013 at 03:55 PM.
Reply With Quote
  #4  
Old 07-23-2013, 03:55 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 488,519
Hall of Famer is on a distinguished road
Default

Well there is indeed an error in your code. This line clearly is not doing the right thing, you aint using the database class properly.

PHP Code:
$gender $mysidia -> db -> select ("gender") -> fetchObject(); 
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #5  
Old 07-23-2013, 03:58 PM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 58,172
Hwona is on a distinguished road
Default Re

Ah thanks! Now if only I knew exactly how to fix it...

From the looks of it, I think I might have to add something like: ... ownedadopt ->... and so on..
But then, another half of me thinks it's suppossed to be something like getgender. :L

Do you mind telling me what I need to tweak.

PHP Code:
$gender $mysidia -> db -> ownedadoptable -> select ("gender") -> fetchObject(); 
Any closer to getting it right?

Last edited by Hwona; 07-23-2013 at 04:38 PM.
Reply With Quote
  #6  
Old 07-24-2013, 12:40 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 488,519
Hall of Famer is on a distinguished road
Default

Well its still incorrect, the syntax should be:

PHP Code:
$gender $mysidia -> db -> select ("owned_adoptables", array("gender"), "aid='{$adopt->aid}' and owner ='{$item->owner}'") -> fetchColumn(); 
Use fetchColumn() if you only want the gender info, but if you wish to pull a collection of information such as type, name, owner and other things out, you can use fetchObject().
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #7  
Old 07-24-2013, 11:13 AM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 58,172
Hwona is on a distinguished road
Default Re

:D thank you so much! So you have to put all that aid stuff there? :3

O.o but it still says the function is invalid. Is there any other problem with the code?

Last edited by Hwona; 07-24-2013 at 11:15 AM.
Reply With Quote
  #8  
Old 07-30-2013, 03:55 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 488,519
Hall of Famer is on a distinguished road
Default

Yeah there is still one more trick you need to apply at least with Mys v1.3.3. Go to the script file class_privateitem.php, find the long switch statement that defines each item function, add yours in the list, and it should be working. In Mys v1.3.4 that will be released in about a week or two, I will make it possible to get the item function name dynamically so you wont have to go through this pain.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #9  
Old 07-30-2013, 06:48 PM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 58,172
Hwona is on a distinguished road
Default

:D Thanks!
- Oh, now it says that the registery doesn't exist. O.o
__________________

Last edited by Hwona; 07-30-2013 at 06:55 PM.
Reply With Quote
  #10  
Old 08-02-2013, 03:46 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 488,519
Hall of Famer is on a distinguished road
Default

Clearly you have misspelled the word registry.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
Reply


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 11:17 AM
Mys v1.3.4 Item Function: Gender Change Potion Kyttias Mys v1.3.x Mods 21 10-12-2016 08:52 PM
Calling a function in a function from the same class page Hwona Questions and Supports 2 04-25-2015 09:41 AM
Item Function Suggestions NobodysHero Suggestions and Feature Requests 5 06-23-2014 04:45 AM


All times are GMT -5. The time now is 03:54 AM.

Currently Active Users: 725 (0 members and 725 guests)
Threads: 4,081, Posts: 32,031, 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