Thread: Mys 1.3.4 Itemdrop Mod for Mys v1.3.4
View Single Post
  #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,411
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