Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Mys v1.3.x Mods (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=42)
-   -   Mys v1.3.4 Itemdrop Mod for Mys v1.3.4 (http://www.mysidiaadoptables.com/forum/showthread.php?t=4362)

Hall of Famer 01-25-2014 09:37 AM

Itemdrop Mod for Mys v1.3.4
 
1 Attachment(s)
Another Mod I decided to revise for Mys v1.3.4 is this Itemdrop Mod, which should be perfectly compatible with the new version. With this plugin, users have a chance to get a specific item by clicking on a certain species of adoptable. It may help with users exchange clicks, but do not abuse this feature so users get way too many important items.

You can assign either one or multiple items to an adoptables species, which will drop items based on their item drop-rate. For instance, if an adoptable has drop-rate of 30, your user will have 30% chance to get an item by clicking on this pet. If you assign two or three items to this species, each of them will have 15% or 10% chance to come out. Unfortunately there's no way to 'discriminate' among items for a given adoptable, a probability system is way too complicated for me to work with at this point.

Assuming you have a fresh installation of Mys v1.3.4, you can simply download the .rar files I upload myself, then go to /install/genderratio.php to execute the file to install the Mod. If your site is heavily customized, you'd have to install manually, which should not be difficult anyway. The manual installation steps are explained as below:


To begin with, insert two columns in table prefix.adoptables:
PHP Code:

dropitemvarchar(100), default NULL;
droprateint(11), default 10

Next, open /admincp/view/adoptview.php on your server and find the following lines:
PHP Code:

        $adoptForm->add(new Button("Create this Adoptable""submit""submit"));
        
$document->add($adoptForm); 

Replace them with:
PHP Code:

        $itemdrop = new FieldSetBuilder("Item Drop Settings");
        
$itemdrop->add(new Comment("Items dropped by clicking this  adopt: (if multiple items are possible, separate them by comma)"));
        
$itemdrop->add(new TextField("dropitem"));
        
$itemdrop->add(new Comment("Items dropped rate: (must be somewhere between 0 and 100"));
        
$itemdrop->add(new TextField("droprate"));
        
$adoptForm->add($itemdrop);
        
$adoptForm->add(new Button("Create this Adoptable""submit""submit"));
        
$document->add($adoptForm); 

This should make the itemdrop field to appear in ACP, still we need to find a way to insert values for the two new columns in your database table. Open file /admincp/adopt.php and find the SQL insert query for prefix.adoptables at:
PHP Code:

            $mysidia->db->insert("adoptables", array("id" =>  NULL"type" => $mysidia->input->post("type"), "class" =>  $mysidia->input->post("class"), "description" =>  $mysidia->input->post("description"), "eggimage" => $eggimage,  "whenisavail" => $mysidia->input->post("cba"),
                                                     
"alternates" =>  $mysidia->input->post("alternates"), "altoutlevel" =>  $mysidia->input->post("altoutlevel"), "altchance" =>  $mysidia->input->post("altchance"), "shop" =>  $mysidia->input->post("shop"), "cost" =>  $mysidia->input->post("cost"))); 

And again replace this chunk of code with:
PHP Code:

            $mysidia->db->insert("adoptables", array("id" =>  NULL"type" => $mysidia->input->post("type"), "class" =>  $mysidia->input->post("class"), "description" =>  $mysidia->input->post("description"), "eggimage" => $eggimage,  "whenisavail" => $mysidia->input->post("cba"), "alternates"  => $mysidia->input->post("alternates"), 
                                                     
"altoutlevel" =>  $mysidia->input->post("altoutlevel"), "altchance" =>  $mysidia->input->post("altchance"), "shop" =>  $mysidia->input->post("shop"), "cost" =>  $mysidia->input->post("cost"), "dropitem" =>  $mysidia->input->post("dropitem"), "droprate" =>  $mysidia->input->post("droprate"))); 

We are now done with /admincp/adopt.php. It is time to open levelup.php and finish up our tasks. At levelup.php, find the following lines:
PHP Code:

            if($this->adopt->hasNextLevel()){
                
$nextLevel $this->adopt->getNextLevel();
                
$requiredClicks $nextLevel->getRequiredClicks();
                if(
$requiredClicks and $newClicks >= $requiredClicks$this->adopt->setCurrentLevel($nextLevel->getLevel(), "update");
            } 

Add below:
PHP Code:

            $plugin $mysidia->db->select("acp_hooks", array(), "pluginname = 'itemdrop' and pluginstatus = 1")->fetchObject();
            if(
$mysidia->user instanceof Member and is_object($plugin)){
                
$item $mysidia->db->select("adoptables", array("dropitem""droprate"), "type = '{$this->adopt->getType()}'")->fetchObject();
                if(!empty(
$item->dropitem) and $item->droprate 0){
                    
$candrop "yes";
                    
$droprand mt_rand(099);
                    if(
$droprand $item->droprate){
                        
// Item has dropped, now process the event!
                        
$itemrand explode(","$item->dropitem);
                        
$num count($itemrand);

                        if(
count($itemrand) == 1$actualitem $itemrand[0];
                        else{
                            
$actualrand mt_rand(0$num 1);
                            
$actualitem $itemrand[$actualrand];
                        }

                        
$newitem = new StockItem($actualitem1);
                        
$newitem->assign($mysidia->user->username);
                        
$newitem->append(1); 
                        
$dropstatus = new Integer(1);
                    }
                }    
            }

            
$this->setField("dropstatus", ($dropstatus)?$dropstatus:new Integer(0)); 

Then open your /view/levelupview.php file and find the following lines:
PHP Code:

        $summary = new Division;
        
$summary->setAlign(new Align("center"));
        
$summary->add($image);    
        
$summary->add(new Comment("{$this->lang->gave}{$adopt->getName()} one {$this->lang->unit}."));
        
$summary->add(new Comment($this->lang->encourage));
        
$summary->add(new Comment("<br> You have earned {$reward} {$mysidia->settings->cost} for leveling up this adoptable. "));
        
$summary->add(new Comment("You now have {$mysidia->user->getcash()} {$mysidia->settings->cost}")); 

And again add the code right below the above lines:
PHP Code:

        $dropstatus $this->getField("dropstatus")->getValue();
        if(
$dropstatus == 1$document->addLangvar("<br>Congratulations, you have acquired an item by clicking this adoptable, check your inventory to see what it is!"); 
        else 
$document->addLangvar("<br>Unfortunately no item is dropped from this adoptable this time, you have to try something else."); 

At the very last, do not forget to insert a row into the table prefix.acp_hooks, the row should look like this below:
PHP Code:

"id" => NULL
"linktext" => "Item Drop Plugin v1.3.4 by Hall of Famer"
"linkurl" => "http://www.mysidiaadoptables.com/forum/showthread.php?t=4362"
"pluginname" => "itemdrop"
"pluginstatus" => 

Well done, it is just so simple isnt it? Congratulations, you have now added an interesting tiny little feature to your site. Hopefully your members will love it, although you need to be careful with the drop-rate of each adoptable. To low drop-rate frustrates your members, while too high drop-rate makes this entire thing pointless. Good luck.

squiggler 01-25-2014 01:43 PM

This is beautiful! I love it! Question, though- do they need to be the pre-set usable items, or can they be collectibles (no function, just pretty)? If the former, is there an easy way to modify this? Thanks in advance for your time.

Hall of Famer 01-25-2014 03:07 PM

Well of course you need to create these items in ACP first, but they can be something like key items or valuable items that do not serve any purpose other than collectibles.

squiggler 01-25-2014 08:09 PM

Thank you! I shall try it out and let you know if anything goes wrong how it goes! XD

Edit: What are those table prefixes you mention?
Quote:

To begin with, insert two columns in table prefix.adoptables:
PHP Code:
dropitem, varchar(100), default NULL;
droprate, int(11), default 10;
Quote:

At the very last, do not forget to insert a row into the table prefix.acp_hooks, the row should look like this below:
PHP Code:
"id" => NULL,
"linktext" => "Item Drop Plugin v1.3.4 by Hall of Famer",
"linkurl" => "http://www.mysidiaadoptables.com/forum/showthread.php?t=4362",
"pluginname" => "itemdrop",
"pluginstatus" => 1
Neither are in my file manager.

Hall of Famer 01-25-2014 11:44 PM

table prefix is the prefix applied to your table, lol I know I am not good at explaining this thing. One example is adopt_, which is the default table prefix is you do not specify any.

squiggler 01-26-2014 04:16 AM

Where would I find it? In the file manager? Or...phpMyAdmin? If I go to that, it won't let me add simple text. This is what it looks like: http://i44.tinypic.com/123kxi1.png
I added what options the menu gives me to the side. I have absolutely no idea how to add columns with this system. It's very unfriendly.

Hall of Famer 01-26-2014 04:34 AM

Did you notice that all your database tables start with the same sequence of characters? From the look of your database, the prefix is adopts_

LucasA33 03-15-2014 02:20 AM

I'm getting an error:
Fatal error: Call to a member function getValue() on a non-object in /home/lucasa33/public_html/ranch/view/levelupview.php on line 24

This is my code:
Code:

p

use Resource\Collection\ArrayList;
use Resource\Utility\Curl;

class LevelupView extends View{
       
        public function click(){
            $mysidia = Registry::get("mysidia");
                $document = $this->document;                               
        $adopt = $this->getField("adopt");                       
                $reward = $this->getField("reward")->getValue();
                $document->setTitle("{$this->lang->gave} {$adopt->getName()} one {$this->lang->unit}");

                $image = $adopt->getImage("gui");       
                $image->setLineBreak(TRUE);               
                $summary = new Division;
                $summary->setAlign(new Align("center"));
        $summary->add($image);       
        $summary->add(new Comment("{$this->lang->gave}{$adopt->getName()} one {$this->lang->unit}."));
        $summary->add(new Comment($this->lang->encourage));
        $summary->add(new Comment("<br> You have recieved {$reward} {$mysidia->settings->cost} from the owner of the ranch animal!  "));
        $summary->add(new Comment("You now have {$mysidia->user->getcash()} {$mysidia->settings->cost}"));
        $dropstatus = $this->getField("dropstatus")->getValue();
        if($dropstatus == 1) $document->addLangvar("<br>Congratulations, you have acquired an item by clicking this adoptable, check your inventory to see what it is!");
        else $document->addLangvar("<br>Unfortunately no item is dropped from this adoptable this time, you have to try something else.");         
        $document->add($summary);

Line 24 is
Code:

        $dropstatus = $this->getField("dropstatus")->getValue();
This is my levelup.php file around where I pasted the code I needed to:
Code:

                    $newClicks = $this->adopt->getTotalClicks() + 1;
                        $this->adopt->setTotalClicks($newClicks, "update");
                $mysidia->db->insert("vote_voters", array("void" => NULL, "date" => $date->format('Y-m-d'), "username" => $mysidia->user->username, "ip" => $ip, "adoptableid" => $mysidia->input->get("aid")));               
                       
                        if($this->adopt->hasNextLevel()){
                    $nextLevel = $this->adopt->getNextLevel();
                                $requiredClicks = $nextLevel->getRequiredClicks();
                    if($requiredClicks and $newClicks >= $requiredClicks) $this->adopt->setCurrentLevel($nextLevel->getLevel(), "update");
                }
            $plugin = $mysidia->db->select("acp_hooks", array(), "pluginname = 'itemdrop' and pluginstatus = 1")->fetchObject();
            if($mysidia->user instanceof Member and is_object($plugin)){
                $item = $mysidia->db->select("adoptables", array("dropitem", "droprate"), "type = '{$this->adopt->getType()}'")->fetchObject();
                if(!empty($item->dropitem) and $item->droprate > 0){
                    $candrop = "yes";
                    $droprand = mt_rand(0, 99);
                    if($droprand < $item->droprate){
                        // Item has dropped, now process the event!
                        $itemrand = explode(",", $item->dropitem);
                        $num = count($itemrand);

                        if(count($itemrand) == 1) $actualitem = $itemrand[0];
                        else{
                            $actualrand = mt_rand(0, $num - 1);
                            $actualitem = $itemrand[$actualrand];
                        }

                        $newitem = new StockItem($actualitem, 1);
                        $newitem->assign($mysidia->user->username);
                        $newitem->append(1);
                        $dropstatus = new Integer(1);
                    }
                }   
            }

            $this->setField("reward", ($dropstatus)?$dropstatus:new Integer(0)); 
                       
                        $reward = $mysidia->user->clickreward($this->settings->reward);
                    $mysidia->user->changecash($reward);                       
            $this->setField("adopt", $this->adopt);
            $this->setField("reward", new Integer($reward));

I wonder if it is because I didn't give any of the animals a rate and item to drop yet.

IntoRain 03-15-2014 02:20 PM

Maybe the first setField in levelup.php is supposed to be dropstatus and not reward?

$this->setField("reward"(here), ($dropstatus)?$dropstatus:new Integer(0));
$reward = $mysidia->user->clickreward($this->settings->reward);
$mysidia->user->changecash($reward);
$this->setField("adopt", $this->adopt);
$this->setField("reward", new Integer($reward));

LucasA33 03-16-2014 06:41 PM

Quote:

Originally Posted by IntoRain (Post 29367)
Maybe the first setField in levelup.php is supposed to be dropstatus and not reward?

$this->setField("reward"(here), ($dropstatus)?$dropstatus:new Integer(0));
$reward = $mysidia->user->clickreward($this->settings->reward);
$mysidia->user->changecash($reward);
$this->setField("adopt", $this->adopt);
$this->setField("reward", new Integer($reward));

I didn't modify that at all, which is why I am afraid to touch that. I did notice that even after doing what the guide told me with the ACP Hooks:
http://i.imgur.com/8grEFWu.png

I get this in the ACP:
http://i.imgur.com/jx9dDbH.png

IntoRain 03-16-2014 06:51 PM

Quote:

Originally Posted by LucasA33 (Post 29371)
I didn't modify that at all, which is why I am afraid to touch that. I did notice that even after doing what the guide told me with the ACP Hooks:
http://i.imgur.com/8grEFWu.png

I get this in the ACP:
http://i.imgur.com/jx9dDbH.png

I just find it weird that a getField() for dropstatus is done in levelupview.php, without a setField() being done in levelup.php to give a value to dropstatus, while in levelup.php there are two setFields() for reward, so one overwrites the other x.x Better wait for HoF's input then

LucasA33 03-24-2014 10:14 PM

Still can't seem to get it working. :mii:

Hall of Famer 03-25-2014 08:32 AM

umm are you using Mys v1.3.4? And have you modified your script heavily before installing this mod? If it turns out to be a glitch in the mod I will make sure to take good care of it.

LucasA33 03-28-2014 11:42 PM

So now after a fresh project site, and installation of Alchemy and Item Drops, the adoptable creation screen forms appear twice. I'm trying to locate why it is doing this but no luck so far.

http://i.imgur.com/dBG8Kde.png

IntoRain 03-29-2014 07:29 AM

Whats the contents of your /admincp/view/adoptview.php? You might have a duplicate document->add(adoptform)

Hall of Famer 03-29-2014 08:23 AM

Quote:

Originally Posted by LucasA33 (Post 29432)
So now after a fresh project site, and installation of Alchemy and Item Drops, the adoptable creation screen forms appear twice. I'm trying to locate why it is doing this but no luck so far.

http://i.imgur.com/dBG8Kde.png

If the form appears twice, chances are you did not follow the installation guide properly. When I said replace by the code block below, you probably have instead added the code below the lines but did not replace them.

LucasA33 03-29-2014 02:13 PM

But I did a automatic install, not a manual.
Secondly, feeding an adopt with the script makes a blank page, much like when I did it manually before.

Hall of Famer 03-30-2014 01:44 PM

I see, alright I will look into it and see where the bug may be. The mod does work well with Mys v1.3.3, I thought there would be a simple way to port it to Mys v1.3.4 but maybe I underestimated the difficulty. Thanks for reporting it, btw.

squiggler 05-28-2014 10:16 PM

So, I'm pretty sure I followed the guide correctly with the manual install. It seems to work just fine until you go to your inventory. The items just don't appear. Thank you for your help.

LucasA33 06-01-2014 01:19 AM

It's weird we are getting different results.. I still get the blank page.. Can you please open phpmyadmin and tell me if the items exist there?

squiggler 06-01-2014 01:15 PM

Okay, went to adopts_inventory and it only said my cherries were there. In adopts_items, it has all 3 items listed. These are the values:
Full texts id category itemname description imageurl function target value shop price chance cap tradable consumable
2 valuable Raw Sapphire A beautiful blue stone. URL Valuable all 0 Toris Trinkets 100 100 99 yes NULL
3 valuable Ring A ring. URL Valuable all 0 Toris Trinkets 10 100 99 yes NULL
4 click Cherry A delicious cherry. Gives 25 clicks to your adopta... URL Click1 all 25 Toris Trinkets 25 100 99 yes yes

LucasA33 06-01-2014 03:45 PM

Yeah, that is strange. Maybe HoF can help you out further

Hall of Famer 06-03-2014 02:11 PM

So you are saying that the items are in your inventory when you go to phpmyadmin database but just somehow aint showing up on the site? Or did I misunderstand? I think posting the entries in your adopts_inventory table will be more helpful than adopts_items.

squiggler 06-03-2014 06:59 PM

They never get added to the inventory, it seems.
iid category itemname owner quantity status
3 click Cherry ToriandLori 97 Available

In fact, I just tried to click 2 adoptables, and it said I shoulda gotten them, but I didn't.

Missy Master 06-27-2014 09:44 PM

Whatever happened with this? Is it working for most people? I am launching four Pet sites on the 4th, and would love to include this but I don't want to mess up what I have ...

it looks like a lot of fun to use!!

Is this working ok now ?

Hall of Famer 06-27-2014 10:38 PM

It seems that some people are having trouble with it, as the items aint added to their inventory. I dunno why it happens though, but I can give a try troubleshooting it for the next 2-4 days.

squiggler 06-28-2014 03:37 PM

Thank you for working on it. If you need access to my files to do it, just ask!

Missy Master 06-28-2014 03:55 PM

Great!! Thanks HOF :)

Hall of Famer 06-29-2014 03:18 AM

Quote:

Originally Posted by squiggler (Post 30353)
Thank you for working on it. If you need access to my files to do it, just ask!

Oh sure, Id love to test it with a live site like yours. You can PM me the FTP information if you dont mind. ^^

Hall of Famer 07-03-2014 03:11 AM

I've fixed Squiggler's problem, it seems that there is a minor error I made for manual installation. This line:

PHP Code:

$this->setField("reward", ($dropstatus)?$dropstatus:new Integer(0)); 

should be:

PHP Code:

$this->setField("dropstatus", ($dropstatus)?$dropstatus:new Integer(0)); 

A typo, but significant enough to stop the mod from working. Also Squiggler made an error in the manual installation as well, perhaps I did not explain very well myself. When you add this row to table prefix.acp_hooks, for string columns please do not enter the double quotes and instead only enter the alphanumeric values. MySQL is not PHP, strings are not enclosed by double or single quotes. Note "Itemdrop"(with double quotes) and Itemdrop(without quotes) are different values for a mysql column, it will stop the mod from working.

PHP Code:

"id" => NULL
"linktext" => "Item Drop Plugin v1.3.4 by Hall of Famer"
"linkurl" => "http://www.mysidiaadoptables.com/forum/showthread.php?t=4362"
"pluginname" => "itemdrop"
"pluginstatus" => 

Hope this helps, and note you should not encounter this issue if you simply download the script files and use automatic installer, it only affects manual installations.

squiggler 07-03-2014 05:36 AM

Thank you so much! This really helps me out! I just tried it and if gave me 3 Rings (total)!

Missy Master 07-07-2014 02:37 PM

Did the Install ( not manual ) and now it white pages when I go to levelup ...

it never created the tables so I did that on my own.

ilrak 09-22-2014 02:37 PM

Hi! I thought I had gone through the manual install correctly, but I seem to be having an issue. I created an adoptable who will drop some items, so I went to test it out and when I click to level up the adoptable, I get this error.

Quote:

Parse error: syntax error, unexpected '$dropstatus' (T_VARIABLE), expecting function (T_FUNCTION) in /home/auratusg/public_html/view/levelupview.php on line 26
This is what my line 26 looks like:

Quote:

$dropstatus = $this->getField("dropstatus")->getValue();
Not too sure what I should have in place of the unexpected drop status

IntoRain 09-22-2014 05:50 PM

Quote:

Originally Posted by ilrak (Post 31151)
Hi! I thought I had gone through the manual install correctly, but I seem to be having an issue. I created an adoptable who will drop some items, so I went to test it out and when I click to level up the adoptable, I get this error.



This is what my line 26 looks like:



Not too sure what I should have in place of the unexpected drop status

Might be an error in the line before (missing semicolon etc.), what's line 25 like?

ilrak 09-22-2014 06:41 PM

Line 25 is just:
Quote:

}
With Line 24 being

Quote:

$document->add($summary);
EDIT: I fixed it! I had to do some deleting and such, but now it works!

Ittermat 03-02-2016 06:38 PM

Is there a way to add some code to make you able to change the items dropped by pets without having to remake the entire pet/levels in the edit pet area?

also a way to make it so clicking on pets from before this mod dont get errors? Everytime I click on a pet I created before adding itemdrop I get this- on a blank page.

Fatal error: Call to a member function getValue() on null in /home/atrocity/public_html/view/levelupview.php on line 12

Hall of Famer 03-09-2016 03:58 PM

There is a glitch in the .rar file I uploaded in the first post, in the file levelup.php. It results in a fatal error when you click an adoptable that you havent clicked before, showing that a value is null when it cannot be null.

I've reuploaded a new version of the .rar file, it should fix the problem. Note this only affects users who choose automatic installation(directly download the .rar file to replace their original files fully). If you follow the guideline for manual installation(copy/paste code from first post), you should be unaffected by this glitch.

Suzanne 06-14-2016 07:06 PM

Works perfectly! Thank you for directing me to the correct thread.

Hall of Famer 06-14-2016 11:11 PM

You are very welcome, all mods made by myself are ported into each different versions for Mys v1.3.x. So if you see a mod for Mys v1.3.3 made by Hall of Famer, you can be sure a similar version for Mys v1.3.4 exists.

Fox 10-09-2016 07:22 PM

For someone rather foreign to coding, can someone please explain how to install this mod? I have the latest script, do I need to go into phpMyAdmin? Can someone explain what to do from there?


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

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