Mys 1.3.x Stat/SKill System

Forum
Last Post
Threads / Messages

Hwona

Member
Member
Joined
Mar 1, 2013
Messages
620
Points
0
Mysidian Dollar
31,589
Stat/Skill System(Tested with V.1.3.3)

Please pardon my poor explanation skills, but here's a quick guide to creating random-generated stats for adoptables. Please save back ups before beginning as this works perfectly for my site but I don't know what may happen with yours. Hence, please don't unleash your anger on me if there is anything amiss. :3

This first post shall cover assigning stats to created adoptables.

1. Go to PHPMyAdmin->your site's database->prefix_owned_adoptables
Once there, there should be a "structure" tab at the top of the screen - click that and then scroll to the bottom of the page until you find:

Press go. Then you'll come to a page that looks like this:

There, set the values to match those in the example and press "save".

2. In the "adopt.php" file, there should be something like this from lines 29 to 32:
PHP:
			$name = (!$mysidia->input->post("name"))?$adopt->getType():$mysidia->input->post("name");
		    $alts = $adopt->getAltStatus();
		    $code = $adopt->getCode();
			$gender = $adopt->getGender();
Below that, add:
$statname = rand(minimum value,maximum value);
Then find this on lines 33 to 34:
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 that with (See what was changed?):
PHP:
		    $mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $adopt->getType(), "name" => $name, "statname" => $statname, "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
			                                            "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $gender, "lastbred" => 0));

3. Go to the "breeding.php" file and find this on line 52:
PHP:
 $offspringID = $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num + 1;
Below that, add:
$statname = rand(minimum value,maximum value) ;
and
PHP:
$mysidia->db->update("owned_adoptables",array("statname" => $statname),"aid = $offspringID");

3. Go to the "shop.php" file. You should find this line on line 73:
elseif($mysidia->input->post("shoptype") == "adoptshop"){
Put this under that:
$statname = rand(minimum value,maximum value) ;
And put this under that:
PHP:
$mysidia->db->update("owned_adoptables",array("statname" => $statname),"aid = $offspringID");

4. Go to your "class_promocode.php" file in your "classes" folder. Find this piece of code:
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 it with:
$statname = rand(minimum value,maximum value) ;
Put this under that:
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, "statname" => $statname));

5. Now, read carefully! IF there are existing adoptables on the site, go back to the "adopt.php" file. I couldn't figure out how to give adoptables that were created prior to the addition of the modification their own unique values, but I decided to set the existing adoptables' values to half of the maximum initial value. Right below the edits just made to that file, add:
$mysidia->db->update("owned_adoptables",array("statname" => "value"),"") ;
Once that is done, save all changes to the file but don't close it. After that, go to your site and create a quick free adoptable. Adopt that adoptable once. This will update all adoptables in the database to have the set stat.
Go back to the "adopt.php" file and delete what you just added or right-click and select "undo".

Tada! Please contact me or post in the thread if you have any questions! This includes adding extra stats. The next section shall cover how to display those stats on an adoptable's levelup page.
 
Last edited:
Displaying Stats On Levelup Page

This post will cover how to display stats on an adoptable's 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 $statname;
Add this function to the list of functions below:
public function getAdoptstatname(){
return $this->statname;
}

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:
$adoptablestatname = $this->adopt->getAdoptstatname();
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='stats'>Statname: {$adoptablestatname}</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'>
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);
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);

Tada! The next section will go over the "stat-raising system".
 
Last edited:
Creating Items to Raise Stats

This post will explain how to create items to raise an adoptable's stats.


1. Go to the “item_functions” table in your database. Once there, click the “insert” tab at the top of the page. You should arrive at a page like this:

Fill out the values to match those in the example and then press “Go”.

2.Go to the “functions_items.php” file in the “functions” folder. Add this item function to the list:
PHP:
function items_statname($item, $adopt){ $mysidia = Registry::get("mysidia"); $newstatname = $adopt->statname + $item->value; $mysidia->db->update("owned_adoptables", array("statname" => $newstatname), "aid='{$adopt->aid}'and owner='{$item->owner}'"); $note = "By using {$item->itemname}, the adoptable's Statname raised by {$item->value}!"; $delitem = $item->remove(); return $note; }

