Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Item Function Is Invalid (http://www.mysidiaadoptables.com/forum/showthread.php?t=4209)

Hwona 07-22-2013 11:07 PM

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.

Hall of Famer 07-23-2013 02:46 PM

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

Hwona 07-23-2013 02:49 PM

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

Edit here it is :3:

http://i1290.photobucket.com/albums/...ps2b12a65c.jpg

Hall of Famer 07-23-2013 02:55 PM

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(); 


Hwona 07-23-2013 02:58 PM

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?

Hall of Famer 07-23-2013 11:40 PM

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().

Hwona 07-24-2013 10:13 AM

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?

Hall of Famer 07-30-2013 02:55 PM

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.

Hwona 07-30-2013 05:48 PM

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

Hall of Famer 08-02-2013 02:46 PM

Clearly you have misspelled the word registry.


All times are GMT -5. The time now is 10:53 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.