Mys 1.3.3 Personality System

Forum
Last Post
Threads / Messages

Hwona

Member
Member
Joined
Mar 1, 2013
Messages
620
Points
0
Mysidian Dollar
31,589
Please save back ups before using this modification!

How to make a random-generating personality system


1. Go to the "owned_adoptables" table in your database(PHPMyadmin). Click the "structure" tab at the top of the page. When it brings you to the next page, scroll down until you see this:

Press "Go".
You'll be brought to this:

Set the values to match the example above and press "Save".

2. Go to the "adopt.php" file and find this:
$gender = $adopt->getGender();
Under that, put:
PHP:
 $personalities = array('personality1', 'personality2', 'personality3');
		   shuffle($personalities);
foreach ($personalities as $personality) {
    $adoptablepersonality = "$personality";
}
Find this:
PHP:
$mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $adopt->getType(), "name" => $name, "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $gender, "lastbred" => 0));
Replace with:
PHP:
$mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $adopt->getType(), "name" => $name, "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "personality" => $adoptablepersonality, "gender" => $gender, "lastbred" => 0));

3. Go to the "breeding.php" file and find this:
$offspringID = $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num + 1;
Under that, put:
PHP:
 $personalities = array('personality1', 'personality2', 'personality3');
		   shuffle($personalities);
foreach ($personalities as $personality) {
    $adoptablepersonality = "$personality";
}
Under that, put:
PHP:
 $mysidia->db->update("owned_adoptables",array("personality" => $adoptablepersonality),"aid = $offspringID");

4. Go to the "shop.php" file and find this:
$adoptid = $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num + 1;
Under that, add:
PHP:
 $personalities = array('personality1', 'personality2', 'personality3');
		   shuffle($personalities);
foreach ($personalities as $personality) {
    $adoptablepersonality = "$personality";
}
Under that, put:
PHP:
$mysidia->db->update("owned_adoptables",array("personality" => $adoptablepersonality),"aid = $adoptid");

5. Go to your "class_promocode.php" file(in the "classes" folder) and find this(in the "execute" function):
switch($this->type){
case "Adopt":
Below that, add:
PHP:
$personalities = array('personality1', 'personality2', 'personality3');
		   shuffle($personalities);
foreach ($personalities as $personality) {
    $adoptablepersonality = "$personality";
}
Find this:
PHP:
 $mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $this->reward, "name" => $this->reward, "owner" => $this->user, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
			                                               "imageurl" => NULL, "usealternates" => 'no', "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$rand], "lastbred" => 0));
Replace with:
PHP:
 $mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $this->reward, "name" => $this->reward, "owner" => $this->user, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
			                                               "imageurl" => NULL, "usealternates" => 'no', "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$rand], "lastbred" => 0, "personality" => $adoptablepersonality, ));

6. Go back to the "adopt.php" file.
Under this:
Add:
$mysidia->db->update("owned_adoptables",array("personality" =>"personality4"),"aid = $adoptid");
Go to your site's ACP and create a free adopt-page adopt. Adopt that pet once. Delete the adopted pet and the species. Then, go back to the "adopt.php" file and delete the code you just added


Done!
If you want to display the personality on the levelup page:
 
Last edited:
Displaying Personality On Levelup Page

This post will cover how to display an adoptable's personality on its click page


1. Go to the "class_ownedadoptable.php" file(inside the "classes" folder). There, at the top, there's a bunch of "protected" variables. Add this below them:
protected $adoptablepersonality;
Add this function to the list of functions below:
public function getAdoptPersonality(){
return $this->personality;
}

2. Got to the "levelup.php" file. On line 29, there should be something like this:
$ip = secure($_SERVER['REMOTE_ADDR']);
Under that with this:
$adoptablepersonality = $this->adopt->getAdoptPersonality();
On line 33, there's a piece of code like this:
PHP:
$message = ($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest;
Replace that with:
PHP:
$message = "<div id='personality'>Personality: {$adoptablepersonality}</div>";
$message = $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);
Replace lines 38 and 39, which should contain something like this:
PHP:
$document->setTitle($mysidia->lang->frozen_title);
	        $document->addLangvar($mysidia->lang->frozen);
With:
PHP:
	$message = $message .= "
<div id='stats'>
Personality: {$adoptablepersonality}
</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);
On line 41, there should be:
else{
Under that, put:
PHP:
$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>";
On line 67, there should be something like this:
$document->add($summary);
Under that, put:
$document->addLangvar($message);

I plan on editing the code to allow different personalities to have different chances of being selected. :3
 
Last edited:
Looks interesting. ^^ One quick suggestion though, why not uploaded all files that you've edited for this mods for new users to download and use quickly? I always provide that as an option for users running fresh installation sites.
 
^Sure! It'll be a lot of files to upload, but I can make it work. :3 Do you know how to insert content into the levelup.php file? From what I know, the two recent mods I made are compatible with the newest version other than the fact that displaying the stats on the click page can't be done the same way... do you know how to do this?
 
I've managed to get it to work somewhat! But because I'm using four stats, instead of this in levelup.php:
Code:
$message = "<div id='personality'>Personality: {$adoptablepersonality}</div>";

I'm using just:
Code:
$message = "<div id='personality'>Personality: {$this->adopt->personality}</div>";

(For example, anyway.) Which means I'm not even calling back to the edits made in class_ownedadoptable.php.

I really like how on your site, once you reload the page, rather than throwing an error that you've already levelled up the adoptable, it shows a nice profile page for it. How are you getting the species name to show? I can't seem to find where that variable is stored.
 
^Great! Wait, aren't you using v.1.3.4? How'd you get it to work there? The species thing should be there...
 
Yeah, I've got 1.3.4, and... Well, I got it to display, but... all that's on that page is an error message that the pet has already been fed... and now something that displays it's personality. I'll have to build an entire page for it to replace the 'already been fed' message, I guess. I wish it was cool like yours and showed a whole profile. I'm not sure what variable holds the species name, though. I can't seem to find it. I thought it was 'type' but that didn't manage to write anything.

On your Spring theme where you add in the mod for 1.3.3 levelup.php page (which I don't want to copy over to 1.3.4 and accidentally break everything somehow, for obvious reasons - but I can still glean enough information from it to replicate what I need) you don't seem to have the species on the list of things displayed, but, on your actual site, you do. o3o~?
 
Last edited:
Yeah, don't copy anything over to v.1.3.4 - I've no experience working with it, and right now, I'm still trying to figure out how to display stuff on the click page. And yes, the "type" variable is the thing that gets the species...

Actually, can you give me the link of one of your site's pets?
 
Last edited:
Nah, I can't. I'm working from my localhost/wamp setup only for now, and it's not online-online. =/ I could get it online from an IP address, but I'd have to do some port forwarding with the router but I figured since I'm moving at the end of the month that I wasn't going to bother until I was settled in at my new place.
 
(I think we should move the discussion here, in case it's helpful to someone, rather than having it on our pages?)

Alright, before click: x
After click: x

I followed your instructions exactly? And your instructions very literally snuggled up the personality to error message right below it, already there by default. When your page is reloaded, it shows a profile. But by default on 1.3.4, at least, it just shows an error. I assume you just designed over the error? I can do that no problem. There -isn't- a profile page by default at that link at all, though, so I assume you made all of it yourself.

However, there are only two references to 'frozen' pages in my script on that page and none of them look like what you have in the step after that. It's just "elseif($this->adopt->isFrozen() == "yes") throw new LevelupException("frozen");" so I couldn't continue your tutorial from there. Line numbers didn't help me at all because none of those matched, and there is no "$document->add($summary);" going on anywhere in that file. Nor any reference to 'document' at all.

1.3.4 levelup.php (with the tiny edit I managed to do):
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']);
		
		if($this->settings->system != "enabled") throw new NoPermissionException("disabled");
        elseif($this->adopt->hasVoter($mysidia->user, $date)){
		    $message = "<div id='personality'>This {$this->adopt->size}-sized, {$this->adopt->nature} novu likes {$this->adopt->likes} and dislikes {$this->adopt->dislikes}.</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") throw new LevelupException("frozen");
        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{
		    $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));			
		}
	}

	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(){		
		$daycare = new Daycare;
		$adopts = $daycare->getAdopts();
		$this->setField("daycare", $daycare);
	}
}
?>

