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:

draugluin 12-10-2012 04:52 AM

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

Hall of Famer 12-10-2012 10:52 AM

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

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

Replace by:

PHP Code:

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


draugluin 12-10-2012 12:34 PM

http://mitglied.multimania.de/draugie/smilies/yess.gif
ok, knowing how to embed this, it's easy. thanks, that's what I wish to have.

Hall of Famer 12-10-2012 12:37 PM

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.

LucasA33 12-11-2012 09:49 AM

What do I type in the drop rate in PHPMYADMIN if I want to give previous monsters the ability?

Hall of Famer 12-11-2012 01:08 PM

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.

Abronsyth 12-16-2012 04:04 PM

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

Hall of Famer 12-17-2012 12:54 AM

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.

Abronsyth 12-18-2012 02:04 PM

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)!

Hall of Famer 12-18-2012 04:28 PM

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.

Abronsyth 01-09-2013 11:07 AM

Ehm, okay, so I installed the files...but when trying to access any of the edited pages this is what I get:
Quote:

Server error
The website encountered an error while retrieving http://www.bellesombres.com/Site/adm...ttings/globals. It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this webpage later.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
And it's only on the settings, admin cp/adopt, and probably when trying to level up too.

Hall of Famer 01-09-2013 04:21 PM

umm this is weird, you should get an internal server error no matter how the script goes wrong. Are you sure this only happened after you installed the Mod?

Abronsyth 01-10-2013 08:14 AM

Yep, and only on the pages that the mod altered. I'm going to revert the files back to the originals just to see if that clears the problem up...maybe I'll have to try a manual install...

Hall of Famer 01-11-2013 03:55 PM

I see, so does it clear the problem if you revert the script file back to the original? If not, there's probably something wrong with the CMD of the file you download.

Abronsyth 01-12-2013 08:37 AM

I reverted the files back to the originals and it all is now working perfectly, so my guess is that there's something wrong with the files you have available for download.

Abronsyth 01-26-2013 08:15 AM

Okay, Hofster, I'm getting an error when trying to add the column
Code:

droprate
to cost in phpmyadmin. The problem is that when I try to set the default, I select "As Defined:" and then put in "0". However, it's saying that it's invalid.

EDIT:
Okay, so I got it to work but I had to add each column individually.

EDIT:
Whoo! Went through and did it all manually and now it appears to be working! I'll be testing it out soon :)

Hwona 03-09-2013 10:52 PM

Quick question: how do you edit the drop rate through the ACP?

Hall of Famer 03-09-2013 10:54 PM

Looks like theres no way to edit the droprate in ACP once it is set, you need to use PHPmyadmin. The ACP for adoptables and adoptable levels aint good enough atm, it will be changed in future.

Missy Master 03-11-2013 09:44 AM

reading through I'm not certain if this mod is working alright or not? I really want to try this out, looks fantastic! :) I have the latest version of Mysid installed!

Abronsyth 03-11-2013 02:44 PM

It works perfectly if you add it in manually, but for some reason just adding the files didn't work...so just do it manually and yep, it'll work! It is a lovely mod and it's very easy to customize it! I customized it to show a box under the adoptable saying "What's This?" and showing the image of the item and the text "It looks like you found a ITEMNAME!" which is pretty cool :)


All times are GMT -5. The time now is 05:21 PM.

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