3. Go to your “class_privateitem.php” file in the “classes’ folder. See all that case-break stuff? Add this to the list:
PHP:
case "Statname":
            $message = items_Statname($this, $owned_adoptable);
            break;

4. Go to your ACP and create a “Statname” item. Make your you allow it to be consumed!

Tada! The next post shall cover the award system!
 
Last edited:
**Squees **

Okay gonna try this out, thank you soooooooo much for this!!! :)
 
Would you possibly be able to just upload your modded levelup file? I keep getting errors on that part of the changeover of code!


**Also, is there any way to just get the code for your brilliant and beautiful layout? I really am dying to see this as part of my display, it's gorgeous!!



Thank you !
 
Last edited:
Award System

Allowing pets to earn "awards" through training.


1. Go to PHPMyAdmin->your site's database->prefix_owned_adoptables
Once there, there should be a "structure" tab at the top of the screen - click that and then scroll to the bottom of the page until you find:

Press go. Then you'll come to a page that looks like this:

Set the values to match the example shown above and press "save".

2. Remember the item function we made earlier in the "functions_items.php" file? Go there and replace that part of the code with this:
PHP:
 function items_statname($item, $adopt){
  $mysidia = Registry::get("mysidia");
  $newstatname = $adopt->statname + $item->value;
  $mysidia->db->update("owned_adoptables", array("statname" => $newstatname), "aid='{$adopt->aid}'and owner='{$item->owner}'");
  $note = "By using {$item->itemname}, the adoptable's statname raised by {$item->value}!<br>";
  $note2 = "By using {$item->itemname}, the adoptable's statname raised by {$item->value}! It now has 1 statname medal!<br>";
    if($newstatname >= 150) {
  $mysidia->db->update("owned_adoptables", array("statnamemedalstatus" => 'yes'), "aid='{$adopt->aid}'and owner='{$item->owner}'");
  $delitem = $item->remove(); 
  return $note2;
  }
  else{
   $delitem = $item->remove(); 
  return $note;
  }
  }

3. Go to your "class_ownedadoptable.php" file. Add this to the "protected" list:
protected $statnamemedalstatus;
Add this to the list of functions:
public function getAdoptObedienceMedalStatus(){
return $this->obediencemedalstatus;
}

4. Go to "levelup.php" and find this piece of code:
$adoptablestatname = $this->adopt->getAdoptstatname();
Under that, put:
$statnamemedalstatus = $this->adopt->getAdoptStatNameMedalStatus();
PHP:
$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);
Right after:
<div id='stats'>
Statname: {$adoptablestatname}
</div><br>
Add:
<div id ='trainingawards'><img src='{$mysidia->path->getAbsolute()}picuploads/awards/statnamemedalstatus{$statnamemedalstatus}.png'></div>

5. Awards Folder(Zipped)
to your picuploads folder and unzip it.
Here are some Photoshop bases you can color if you want to swap out the images provided in the folder:
Trophy Base
Ribbon Base
Medal Base
If you need non-photshop bases, please tell me.



That's done! Now, you may have noticed that the levelup page might not look as visually-appealing as you want it to be. The next post will take care of that.
 
Last edited:
I'm not sure :3

I will take another crack at this today, but I got a white screen when I did the edits on levelup ... maybe someone else can try and see what you get?

Might be error on my part pretty easy heheh :)
 
Styling The Levelup Page

Styling the levelup page

Ok... just a heads up, I don't really know how to explain this, but I'll give it a shot!


So, do you all remember the "div id" stuff we added to the levelup page earlier on?:
PHP:
$message = $message .= " 
<div id='stats'> 
Statname: {$adoptablestatname} 
</div><br><div id ='trainingawards'><img src='{$mysidia->path->getAbsolute()}picuploads/awards/statnamemedalstatus{$statnamemedalstatus}.png'></div> 
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.";
Go to the CSS stylesheet for your themes and add this:
#stats {
}
#trainingawards {

}
Add CSS code between those brackets to style the boxes the stats and awards are in! I'll make a custom them just for this. :3

