Mys 1.3.x Stat/SKill System

Forum
Last Post
Threads / Messages
^Try this for breeding?:
PHP:
<?php

use Resource\Native\Integer;
use Resource\Native\String;
use Resource\Native\Null;
use Resource\Collection\LinkedList;

class BreedingController extends AppController{

    public function __construct(){
        parent::__construct("member");
		$mysidia = Registry::get("mysidia");		
		$userStatus = $mysidia->user->getstatus();
        if($userStatus->canbreed == "no") throw new NoPermissionException("permission");		
    }
	
	public function index(){
	    $mysidia = Registry::get("mysidia");
		$settings = new BreedingSetting($mysidia->db);
        if($settings->system != "enabled") throw new InvalidActionException("system");
		
	    if($mysidia->input->post("submit")){
		    if($mysidia->input->post("female") == "none" or $mysidia->input->post("male") == "none"){
  			    throw new InvalidIDException("none_select");
			}
			
			try{
			    $female = new OwnedAdoptable($mysidia->input->post("female"), $mysidia->user->username);
				$male = new OwnedAdoptable($mysidia->input->post("male"), $mysidia->user->username);
				$breeding = new Breeding($female, $male, $settings); 
                $validator = $breeding->getValidator("all");
				$validator->validate();
			}
			catch(AdoptNotfoundException $ane){
                throw new InvalidIDException("none_exist");
			}
			catch(BreedingException $bre){                
			    $status = $bre->getmessage();
                $validator->setStatus($status);
			    throw new InvalidActionException($status);
			}
			
			if($settings->method == "advanced") $species = $breeding->getBabySpecies();
			$breeding->getBabyAdopts($species);
			$breeding->breed($adopts);
			$num = $breeding->countOffsprings();
						
			if($num > 0){
			
                $offsprings = $breeding->getOffsprings();
                $offspringID = $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num + 1;
				$statname = rand(0,100);
				$links = new LinkedList;
				$mysidia->db->update("owned_adoptables",array("statname" => $statname),"aid = $offspringID");  
				foreach($offsprings as $offspring){
                    $image = $offspring->getEggImage("gui");
                    $links->add(new Link("myadopts/manage/{$offspringID}", $image));
                    $offspringID++;
                }
				$this->setField("links", $links);
			}
            else $this->setField("links", new Null);
            $this->setField("breeding", $breeding);		
			return;
		}

		$this->setField("cost", new Integer($settings->cost));
		$current = new DateTime;
		$lasttime = $current->getTimestamp() - (($settings->interval) * 24 * 60 * 60);
				
	    $stmt = $mysidia->db->select("owned_adoptables", array("name", "aid"), "owner = '{$mysidia->user->username}' AND gender = 'f' AND currentlevel >= {$settings->level} AND lastbred <= '{$lasttime}'");
        $female = ($stmt->rowcount() == 0)?new Null:$mysidia->db->fetchMap($stmt);
		$this->setField("femaleMap", $female);
  
        $stmt = $mysidia->db->select("owned_adoptables", array("name", "aid"), "owner = '{$mysidia->user->username}' AND gender = 'm' AND currentlevel >= {$settings->level} AND lastbred <= '{$lasttime}'");
		$male = ($stmt->rowcount() == 0)?new Null:$mysidia->db->fetchMap($stmt);
		$this->setField("maleMap", $male);
	}
}
?>

If it works, proceed with setting the stats for existing adoptables. :3 I'll work on level up... by the way, are you inserting the code based on the line number or the content? V1.3.4 is different than v1.3.3, so the line numbering and content doesn't match exactly.
 
Last edited:
Breeding works! So we have adopt and breeding working alright.

Levelup still white pages on me ...
 
I'll work on level up... can you give me the file again? By the way, are you inserting the code based on the line number or the content? V1.3.4 is different than v1.3.3, so the line numbering and content doesn't match exactly.
 
I search for it by number but I double check the content ... I've attached the file for levelup.

Named it _1 for the upload, but it's what I was using for levelup.php.
 

Attachments

  • levelup_1.php
    8.7 KB · Views: 2
