Mys 1.3.2 Itemdrop Mod for Mys v1.3.2

Forum
Last Post
Threads / Messages

Hall of Famer

Administrator
Staff member
Administrator
Joined
Dec 15, 2008
Messages
4,564
Points
48
Location
United States
Mysidian Dollar
214,223
Well I've decided to take a break from working on Mys v1.3.3's GUI system, and instead I ended up with this plugin. It is called Itemdrop, which allows your user to gain random items by clicking on pets. This way it motivates them to exchange clicks more than simply leveling up. This feature is only available for members, guests wont get items however they try.

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.

So if you have just completed a fresh installation of Mys v1.3.2, you may just download the compressed .rar file in this thread. Upload the files to their corresponding directories. Run the install_itemdrop.php script once and ONLY ONCE, and you are good to go.

If you have modified your levelup.php and admincp/adopt.php, however, you will have to install this Mod manually. Its quite simple though, I will show you how to do this step by step:


Step 1:
Go to PHPMyadmin, in table prefix.adoptables, add the two following columns after cost:
PHP:
dropitem, varchar(100), default NULL;
droprate, int(11), default 0;
Step 2:
Open admincp/adopt.php, find this section of code:
PHP:
<p>The alternate outcome has a chance of 1 in <input name='altchance' type='text' id='altchance' size='6' maxlength='6'>of being selected.<br />
                                   (Here you can select the chance that the alternate images for this adoptable are used. 
                                   So, for an equal chance of using say male or female images, put 2 in the box to have a 1 out of 2 or 50% chance of using the alternate image. 
                                   If you want to have the alternate images be rare images, use a higher number, 
                                   like 100 for a 1 out of 100 chance of using the alternates.)</p></fieldset>
add below:
PHP:
<fieldset><legend>Item Drop Settings</legend>
                                   <p>Items dropped by clicking this adopt: (if multiple items are possible, separate them by comma)</p>
                                   <input name='dropitem' type='text' id='dropitem'></p>
                                   <p>Items dropped rate: (must be somewhere between 0 and 100)
                                   <p><input name='droprate' type='text' id='droprate'></p></fieldset>
Then browse a little bit up and locate this line:
PHP:
$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")));
replace with:
PHP:
$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")));
Now that we are done with admincp modification, it is time for the real fun. Open the file levelup.php in your adoptables root directory and search for these:
PHP:
         // At the very last, give the user some money for clicking adoptables
         $mysidia->page->settitle("{$lang->gave} {$adopt->name} one {$lang->unit}");
Then add this block of code above these two lines:
PHP:
        // Now let's take care of the itemdrop plugin.
         $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 = '{$adopt->type}'")->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 = "<br>Congratulations, you have acquired an item {$actualitem} by clicking this adoptable.";
                 }
                 else $dropstatus = "<br>Unfortunately no item is dropped from this adoptable this time, you have to try something else.";
             }    
         }
You are getting close, now locate this very line of code near the bottom of levelup.php:
PHP:
         $mysidia->page->addcontent("<div align='center'><br />You have earned {$reward} {$mysidia->settings->cost} for leveling up this adoptable. <br />You now have {$mysidia->user->getcash()} {$mysidia->settings->cost}</div>");
Add below:
PHP:
if($candrop == "yes") $mysidia->page->addcontent($dropstatus);
At the very last, insert a row into table prefix.acp_hooks. This can be done in PHPMyadmin, or you can download the script file install_itemdrop.php and executes it on your site.

PHP:
"id" => NULL, 
"linktext" => "Item Drop Plugin v1.3.2 by Hall of Famer", 
"linkurl" => "http://www.mysidiaadoptables.com/forum/showthread.php?p=25214", 
"pluginname" => "itemdrop", 
"pluginstatus" => 1
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.

Hall of Famer
 

Attachments

  • itemdrop mod v1.3.2.rar
    10.9 KB · Views: 18
Wow you were quick, I hadnt even finished uploading the files and you already posted a reply lol. Good luck using this Mod though, dont overdo it or you may end up killing the fun for your members.
 
Yea, when I saw you making this, I was like:
"omahgawd it's something i've always wanted on my site".

I haven't even configured it yet. :ohnoes:
 
Oh great, glad it actually could be of some help for certain people. I actually tried it on a beta site with fresh installation, it worked as nice as a charm. Not sure with Mys v1.3.1 upgraded site though, hopefully it will run smoothly.
 
I'm currently getting this error:
Fatal error: Uncaught exception 'Exception' with message 'Database error 1054 - Unknown column 'droprate' in 'field list'' in /home/mineedit/public_html/game/classes/class_database.php:161 Stack trace: #0 /home/mineedit/public_html/game/classes/class_database.php(81): Database->_query('adoptables', Array, 'select', 'type = 'Meowly'') #1 /home/mineedit/public_html/game/levelup.php(72): Database->select('adoptables', Array, 'type = 'Meowly'') #2 {main} thrown in /home/mineedit/public_html/game/classes/class_database.php on line 161
 
You need to add the column droprate to the table prefix.adoptables, it is the very last column after cost and dropitem.
 
Did you run the install_itemdrop.php script? If not, you may give a try. If that doesnt work, go to phpmyadmin and table prefix.adoptables. You can add new columns there.
 
I ran the script the first time, guess it didn't add it.
Well, I added it manually, and it works.

Thank you.:veeee:
 
great script. Thank you :)

is it possible, to show the image of the item ? I will give a rare item, which is not buyable, and it would be nice, if they see, what they get :)
 
Last edited:
umm you mean the image of the item when the user receives it? Sure its doable and should be relatively simple to accomplish. If you have installed the script, find this line in levelup.php:

PHP:
$dropstatus = "<br>Congratulations, you have acquired an item {$actualitem} by clicking this adoptable.";

Replace by:

PHP:
$dropstatus = "<br>Congratulations, you have acquired an item {$newitem->itemname} by clicking this adoptable.<br><img src='{$newitem->imageurl}'>";
 
yess.gif

ok, knowing how to embed this, it's easy. thanks, that's what I wish to have.
 
Oh great, glad it helps out one more person. Good luck using it, but again do not overdo it or you can kill the fun with a high droprate of rare items.
 
What do I type in the drop rate in PHPMYADMIN if I want to give previous monsters the ability?
 
Well I think you can give a droprate to your adoptables in ACP by editing them? If you dont know how to do that, you sure can accomplish the same thing in PHPmyadmin. The droprate should be somewhere between 0 to 100.
 
Would it be possible to make a mod where users can randomly find items while exploring the pages of the site..? Of course, not on every page...but maybe every 10 minutes or so..? Or just at random..?

Of course this mod is very helpful...but not quiiiiiiitttteeeeee....
 
Well this is gonna be quite difficult, will require a complete redesign of the page system. Of course by Mys v1.4.x you can expect a much more advanced reward system, in which you can specify rewards for users clicking pets, visiting pages, purchasing certain goods, and maybe more. Not sure when I will be doing this though, it may be a feature for Mys v1.4.0, v1.4.1 or later.
 
Ah, I see. Sounds good :) Haha, I need to set aside some time some day to learn PHP (and by some time I mean years)!
 
Thanks, I'm telling you that learning PHP can be a fun experience, its easy to get started but to become a true expert it takes a huge amount of time.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,278
Messages
33,127
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top