Go to this thread for a CSS theme with levelup page styling: Spring Theme
 
Last edited:
^Thanks a bunch! Ehh... it doesn't say what version you're using? Do you think this would work for earlier and later versions?
 
using 1.3.4 ! And it should, but yes using the latest :)

I will see if your levelup works okay on my live site ... and if it does that parts a go!
 
^In that case, that MIGHT be the problem since this was made to work with v.1.3.3.
 
^Nevermind! It was probably a mistake on my part- I caught a lot of miswording and issues. But, the first post works right? COuld you check your database for me?
 
Okay altering adopt and breeding both in the first section cause the dreaded white! page ... I did everything very slowly and carefully and then backtracked. As soon as I inserted '$statname = rand(minimum value,maximum value);' I lost adopt and breeding both!

Even with the table inserted correctly something isn't jibing for the code changes for the first random stats stuff.
 
^Does it work for shop? Let me try and work this with my own files...
 
Umm, would you mind showing me your files... there may be another way to do this... anyways, how does the database look?
 
here's my two files, if you can get this all worked out that will be wonderful ! :)

The Database is fine, it just has the added table --



15 statname int(4) No 0 Change Change Drop Drop
 

Attachments

  • adopt.php
    2.6 KB · Views: 3
  • breeding.php
    3.1 KB · Views: 1
^I don't know why, but your file popped up with no changes? Try this for adopt.php:
PHP:
<?php

use Resource\Native\Integer;
use Resource\Native\String;
use Resource\Native\Arrays;
use Resource\Native\Null;

class AdoptController extends AppController{

    public function __construct(){
        parent::__construct("member");
		$mysidia = Registry::get("mysidia");
		if($mysidia->usergroup->getpermission("canadopt") != "yes"){
		    throw new NoPermissionException("permission");
		}	
    }
	
	public function index(){
	    $mysidia = Registry::get("mysidia");		
	    if($mysidia->input->post("submit")){
		    $this->access = "member";
	        $this->handleAccess();
            $id = $mysidia->input->post("id");
			if($mysidia->session->fetch("adopt") != 1 or !$id) throw new InvalidIDException("global_id");			
			
			$adopt = new Adoptable($id);			    
			$conditions = $adopt->getConditions();
			if(!$conditions->checkConditions()) throw new NoPermissionException("condition");
			
			$name = (!$mysidia->input->post("name"))?$adopt->getType():$mysidia->input->post("name");
		    $alts = $adopt->getAltStatus();
		    $code = $adopt->getCode();
			$gender = $adopt->getGender();
			$statname = rand(0,100);
			
			
			
			
		    $mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $adopt->getType(), "name" => $name, "owner" => $mysidia->user->username, "statname" => $statname, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
			                                               "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'notfortrade', "isfrozen" => 'no', "gender" => $gender, "offsprings" => 0, "lastbred" => 0));
		    			
			$aid = $mysidia->db->select("owned_adoptables", array("aid"), "code='{$code}' and owner='{$mysidia->user->username}'")->fetchColumn();
			$this->setField("aid", new Integer($aid));
            $this->setField("name", new String($name));			
			$this->setField("eggImage", new String($adopt->getEggImage()));
		    return;
		}
		
		$mysidia->session->assign("adopt", 1, TRUE);
        $ids = $mysidia->db->select("adoptables", array("id"), "shop='none'")->fetchAll(PDO::FETCH_COLUMN);
        $total = ($ids)?count($ids):0;
		
		if($total == 0) $adopts = new Null;
		else{		
		    $adopts = new Arrays($total);
			$available = 0;
			
		    foreach($ids as $id){
                $adopt = new Adoptable($id);
			    $conditions = $adopt->getConditions();	
      			if($conditions->checkConditions()) $adopts[$available++] = $adopt;	
            }
			
            if($available == 0) $adopts = new Null;
            else $adopts->setSize($available);			
		}		
		if($adopts instanceof Null) throw new InvalidActionException("adopt_none");
		$this->setField("adopts", $adopts);
	}
}
?>
 
I wanted to mention that the new levelup code is giving me a white page :(

the adopt code IS working, though!
 

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