Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.3.x Mods

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2014, 09:37 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 327,421
Hall of Famer is on a distinguished road
Default Itemdrop Mod for Mys v1.3.4

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.
Attached Files
File Type: rar Itemdrop Mod v1.3.4.rar (8.9 KB, 9 views)
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #2  
Old 01-25-2014, 01:43 PM
squiggler's Avatar
squiggler squiggler is offline
Squiggling since 1995
 
Join Date: Jul 2013
Posts: 185
Gender: Unknown/Other
Credits: 8,101
squiggler is on a distinguished road
Default

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.
__________________
Avatar courtesy of Doll Divine.
Reply With Quote
  #3  
Old 01-25-2014, 03:07 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 327,421
Hall of Famer is on a distinguished road
Default

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


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #4  
Old 01-25-2014, 08:09 PM
squiggler's Avatar
squiggler squiggler is offline
Squiggling since 1995
 
Join Date: Jul 2013
Posts: 185
Gender: Unknown/Other
Credits: 8,101
squiggler is on a distinguished road
Default

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.
__________________
Avatar courtesy of Doll Divine.

Last edited by squiggler; 01-25-2014 at 10:29 PM. Reason: *clueless*
Reply With Quote
  #5  
Old 01-25-2014, 11:44 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 327,421
Hall of Famer is on a distinguished road
Default

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


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #6  
Old 01-26-2014, 04:16 AM
squiggler's Avatar
squiggler squiggler is offline
Squiggling since 1995
 
Join Date: Jul 2013
Posts: 185
Gender: Unknown/Other
Credits: 8,101
squiggler is on a distinguished road
Default

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.
__________________
Avatar courtesy of Doll Divine.
Reply With Quote
  #7  
Old 01-26-2014, 04:34 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 327,421
Hall of Famer is on a distinguished road
Default

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_
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #8  
Old 03-15-2014, 02:20 AM
LucasA33's Avatar
LucasA33 LucasA33 is offline
Member
 
Join Date: Jul 2011
Posts: 144
Gender: Male
Credits: 12,241
LucasA33 is on a distinguished road
Default

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.
__________________
Reply With Quote
  #9  
Old 03-15-2014, 02:20 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 19,257
IntoRain is on a distinguished road
Default

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


asp.net stole my soul.
Reply With Quote
  #10  
Old 03-16-2014, 06:41 PM
LucasA33's Avatar
LucasA33 LucasA33 is offline
Member
 
Join Date: Jul 2011
Posts: 144
Gender: Male
Credits: 12,241
LucasA33 is on a distinguished road
Default

Quote:
Originally Posted by IntoRain View Post
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:


I get this in the ACP:
__________________
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mys v1.3.3 Itemdrop Mod for Mys v1.3.3 Hall of Famer Mys v1.3.x Mods 8 06-14-2016 04:50 PM
Mys v1.3.2 Itemdrop Mod for Mys v1.3.2 Hall of Famer Mys v1.3.x Mods 29 03-11-2013 02:44 PM


All times are GMT -5. The time now is 10:27 AM.

Currently Active Users: 371 (0 members and 371 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636