Umm, the code you got should work:
PHP:
<?php

class LevelupController extends AppController{

    const PARAM = "aid";
    private $view;
	private $subController;
	private $adopt;

    public function __construct(){
        parent::__construct();
		$mysidia = Registry::get("mysidia");
		if($mysidia->input->action() == "click" or $mysidia->input->action() == "siggy") $this->adopt = new OwnedAdoptable($mysidia->input->get("aid"));
		if($mysidia->user instanceof Member){
		    $status = $mysidia->user->getstatus();   
			if($status->canlevel == "no") throw new InvalidActionException($mysidia->lang->banned);
		}	
    }
	
	public function index(){
	    $mysidia = Registry::get("mysidia");
		throw new InvalidActionException($mysidia->lang->global_action);
	}
	
	public function click(){
	    $mysidia = Registry::get("mysidia");
		$document = $mysidia->frame->getDocument();		
		$date = new DateTime;
		$ip = secure($_SERVER['REMOTE_ADDR']);
		$adoptablestatname = $this->adopt->getAdoptstatname();
	
        if($this->adopt->hasVoter($mysidia->user, $date)){
	        // The user has leveled up this adoptable today, show error message
		    $message = "<div id='stats'>Statname: {$adoptablestatname}</div>";
            $message = $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);  
		    $document->setTitle($mysidia->lang->already_leveled_title);
	        $document->addLangvar($message);		
	    }
		elseif($this->adopt->isFrozen() == "yes"){
		        $message = $message .= "
<div id='stats'>
Statname: {$adoptablestatname}
</div><br>
We're sorry, but you cannot add clicks to this adoptable at this time because its owner has chosen to freeze it.  Frozen adoptables do not accept new clicks and do not level up.  Thanks anyway for the click though, but the owner of this adoptable wants to keep this adoptable young so it will not be counted.";
		    $document->setTitle($mysidia->lang->frozen_title);
	        $document->addLangvar($message);
		}
		else{
		    $message = $message .= "<br><text align ='center'><div id='clickpagelink'><a href='{$mysidia->path->getAbsolute()}levelup/click/{$this->adopt->getAdoptID()}'>Click here to visit {$adoptablename}</a><br></div>";  
		    $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()){
                // A higher level does exist, so we see if it is time to level up
	            $nextLevel = $this->adopt->getNextLevel();
				$requiredClicks = $nextLevel->getRequiredClicks();
	            if($requiredClicks and $newClicks >= $requiredClicks) $this->adopt->setCurrentLevel($nextLevel->getLevel(), "update");
	        }
			
			$document->setTitle("{$mysidia->lang->gave} {$this->adopt->getName()} one {$mysidia->lang->unit}");
			$reward = $mysidia->user->clickreward($mysidia->settings->rewardmoney);
		    $mysidia->user->changecash($reward);			
	        $image = $this->adopt->getImage("gui");        
			$image->setLineBreak(TRUE);	
			