However, in 1.3.4, we have another file in view/levelupview.php, and it contains all the document writing variables, but won't be able to find $message written on a local scope in a completely different document, probably:

PHP:
<?php

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

	public function siggy(){
	
	}
	
	public function daycare(){
		$mysidia = Registry::get("mysidia");
		$document = $this->document;	
        $document->setTitle($this->lang->daycare_title);
        $document->addLangvar($this->lang->daycare, TRUE);
		
		$daycare = $this->getField("daycare");
        $adopts = $daycare->getAdopts();
		$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]);
				$cell = new ArrayList;
				$cell->add(new Link("levelup/click/{$adopt->getAdoptID()}", $adopt->getImage("gui"), TRUE));
				$cell->add(new Comment($daycare->getStats($adopt)));
				$daycareCell = new TCell($cell, "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());
	}
}
?>

That's with no modifications, of course, because it's a file you aren't used to and had no instructions for. I can modify it, of course. I actually don't need anymore help? Seems pretty straight forward from here on out.

I really wish Mysidia would feed pets on a button click, rather than on a page view. *sigh*
 
^Oh, so you can figure it out? As long as you get over the "not having the document" stuff in the pages, the rest might work.
Edit: With the version I'm using the error title shows up too I think. It just has different text. So yes, you basically have everything the way I have it for already clicked non-frozen pets. You just need to style it.
 
Last edited:
Your first two image steps are missing.

So until that's fixed, in case anyone's curious, you're basically just making a field like the ones that hold the type, name, and owner. They're VARCHAR 40 which should be plenty of room - that's 40 letters/characters, of course. If you assign a default value, all currently existing adopts will have their new column filled with that default value.

help_by_kyttias-d8623px.gif
 
Has anyone added this successfully for 1.3.4?

The first step works for adoptables on the adopt page, but not for shop (stock) adoptables, and I haven't tested out breed adopts and promo ones.

I've tried adding and tweaking the code and putting it in the class files (class_stockadopt, class_promo, etc) but I've been unsuccessful so far. For example getting errors when I try to purchase an adopt. Any help? :< Would really love this on my site.

EDIT: Umm, nevermind, I did it. Lordy I have such a nasty habit of fixing my problems literally right after I post them LOL.
 
Last edited:
I know this post is pretty much dead, but does anyone have an idea for what the images on the front page show? I'd like to implement this on my 1.3.4 site but the images are now broken.. xD

Thank you ^_^
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top