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.2 Itemdrop Mod for Mys v1.3.2 (http://www.mysidiaadoptables.com/forum/showthread.php?t=3903)

Hall of Famer 12-09-2012 02:25 AM

Itemdrop Mod for Mys v1.3.2
 
1 Attachment(s)
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 Code:

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

Step 2:
Open admincp/adopt.php, find this section of code:
PHP Code:

<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 imagesput 2 in the box to have a 1 out of 2 or 50chance 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 Code:

<fieldset><legend>Item Drop Settings</legend>
                                   <
p>Items dropped by clicking this adopt: (if multiple items are possibleseparate 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 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"))); 

replace 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"))); 

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 Code:

         // 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 Code:

        // 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(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 "<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 Code:

         $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 Code:

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 Code:

"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" => 

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

LucasA33 12-09-2012 02:26 AM

This is completely what I have been looking for!
Thanks! :)

Hall of Famer 12-09-2012 02:30 AM

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.

LucasA33 12-09-2012 01:32 PM

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:

Hall of Famer 12-09-2012 01:34 PM

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.

LucasA33 12-09-2012 08:27 PM

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

Hall of Famer 12-09-2012 08:28 PM

You need to add the column droprate to the table prefix.adoptables, it is the very last column after cost and dropitem.

LucasA33 12-09-2012 08:32 PM

How do I do that :C

Hall of Famer 12-09-2012 08:48 PM

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.

LucasA33 12-09-2012 09:10 PM

I ran the script the first time, guess it didn't add it.
Well, I added it manually, and it works.

Thank you.:veeee:


All times are GMT -5. The time now is 04:35 AM.

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