		    $summary = new Division;
			$summary->setAlign(new Align("center"));
            $summary->add($image);	
            $summary->add(new Comment("{$mysidia->lang->gave}{$this->adopt->getName()} one {$mysidia->lang->unit}."));
            $summary->add(new Comment($mysidia->lang->encourage));
            $summary->add(new Comment("<br>"));
            $summary->add(new Comment(" 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}"));
            $document->add($summary);
			$document->addLangvar($message);			
		}
	}

	public function siggy(){
	    $mysidia = Registry::get("mysidia");
        // The adoptable is available, let's collect its info
	    $usingimage = "no";
	    $image = $this->adopt->getImage(); 
	  
	    $usegd = $mysidia->settings->gdimages;
	    $imageinfo = @getimagesize($image);
	    $imagemime = $imageinfo["mime"]; // Mime type of the image file, should be a .gif file...

	    if(function_exists('imagegif') and $usegd == "yes" and $imagemime == "image/gif"){
	        $usingimage = "yes"; //Turn the template system off
            $type = $this->adopt->getType();
            list($width, $height, $type, $attr) = getimagesize($image); // The size of the original adoptable image

	        // Lets create the new target image, with a size big enough for the text for the adoptable
	        $newheight = $height + 72;
            $newwidth = ($newwidth < 250)?250:$width;
            $img_temp = imagecreatetruecolor($newwidth, $newheight); 
            $alphablending = true;  
		 
    	    // Lets create the image and save its transparency  
            $img_old = @imagecreatefromgif($image);  
            imagealphablending($img_old, true);  
            imagesavealpha($img_old, true);
   
            // Lets copy the old image into the new image with  
            ImageCopyResampled($img_temp, $img_old, 0, 0, 0, 0, $width, $height, $width, $height);    
	        $textheight = $width + 2;
	        $image = $img_temp;
            $bgi = imagecreatetruecolor($newwidth, $newheight);
            $color = imagecolorallocate($bgi, 51, 51, 51);
		 
		    // Build text for siggy
            $str1 = "Name: ".$this->adopt->getName();
            $str2 = "Owner: ".$this->adopt->getOwner();
	        $str3 = "Click Here to Feed Me!";
	        $str4 = "More Adopts at:";
	        $str5 = "www.".constant("DOMAIN");

            // Renger Image
	        imagestring ($image, 12, 0, $textheight,  $str1, $color);
	        imagestring ($image, 12, 0, $textheight + 13,  $str2, $color);
	        imagestring ($image, 12, 0, $textheight + 26,  $str3, $color);
	        imagestring ($image, 12, 0, $textheight + 42,  $str4, $color);
	        imagestring ($image, 12, 0, $textheight + 55,  $str5, $color);
	        $background = imagecolorallocate($image, 0, 0, 0);  
            ImageColorTransparent($image, $background);  
 
            // At the very last, let's clean up temporary files
	        header("Content-Type: image/GIF");
	        ImageGif ($image);
	        imagedestroy($image);
	        imagedestroy($img_temp);
	        imagedestroy($img_old);
	        imagedestroy($bgi);

	    }
	    else{  	
	            // We are going to try and get this image the old fashioned way...
            $extList = array();
	        $extList['gif'] = 'image/gif';
	        $extList['jpg'] = 'image/jpeg';
	        $extList['jpeg'] = 'image/jpeg';
	        $extList['png'] = 'image/png';

	        //Define the output file type
	        $contentType = 'Content-type: '.$extList[ $imageinfo['extension'] ];

	        if($imageinfo['extension'] =! "image/gif" and $imageinfo['extension'] =! "image/jpeg" and $imageinfo['extension'] =! "image/png"){	         
	            throw new InvalidIDException("The file Extension is not allowed!");
	        }
	        else{
                // File type is allowed, so proceed
	            $status = "";
	            header($contentType);
                $curl = new Curl($image);
				$curl->setHeader();
				$curl->exec();
				$curl->close();
	        } 
	    }
	}
	
	public function daycare(){
		$mysidia = Registry::get("mysidia");
		$document = $mysidia->frame->getDocument();
        $document->setTitle($mysidia->lang->daycare_title);
        $document->addLangvar($mysidia->lang->daycare, TRUE);
		
		try{
		    $daycare = new Daycare;
			$adopts = $daycare->getAdopts();
		}
		catch(DaycareException $dae){
		    $message = $dae->getmessage();
		    $document->addLangvar($mysidia->lang->{$message});
			return;
		}
		
		$daycareTable = new Table("daycare", "", FALSE);
		$daycareTable->setBordered(FALSE);
		$total = $daycare->getTotalAdopts();
        $index = 0;

		for($row = 0; $row < $daycare->getTotalRows(); $row++){
	        $daycareRow = new TRow("row{$row}");
            for($column = 0; $column < $daycare->getTotalColumns(); $column++){
			    $adopt = new OwnedAdoptable($adopts[$index]);
				$image = new Link("levelup/click/{$adopt->getAdoptID()}", $adopt->getImage("gui"), TRUE);
				$stats = new Comment($daycare->getStats($adopt));
				$daycareCell = new TCell(new ArrayObject(array($image, $stats)), "cell{$index}");
                $daycareCell->setAlign(new Align("center", "center"));
				$daycareRow->add($daycareCell);
				$index++;
				if($index == $total) break;
            }
            $daycareTable->add($daycareRow);			
		}
		
        $document->add($daycareTable);
		if($pagination = $daycare->getPagination()) $document->addLangvar($pagination->showPage());
	}
}
?>
Check your ownedadoptable class file.
 
