Pet personalities?

Forum
Last Post
Threads / Messages

aquapyrofan

Member
Member
Joined
Apr 22, 2017
Messages
48
Points
0
Mysidian Dollar
5,119
Is there a way I could give pets a randomly generated personality on creation? And maybe have it display a bit of text related to that on the profile(assuming I can get one set up)/on the stats page?
 
Oh lords, I just typed out a bunch of information for you and the internet glitched and ate my entire post.

Okay, I'll edit this post in a moment, just adding the codes that you'll need at the moment.


Edit:

You will need to create two new files, one where the base files for your site are (adopt.php, account.php, etc):

personality.php
PHP:
<?php

class PersonalityController extends AppController{

    public function index(){
        $mysidia = Registry::get("mysidia");        
    }

}
?>

...and one in the view folder:

personalityview.php
PHP:
<?php 

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

class PersonalityView extends View{ 
     
    public function index(){ 
        $mysidia = Registry::get("mysidia"); 
        $document = $this->document;         
        $document->setTitle("New Personality Trait"); 
		
    if($mysidia->input->post("add")){
        $mysidia->db->insert("personalities", array("id" => NULL, "pers" => $mysidia->input->post("type")));                
        $document->add(new Comment( "You have added the personality type {$mysidia->input->post("type")}.")); 
        $document->add(new Comment("<meta http-equiv='refresh' content='1;url=personality' />")); 
        return TRUE;        
    }
            
        if($mysidia->user instanceof Admin){ 
        $adoptablepersonality = $mysidia->db->select("personalities", array("pers"), "1 ORDER BY RAND() DESC LIMIT 1")->fetchColumn();
        $document->add(new Comment( "<h2>Add New Personality Types</h2>")); 
             $document->add(new Comment( "Adding new possible personality types is easy! Just type it in the box and hit submit, then new adoptables have a chance of ending up with that personality type.<br><br>{$adoptablepersonality}<br><br>")); 
         
        $persForm = new Form("addform", "", "post");
        $persForm->add(new Comment("<br><u>Create A New Personality:</u><br>", TRUE, "b"));
        $persForm->add(new Comment("Type:"));
        $persForm->add(new TextField("type"));
        $persForm->add(new Button("Add", "add", "submit"));
        $document->add($persForm);    
                     
                     $document->add(new Comment( "<hr>"));
        }
                else{ 
$document->add(new Comment( "You do not have permission to access this page.")); 
}
          
        
            
            
     }
     
}
?>

With that done we need to go into the database and add one new table to the database called adopts_personalities with two columns. The two columns will need this data entered:
name: id
type: int(20)
null: No
default: None
extra: AUTO_INCREMENT

name: pers
type: varchar(100)
collation: latin1_swedish_ci
null: Yes
default: Null

Now move on over to owned_adoptables and add a new column with the following info:
name: personality
type: varchar(100)
collation: latin1_swedish_ci
null: No
default: Easy Going

Now for the tedious part. You will need to make the same edits, more or less, to the following five files:
adopt.php
classes/class_breeding.php
classes/class_promocode.php
classes/class_stockadopt.php
admincp/ownedadopt.php

Find the insert line in each file that starts like this:
$mysidia->db->insert("owned_adoptables", array("aid" => NULL...

At the end of that, before the closing )); add a comma behind whatever is last, and then add this:
PHP:
"personality" => $adoptablepersonality
 
Last edited:
Oh lords, I just typed out a bunch of information for you and the internet glitched and ate my entire post.

Okay, I'll edit this post in a moment, just adding the codes that you'll need at the moment.


Edit:

You will need to create two new files, one where the base files for your site are (adopt.php, account.php, etc):

personality.php
PHP:
<?php

class PersonalityController extends AppController{

    public function index(){
        $mysidia = Registry::get("mysidia");        
    }

}
?>

...and one in the view folder:

personalityview.php
PHP:
<?php 

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

class PersonalityView extends View{ 
     
    public function index(){ 
        $mysidia = Registry::get("mysidia"); 
        $document = $this->document;         
        $document->setTitle("New Personality Trait"); 
		
    if($mysidia->input->post("add")){
        $mysidia->db->insert("personalities", array("id" => NULL, "pers" => $mysidia->input->post("type")));                
        $document->add(new Comment( "You have added the personality type {$mysidia->input->post("type")}.")); 
        $document->add(new Comment("<meta http-equiv='refresh' content='1;url=personality' />")); 
        return TRUE;        
    }
            
        if($mysidia->user instanceof Admin){ 
        $adoptablepersonality = $mysidia->db->select("personalities", array("pers"), "1 ORDER BY RAND() DESC LIMIT 1")->fetchColumn();
        $document->add(new Comment( "<h2>Add New Personality Types</h2>")); 
             $document->add(new Comment( "Adding new possible personality types is easy! Just type it in the box and hit submit, then new adoptables have a chance of ending up with that personality type.<br><br>{$adoptablepersonality}<br><br>")); 
         
        $persForm = new Form("addform", "", "post");
        $persForm->add(new Comment("<br><u>Create A New Personality:</u><br>", TRUE, "b"));
        $persForm->add(new Comment("Type:"));
        $persForm->add(new TextField("type"));
        $persForm->add(new Button("Add", "add", "submit"));
        $document->add($persForm);    
                     
                     $document->add(new Comment( "<hr>"));
        }
                else{ 
$document->add(new Comment( "You do not have permission to access this page.")); 
}
          
        
            
            
     }
     
}
?>

