Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Pet personalities? (http://www.mysidiaadoptables.com/forum/showthread.php?t=5421)

aquapyrofan 04-25-2017 07:52 PM

Pet personalities?
 
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?

Abronsyth 04-25-2017 08:18 PM

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 Code:

<?php

class PersonalityController extends AppController{

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

}
?>

...and one in the view folder:

personalityview.php
PHP Code:

<?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 Code:

"personality" => $adoptablepersonality 


aquapyrofan 04-25-2017 09:57 PM

Quote:

Originally Posted by Abronsyth (Post 36206)
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 Code:

<?php

class PersonalityController extends AppController{

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

}
?>

...and one in the view folder:

personalityview.php
PHP Code:

<?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 Code:

"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?

Abronsyth 04-26-2017 09:02 AM

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 Code:

$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 Code:

{$adopt->personality

In some files you'll just need to change that to this;
PHP Code:

{$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!

KatFennec 04-26-2017 03:18 PM

I probably screwed something up, but my site returns a 500 error when I try to access mysite/personality

Abronsyth 04-26-2017 04:11 PM

Did you edit anything in the files at all?

Make sure everything's in the right folder?

KatFennec 04-26-2017 06:33 PM

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

Abronsyth 04-27-2017 08:31 AM

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 Code:

public function __construct(){
parent::__construct("member");    


And let me know if you see any changes.

KatFennec 04-27-2017 01:52 PM

adopt.php
PHP Code:

$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 Code:

$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 Code:

$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 Code:

$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 Code:

$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(100), "imageurl" => NULL"usealternates" => $useAlternates"tradestatus" => 'fortrade'"isfrozen" => 'no'"gender" => $mysidia->input->post("gender"), "offsprings" => 0"lastbred" => 0"personality" => $adoptablepersonality)); 


Abronsyth 04-27-2017 02:47 PM

I posted a snippet of code above, could you try that and let me know the results?


All times are GMT -5. The time now is 04:11 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.