NOW it's working to insert the stats!! Not sure why haha ...let me see if Levelup is !



EDIT -- still white page, with the levelup code!
 
Last edited:
^Oh, wait a minute... for the levelup page, did you use the file I provided? THat's 1.3.3..
 
I did yes ... I didn't have much luck adding in the code to my own, didn't think of that.

Here's my 1.3.4 levelup file attached ..


if you want to see if you can add it and I'll try it!
 

Attachments

  • levelup.php
    6 KB · Views: 3
Try this:
PHP:
<?php

use Resource\Native\Integer;
use Resource\Collection\ArrayList;
use Resource\Utility\Curl;

class LevelupController extends AppController{

    const PARAM = "aid";
	private $adopt;
    private $settings;

    public function __construct(){
        parent::__construct();
        $this->settings = new LevelSetting;
		$mysidia = Registry::get("mysidia");

		if($mysidia->input->action() == "click" or $mysidia->input->action() == "siggy") $this->adopt = new OwnedAdoptable($mysidia->input->get("aid"));
		if($mysidia->user instanceof Member){
		    $status = $mysidia->user->getstatus();   
			if($status->canlevel == "no") throw new InvalidActionException("banned");
		}	
    }
	
	public function index(){
		throw new InvalidActionException("global_action");
	}
	
	public function click(){
	    $mysidia = Registry::get("mysidia");
		$date = new DateTime;
		$ip = secure($_SERVER['REMOTE_ADDR']);
		$adoptablestatname = $this->adopt->getAdoptstatname();

		if($this->settings->system != "enabled") throw new NoPermissionException("disabled");
        elseif($this->adopt->hasVoter($mysidia->user, $date)){





		   $message = "<div id='stats'>Statname: {$adoptablestatname}</div>";
$message = $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);  


			throw new LevelupException($message);		
	    }
		




		
		
		elseif($this->adopt->isFrozen() == "yes")  $message = $message .= "
<div id='stats'>
Statname: {$adoptablestatname}
</div><br>
We're sorry, but you cannot add clicks to this adoptable at this time because its owner has chosen to freeze it.  Frozen adoptables do not accept new clicks and do not level up.  Thanks anyway for the click though, but the owner of this adoptable wants to keep this adoptable young so it will not be counted.";
            $document->setTitle($mysidia->lang->frozen_title);
            $document->addLangvar($message);  
        elseif($mysidia->user->getVotes() > $this->settings->number) throw new LevelupException("number");
        elseif($this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){
 			throw new LevelupException("owner");	           
        }
		else{
		$message = $message .= "<br><text align ='center'><div id='clickpagelink'><a href='{$mysidia->path->getAbsolute()}levelup/click/{$this->adopt->getAdoptID()}'>Click here to visit {$adoptablename}</a><br></div>";  
		    $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");
	        }
			