With that done we need to go into the database and add one new table to the database called adopts_personalities with two columns. The two columns will need this data entered:
name: id
type: int(20)
null: No
default: None
extra: AUTO_INCREMENT

name: pers
type: varchar(100)
collation: latin1_swedish_ci
null: Yes
default: Null

Now move on over to owned_adoptables and add a new column with the following info:
name: personality
type: varchar(100)
collation: latin1_swedish_ci
null: No
default: Easy Going

Now for the tedious part. You will need to make the same edits, more or less, to the following five files:
adopt.php
classes/class_breeding.php
classes/class_promocode.php
classes/class_stockadopt.php
admincp/ownedadopt.php

Find the insert line in each file that starts like this:
$mysidia->db->insert("owned_adoptables", array("aid" => NULL...

At the end of that, before the closing )); add a comma behind whatever is last, and then add this:
PHP:
"personality" => $adoptablepersonality
So all that's in, now how do I get to the add personality page and how do I view a pet's personality?
 
Sorry, internet shorted out again before I could finish @_@

Okay, here are the rest of the instructions:

In the same 5 files I mentioned, find the insert line again, and right above it add this line;
PHP:
$adoptablepersonality = $mysidia->db->select("personalities", array("pers"), "1 ORDER BY RAND() DESC LIMIT 1")->fetchColumn();

To display a pet's personality on, say, the manage page (via myadoptsview.php) you can use this:
PHP:
{$adopt->personality}

In some files you'll just need to change that to this;
PHP:
{$this->adopt->personality}

Then you can access the add page at http://YOURSITE.com/personality (don't worry, only admins can access it!)

And that should be it!
 
Last edited:
I probably screwed something up, but my site returns a 500 error when I try to access mysite/personality
 
Did you edit anything in the files at all?

Make sure everything's in the right folder?
 
The only edits I made are the ones you said to make, and I double checked the positions, so I'm pretty sure that's not it
 
Alright, could you show me the sections in the 5 files that have been edited? (adopt.php, class_breeding.php, class_promocode.php, class_stockadopt.php, and admincp/ownedadopt.php)

Edit:
Before doing that, try adding this about the index function in personality.php:
PHP:
public function __construct(){
parent::__construct("member");    
}

And let me know if you see any changes.
 
Last edited:
adopt.php
PHP:
$adoptablepersonality = $mysidia->db->select("personalities", array("pers"), "1 ORDER BY RAND() DESC LIMIT 1")->fetchColumn();
		    $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, "offsprings" => 0, "lastbred" => 0, "personality" => $adoptablepersonality));

class_breeding.php
PHP:
$adoptablepersonality = $mysidia->db->select("personalities", array("pers"), "1 ORDER BY RAND() DESC LIMIT 1")->fetchColumn();
			$mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $adopt->getType(), "name" => $adopt->getType(), "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
			                                               "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $gender, "offsprings" => 0, "lastbred" => 0, "personality" => $adoptablepersonality));

class_promocode.php
PHP:
$adoptablepersonality = $mysidia->db->select("personalities", array("pers"), "1 ORDER BY RAND() DESC LIMIT 1")->fetchColumn();
	        $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));

class_stockadopt.php
PHP:
$adoptablepersonality = $mysidia->db->select("personalities", array("pers"), "1 ORDER BY RAND() DESC LIMIT 1")->fetchColumn();
	  $mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $this->type, "name" => $this->type, "owner" => $this->owner,
	                                                 "currentlevel" => 0, "totalclicks" => 0, "code" => $code, "imageurl" => "", "usealternates" => $alts, 
													 "tradestatus" => "fortrade", "isfrozen" => "no", "gender" => $genders[$rand],
													 "offsprings" => 0, "lastbred" => 0, "personality" => $adoptablepersonality));

ownedadopt.php
PHP:
$adoptablepersonality = $mysidia->db->select("personalities", array("pers"), "1 ORDER BY RAND() DESC LIMIT 1")->fetchColumn();
			$mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $mysidia->input->post("type"), "name" => $mysidia->input->post("name"), "owner" => $mysidia->input->post("owner"), "currentlevel" => $mysidia->input->post("level"), "totalclicks" => $mysidia->input->post("clicks"), 
			                                               "code" => codegen(10, 0), "imageurl" => NULL, "usealternates" => $useAlternates, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $mysidia->input->post("gender"), "offsprings" => 0, "lastbred" => 0, "personality" => $adoptablepersonality));
 
I posted a snippet of code above, could you try that and let me know the results?
 
maybe something is missing in the personality.php and personalityview.php did you try to copy paste everything again? and check if the names match?
i just installed the mod in my site and everything works fine
Thank you Abronsyth for sharing with us the code
 
Now I just feel stupid. Turns out, I had added an extra character to the filename, which was causing the error. It is now working properly
 
Aaaah, okay! Don't feel stupid! I make some of the most ridiculous mistakes with files haha. Glad to hear it's working for you both :D
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,130
Members
1,603
Latest member
Monako
BETA

Latest Threads

Top