			$reward = $mysidia->user->clickreward($this->settings->reward);
		    $mysidia->user->changecash($reward);			
            $this->setField("adopt", $this->adopt);
            $this->setField("reward", new Integer($reward));
			$document->addLangvar($message);			
		}
	}

	public function siggy(){
	    $mysidia = Registry::get("mysidia");
        // The adoptable is available, let's collect its info
	    $usingimage = "no";
	    $image = $this->adopt->getImage(); 
	  
	    $usegd = $mysidia->settings->gdimages;
	    $imageinfo = @getimagesize($image);
	    $imagemime = $imageinfo["mime"]; // Mime type of the image file, should be a .gif file...

	    if(function_exists('imagegif') and $usegd == "yes" and $imagemime == "image/gif"){
	        $usingimage = "yes"; //Turn the template system off
            $type = $this->adopt->getType();
            list($width, $height, $type, $attr) = getimagesize($image); // The size of the original adoptable image

	        // Lets create the new target image, with a size big enough for the text for the adoptable
	        $newheight = $height + 72;
            $newwidth = ($newwidth < 250)?250:$width;
            $img_temp = imagecreatetruecolor($newwidth, $newheight); 
            $alphablending = true;  
		 
    	    // Lets create the image and save its transparency  
            $img_old = @imagecreatefromgif($image);  
            imagealphablending($img_old, true);  
            imagesavealpha($img_old, true);
   
            // Lets copy the old image into the new image with  
            ImageCopyResampled($img_temp, $img_old, 0, 0, 0, 0, $width, $height, $width, $height);    
	        $textheight = $width + 2;
	        $image = $img_temp;
            $bgi = imagecreatetruecolor($newwidth, $newheight);
            $color = imagecolorallocate($bgi, 51, 51, 51);
		 
		    // Build text for siggy
            $str1 = "Name: ".$this->adopt->getName();
            $str2 = "Owner: ".$this->adopt->getOwner();
	        $str3 = "Click Here to Boost Me!";
	        $str4 = "More Pets at:";
	        $str5 = "www.".constant("DOMAIN");

            // Renger Image
	        imagestring ($image, 12, 0, $textheight,  $str1, $color);
	        imagestring ($image, 12, 0, $textheight + 13,  $str2, $color);
	        imagestring ($image, 12, 0, $textheight + 26,  $str3, $color);
	        imagestring ($image, 12, 0, $textheight + 42,  $str4, $color);
	        imagestring ($image, 12, 0, $textheight + 55,  $str5, $color);
	        $background = imagecolorallocate($image, 0, 0, 0);  
            ImageColorTransparent($image, $background);  
 
            // At the very last, let's clean up temporary files
	        header("Content-Type: image/GIF");
	        ImageGif ($image);
	        imagedestroy($image);
	        imagedestroy($img_temp);
	        imagedestroy($img_old);
	        imagedestroy($bgi);

	    }
	    else{  	
	            // We are going to try and get this image the old fashioned way...
            $extList = array();
	        $extList['gif'] = 'image/gif';
	        $extList['jpg'] = 'image/jpeg';
	        $extList['jpeg'] = 'image/jpeg';
	        $extList['png'] = 'image/png';

	        //Define the output file type
	        $contentType = 'Content-type: '.$extList[ $imageinfo['extension'] ];

	        if($imageinfo['extension'] =! "image/gif" and $imageinfo['extension'] =! "image/jpeg" and $imageinfo['extension'] =! "image/png"){	         
	            throw new InvalidIDException("The file Extension is not allowed!");
	        }
	        else{
                // File type is allowed, so proceed
	            $status = "";
	            header($contentType);
                $curl = new Curl($image);
				$curl->setHeader();
				$curl->exec();
				$curl->close();
	        } 
	    }
	}
	
	public function daycare(){		
		$daycare = new Daycare;
		$adopts = $daycare->getAdopts();
		$this->setField("daycare", $daycare);
	}
}
?>
I can try something else if it fails to work.
 
Try this:
PHP:
<?php

use Resource\Native\Integer;
use Resource\Collection\ArrayList;
use Resource\Utility\Curl;

class LevelupController extends AppController{

    const PARAM = "aid";
	private $adopt;
    private $settings;

    public function __construct(){
        parent::__construct();
        $this->settings = new LevelSetting;
		$mysidia = Registry::get("mysidia");

		if($mysidia->input->action() == "click" or $mysidia->input->action() == "siggy") $this->adopt = new OwnedAdoptable($mysidia->input->get("aid"));
		if($mysidia->user instanceof Member){
		    $status = $mysidia->user->getstatus();   
			if($status->canlevel == "no") throw new InvalidActionException("banned");
		}	
    }
	
	public function index(){
		throw new InvalidActionException("global_action");
	}
	
	public function click(){
	    $mysidia = Registry::get("mysidia");
		$date = new DateTime;
		$ip = secure($_SERVER['REMOTE_ADDR']);
		$statname = rand(0,100) ;

		if($this->settings->system != "enabled") throw new NoPermissionException("disabled");
        elseif($this->adopt->hasVoter($mysidia->user, $date)){





		    $message = "<div id='stats'>Statname: {$adoptablestatname}</div>";
$message = $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);  


			throw new LevelupException($message);		
	    }
		




		
		  $message = $message .= "
<div id='stats'>
Statname: {$adoptablestatname}
</div><br>
We're sorry, but you cannot add clicks to this adoptable at this time because its owner has chosen to freeze it.  Frozen adoptables do not accept new clicks and do not level up.  Thanks anyway for the click though, but the owner of this adoptable wants to keep this adoptable young so it will not be counted.";
		elseif($this->adopt->isFrozen() == "yes") throw new LevelupException($message);
        elseif($mysidia->user->getVotes() > $this->settings->number) throw new LevelupException("number");
        elseif($this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){
 			throw new LevelupException("owner");	           
        }
		else{
		  $message = $message .= "<br><text align ='center'><div id='clickpagelink'><a href='{$mysidia->path->getAbsolute()}levelup/click/{$this->adopt->getAdoptID()}'>Click here to visit {$adoptablename}</a><br></div>";  
		    $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");
	        }
			
			$reward = $mysidia->user->clickreward($this->settings->reward);
		    $mysidia->user->changecash($reward);			
            $this->setField("adopt", $this->adopt);
            $this->setField("reward", new Integer($reward));
            throw new LevelupException($message);
		}
	}

	public function siggy(){
	    $mysidia = Registry::get("mysidia");
        // The adoptable is available, let's collect its info
	    $usingimage = "no";
	    $image = $this->adopt->getImage(); 
	  
	    $usegd = $mysidia->settings->gdimages;
	    $imageinfo = @getimagesize($image);
	    $imagemime = $imageinfo["mime"]; // Mime type of the image file, should be a .gif file...

	    if(function_exists('imagegif') and $usegd == "yes" and $imagemime == "image/gif"){
	        $usingimage = "yes"; //Turn the template system off
            $type = $this->adopt->getType();
            list($width, $height, $type, $attr) = getimagesize($image); // The size of the original adoptable image

	        // Lets create the new target image, with a size big enough for the text for the adoptable
	        $newheight = $height + 72;
            $newwidth = ($newwidth < 250)?250:$width;
            $img_temp = imagecreatetruecolor($newwidth, $newheight); 
            $alphablending = true;  
		 
    	    // Lets create the image and save its transparency  
            $img_old = @imagecreatefromgif($image);  
            imagealphablending($img_old, true);  
            imagesavealpha($img_old, true);
   
            // Lets copy the old image into the new image with  
            ImageCopyResampled($img_temp, $img_old, 0, 0, 0, 0, $width, $height, $width, $height);    
	        $textheight = $width + 2;
	        $image = $img_temp;
            $bgi = imagecreatetruecolor($newwidth, $newheight);
            $color = imagecolorallocate($bgi, 51, 51, 51);
		 
		    // Build text for siggy
            $str1 = "Name: ".$this->adopt->getName();
            $str2 = "Owner: ".$this->adopt->getOwner();
	        $str3 = "Click Here to Boost Me!";
	        $str4 = "More Pets at:";
	        $str5 = "www.".constant("DOMAIN");

            // Renger Image
	        imagestring ($image, 12, 0, $textheight,  $str1, $color);
	        imagestring ($image, 12, 0, $textheight + 13,  $str2, $color);
	        imagestring ($image, 12, 0, $textheight + 26,  $str3, $color);
	        imagestring ($image, 12, 0, $textheight + 42,  $str4, $color);
	        imagestring ($image, 12, 0, $textheight + 55,  $str5, $color);
	        $background = imagecolorallocate($image, 0, 0, 0);  
            ImageColorTransparent($image, $background);  
 
            // At the very last, let's clean up temporary files
	        header("Content-Type: image/GIF");
	        ImageGif ($image);
	        imagedestroy($image);
	        imagedestroy($img_temp);
	        imagedestroy($img_old);
	        imagedestroy($bgi);

	    }
	    else{  	
	            // We are going to try and get this image the old fashioned way...
            $extList = array();
	        $extList['gif'] = 'image/gif';
	        $extList['jpg'] = 'image/jpeg';
	        $extList['jpeg'] = 'image/jpeg';
	        $extList['png'] = 'image/png';

	        //Define the output file type
	        $contentType = 'Content-type: '.$extList[ $imageinfo['extension'] ];

	        if($imageinfo['extension'] =! "image/gif" and $imageinfo['extension'] =! "image/jpeg" and $imageinfo['extension'] =! "image/png"){	         
	            throw new InvalidIDException("The file Extension is not allowed!");
	        }
	        else{
                // File type is allowed, so proceed
	            $status = "";
	            header($contentType);
                $curl = new Curl($image);
				$curl->setHeader();
				$curl->exec();
				$curl->close();
	        } 
	    }
	}
	
	public function daycare(){		
		$daycare = new Daycare;
		$adopts = $daycare->getAdopts();
		$this->setField("daycare", $daycare);
	}
}
?>
 
Not working for me still ... anyone else want to try this on a 1.3.4 site?

I really can't imagine what's wrong!
 
I'm not sure .. ah, and shop is giving the same error as adopt and breeding were.



I have uploaded the 1.3.4 shop file, if you have time you can alter that when you are able.

We're getting there, I'm anxious to get this all working because it's fantastic!!


I'm already working on a mod for the mod, to have the mother and father stats combine to be inherited!
 

Attachments

  • shop.php
    2.7 KB · Views: 2
Try this code:
PHP:
<?php

use Resource\Native\Integer;

class ShopController extends AppController{

    const PARAM = "shop";

    public function __construct(){
        parent::__construct("member");	
        $mysidia = Registry::get("mysidia");		
        $mysidia->user->getstatus();
		if($mysidia->user->status->canshop == "no"){
		    throw new NoPermissionException($mysidia->lang->denied);
		}
		if($mysidia->input->action() != "index" and !$mysidia->input->get("shop")){
		    throw new InvalidIDException($mysidia->lang->global_id);
		}
    }
	
	public function index(){
	    $mysidia = Registry::get("mysidia");
        $shopList = new Shoplist($mysidia->input->post("shoptype"));
		if($shopList->gettotal() == 0) throw new InvalidIDException("none");
        $this->setField("shopList", $shopList);
	}
	
	public function browse(){
		$mysidia = Registry::get("mysidia");		
		$shoptype = $mysidia->db->select("shops", array("shoptype"), "shopname = '{$mysidia->input->get("shop")}'")->fetchColumn();
        $shoplist = new Shoplist($shoptype);
        $shop = $shoplist->createshop($mysidia->input->get("shop"));
        $this->setField("shop", $shop);
	}
	
	public function purchase(){
        $mysidia = Registry::get("mysidia");
	    if(!$mysidia->input->post("buy")) throw new InvalidIDException($mysidia->lang->global_id);
		
	    if($mysidia->input->post("shoptype") == "itemshop") $this->purchaseItem();
	    
		elseif($mysidia->input->post("shoptype") == "adoptshop") $this->purchaseAdopt();
		
		
		
		
		
		
		
		else throw new InvalidActionException($mysidia->lang->global_action);
	}
	
	private function purchaseItem(){
        $mysidia = Registry::get("mysidia");        
        $shop = new Itemshop($mysidia->input->get("shop"));
        $item = $shop->getitem($mysidia->input->post("itemname"));
	    $item->assign($mysidia->user->username);
        $oldquantity = $item->getoldquantity();
        $newquantity = $oldquantity + $mysidia->input->post("quantity");
			
	    if(!is_numeric($mysidia->input->post("quantity"))){
			throw new InvalidActionException($mysidia->lang->invalid_quantity);
        }
        elseif($newquantity > $item->cap){
			throw new InvalidActionException($mysidia->lang->full_quantity); 
        }
        else{
		    $shop->purchase($item);
			$this->setField("cost", new Integer($item->getcost($shop->salestax)));
		}		
	}
	
	private function purchaseAdopt(){
        $mysidia = Registry::get("mysidia");
		$shop = new Adoptshop($mysidia->input->get("shop"));
        $adopt = $shop->getadopt($mysidia->input->post("adopttype"));
        $statname = rand(minimum value,maximum value) ;
        $adopt->assign($mysidia->user->username);			
        $shop->purchase($adopt);
        $mysidia->db->update("owned_adoptables",array("statname" => $statname),"aid = $offspringID");  
		$this->setField("cost", new Integer($adopt->getcost($shop->salestax)));	    
	}
}
?>
Also, the breeding sounds great, but if you're going to implement the training and award system I have on my site, you'll also have to limit the number of training items that can be used on an adopt.
 
Aww this one didn't work ... and yeah very true, I'll have to change some of the item amounts allowed.
 
Sorry about that - my mistake!
PHP:
<?php

use Resource\Native\Integer;

class ShopController extends AppController{

    const PARAM = "shop";

    public function __construct(){
        parent::__construct("member");	
        $mysidia = Registry::get("mysidia");		
        $mysidia->user->getstatus();
		if($mysidia->user->status->canshop == "no"){
		    throw new NoPermissionException($mysidia->lang->denied);
		}
		if($mysidia->input->action() != "index" and !$mysidia->input->get("shop")){
		    throw new InvalidIDException($mysidia->lang->global_id);
		}
    }
	
	public function index(){
	    $mysidia = Registry::get("mysidia");
        $shopList = new Shoplist($mysidia->input->post("shoptype"));
		if($shopList->gettotal() == 0) throw new InvalidIDException("none");
        $this->setField("shopList", $shopList);
	}
	
	public function browse(){
		$mysidia = Registry::get("mysidia");		
		$shoptype = $mysidia->db->select("shops", array("shoptype"), "shopname = '{$mysidia->input->get("shop")}'")->fetchColumn();
        $shoplist = new Shoplist($shoptype);
        $shop = $shoplist->createshop($mysidia->input->get("shop"));
        $this->setField("shop", $shop);
	}
	
	public function purchase(){
        $mysidia = Registry::get("mysidia");
	    if(!$mysidia->input->post("buy")) throw new InvalidIDException($mysidia->lang->global_id);
		
	    if($mysidia->input->post("shoptype") == "itemshop") $this->purchaseItem();
	    
		elseif($mysidia->input->post("shoptype") == "adoptshop") $this->purchaseAdopt();
		
		
		
		
		
		
		
		else throw new InvalidActionException($mysidia->lang->global_action);
	}
	
	private function purchaseItem(){
        $mysidia = Registry::get("mysidia");        
        $shop = new Itemshop($mysidia->input->get("shop"));
        $item = $shop->getitem($mysidia->input->post("itemname"));
	    $item->assign($mysidia->user->username);
        $oldquantity = $item->getoldquantity();
        $newquantity = $oldquantity + $mysidia->input->post("quantity");
			
	    if(!is_numeric($mysidia->input->post("quantity"))){
			throw new InvalidActionException($mysidia->lang->invalid_quantity);
        }
        elseif($newquantity > $item->cap){
			throw new InvalidActionException($mysidia->lang->full_quantity); 
        }
        else{
		    $shop->purchase($item);
			$this->setField("cost", new Integer($item->getcost($shop->salestax)));
		}		
	}
	
	private function purchaseAdopt(){
        $mysidia = Registry::get("mysidia");
		$shop = new Adoptshop($mysidia->input->get("shop"));
        $adopt = $shop->getadopt($mysidia->input->post("adopttype"));
        $statname = rand(0,100) ;
        $adoptid = $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num + 1;
        $adopt->assign($mysidia->user->username);			
        $shop->purchase($adopt);
        $mysidia->db->update("owned_adoptables",array("statname" => $statname),"aid = $adoptid");  
		$this->setField("cost", new Integer($adopt->getcost($shop->salestax)));	    
	}
}
?>
Try this. :3
 
Heeeeey ! Looks like you got it!! YAY!! Thank you!!

If you're able to get Levelup going, I'll test that out ...just let me know. And thank you for all your work on this!
 
Hmm, all I need to know is whether or not the comment function would work... either that or, I need to check some v.1.3.4 files.
 

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