PDA

View Full Version : Mys 1.3.x Stat/SKill System


Hwona
06-29-2014, 12:55 AM
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:
http://i1290.photobucket.com/albums/b521/Wallie987/Modification%20Guides/Stat%20System%20Images/AddColumn_zpse6034c19.png (http://s1290.photobucket.com/user/Wallie987/media/Modification%20Guides/Stat%20System%20Images/AddColumn_zpse6034c19.png.html)
Press go. Then you'll come to a page that looks like this:
http://i1290.photobucket.com/albums/b521/Wallie987/Modification%20Guides/Stat%20System%20Images/AddingtoDB_zpsa2d07fcb.png (http://s1290.photobucket.com/user/Wallie987/media/Modification%20Guides/Stat%20System%20Images/AddingtoDB_zpsa2d07fcb.png.html)
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:
$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:
$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?):
$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:
$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
$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:
$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:

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

$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.

Hwona
06-29-2014, 12:56 AM
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:
$message = ($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest;
Replace that with:
$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:
$document->setTitle($mysidia->lang->frozen_title);
$document->addLangvar($mysidia->lang->frozen);
With:
$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:
$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".

Hwona
06-29-2014, 12:57 AM
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:
http://i1290.photobucket.com/albums/b521/Wallie987/Modification%20Guides/Stat%20System%20Images/AddingStatnameFunction_zps899d22a0.png (http://s1290.photobucket.com/user/Wallie987/media/Modification%20Guides/Stat%20System%20Images/AddingStatnameFunction_zps899d22a0.png.html)
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:
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:
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!

Missy Master
06-29-2014, 08:35 AM
**Squees **

Okay gonna try this out, thank you soooooooo much for this!!! :)

Missy Master
06-29-2014, 09:15 AM
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 !

Hwona
06-29-2014, 09:40 AM
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:
http://i1290.photobucket.com/albums/b521/Wallie987/Modification%20Guides/Stat%20System%20Images/AddColumn_zpse6034c19.png (http://s1290.photobucket.com/user/Wallie987/media/Modification%20Guides/Stat%20System%20Images/AddColumn_zpse6034c19.png.html)
Press go. Then you'll come to a page that looks like this:
http://i1290.photobucket.com/albums/b521/Wallie987/Modification%20Guides/Stat%20System%20Images/MedalStatusColumn_zps25a230e7.png (http://s1290.photobucket.com/user/Wallie987/media/Modification%20Guides/Stat%20System%20Images/MedalStatusColumn_zps25a230e7.png.html)
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:
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();
$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) (http://www.mediafire.com/download/pisn29w8vmct51d/awards.zip)
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 (http://www.mediafire.com/download/7uax0002nb9g9r5/Trophy_Base.psd)
Ribbon Base (http://www.mediafire.com/download/fzd9t6dd24nrp3z/Ribbon_Base.psd)
Medal Base (http://www.mediafire.com/download/b53730w3clinnn8/Medal_Base.psd)
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.

Missy Master
06-29-2014, 09:55 AM
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 :)

Hwona
06-29-2014, 09:57 AM
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?:
$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 (http://www.mysidiaadoptables.com/forum/showthread.php?p=30537#post30537)

Missy Master
06-29-2014, 10:09 AM
Oh sure I can test it out for you! No problem! :)

Hwona
06-29-2014, 10:16 AM
^Thanks a bunch! Ehh... it doesn't say what version you're using? Do you think this would work for earlier and later versions?

Missy Master
06-29-2014, 10:26 AM
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!

Hwona
06-29-2014, 10:54 AM
^In that case, that MIGHT be the problem since this was made to work with v.1.3.3.

Hwona
06-29-2014, 11:37 AM
^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?

Hwona
06-29-2014, 11:51 AM
Great! I have the level up page ready for download. :3

Missy Master
06-29-2014, 12:12 PM
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.

Hwona
06-29-2014, 12:32 PM
^Does it work for shop? Let me try and work this with my own files...

Hwona
06-29-2014, 12:44 PM
Umm, would you mind showing me your files... there may be another way to do this... anyways, how does the database look?

Missy Master
06-29-2014, 12:52 PM
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

Hwona
06-29-2014, 01:01 PM
^I don't know why, but your file popped up with no changes? Try this for adopt.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);
}
}
?>

Missy Master
06-29-2014, 01:20 PM
I wanted to mention that the new levelup code is giving me a white page :(

the adopt code IS working, though!

Hwona
06-29-2014, 01:24 PM
^Try this for breeding?:
<?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.

Missy Master
06-29-2014, 01:35 PM
Breeding works! So we have adopt and breeding working alright.

Levelup still white pages on me ...

Hwona
06-29-2014, 01:42 PM
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.

Missy Master
06-29-2014, 01:57 PM
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.

Hwona
06-29-2014, 02:11 PM
Umm, the code you got should work:
<?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.

Missy Master
06-29-2014, 02:29 PM
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!

Hwona
06-29-2014, 02:37 PM
^Oh, wait a minute... for the levelup page, did you use the file I provided? THat's 1.3.3..

Missy Master
06-29-2014, 02:54 PM
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!

Hwona
06-29-2014, 03:21 PM
Try this:
<?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.

Missy Master
06-29-2014, 03:33 PM
Nope :(

Still white page .. I am so sorry it's being such a pain

Hwona
06-29-2014, 04:13 PM
Try this:
<?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);
}
}
?>

Missy Master
06-29-2014, 04:17 PM
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!

Hwona
06-29-2014, 04:29 PM
Does v.1.3.4 have the comment() function?

Missy Master
06-29-2014, 04:45 PM
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!

Hwona
06-29-2014, 06:32 PM
Try this code:
<?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.

Missy Master
06-29-2014, 07:14 PM
Aww this one didn't work ... and yeah very true, I'll have to change some of the item amounts allowed.

Hwona
06-29-2014, 08:01 PM
Sorry about that - my mistake!
<?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

Missy Master
06-29-2014, 08:24 PM
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!

Hwona
06-29-2014, 08:54 PM
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.

Missy Master
06-29-2014, 08:59 PM
HOF ? You know this PHP far better than I ...what say you ? :)

Hwona
06-29-2014, 11:54 PM
Ok, let's take this step by step.
Try this code on a non-frozen adopt(refresh the page after clicking):
<?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") 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 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);
}
}
?>
If that magically works, try this on a frozen adopt(refresh the page after clicking):
<?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")
$frozenmessage = "<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.";
throw new LevelupException($frozenmessage);
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 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);
}
}
?>
And if that magically works, try this on all kinds of adopts:
<?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();
$adoptablename = $this->adopt->getName();

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")
$frozenmessage = "<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.";
throw new LevelupException($frozenmessage);
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{
$levelupmessage = "<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>";
throw new LevelupException($levelupmessage);
$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 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);
}
}
?>

If those don't work, I really don't know what to do from there. :L

Missy Master
06-30-2014, 08:48 AM
Ok the first code on a non frozen --- I was able to level and did NOT get the white page of DOOOM.

I refreshed and got this:

An error has occurred.

Statname: 53
You already leveled this Pet today. You may only Boost a Pet once per day. Please come back tomorrow to Boost this Pet again

The *first* code works on frozen and non frozen.

The second and third codes, WHITE OUT ... so we are a lot closer :) At least one code works to some degree, not sure what the Statname 53 error is.

Was there a formatting supposed to show for this? ( the pretty layout like you have? )

.. I didn't see that, not sure if we have that coded in yet.

Hwona
06-30-2014, 08:57 AM
We won't be able to get to that until this levelup thing is fixed - is there a way to do this without the ERROR?! EEEEP!!!
Try this:
<?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 comment($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 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);
}
}
?>

Missy Master
06-30-2014, 09:18 AM
Okay ...THAT code is working perfect now, no error but:

when you try to click again there is a white page. Possibly there is something we are missing in a lang file? I've noticed that often throws a white page, when that's missing or off ( something in lang )

I see what you mean and it might be the comment thing ...

Hwona
06-30-2014, 09:23 AM
Wait, it works but throws a white page at the same time?

Missy Master
06-30-2014, 09:30 AM
You can go level once.

The fails before wouldn't even let you do that without white page.

If you go back to try to re level, it throws white page now with this latest code.

BUT --

The code you had JUST before that ... did work and give the 'already boosted' comment, but it gave that Statname 53 error mentioned too.

Hwona
06-30-2014, 09:40 AM
^Does html work in the lang files?

Missy Master
06-30-2014, 09:40 AM
Ok the previous code where you posted three, and the first one works?

I just realized what that code is doing!

It's pulling the statname result and posting THAT, along with the already leveled message!



Let me see if I can fix it ...

Hwona
06-30-2014, 09:42 AM
^That's what I did for my site. ^.^ If html works for lang files, I may be able to fix it...

Missy Master
06-30-2014, 09:51 AM
Okay I removed this:

$message = "<div id='stats'>Statname: {$adoptablestatname}</div>";


I've attached what I believe to be a working version of levelup for 1.3.4 and thank you so much for all your help and work !! :)

Hwona
06-30-2014, 10:02 AM
Err, it probably would work, but I don't see how it's going to show the stats now...
Try adding this to the lang_levelup file:
$lang['already_leveled_title'] = "You already leveled this adoptable today";

Try this code:
<?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']);
$document = $mysidia->frame->getDocument();
$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);
$document->addLangvar($message);
$document->setTitle($mysidia->lang->already_leveled_title);
}







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

Missy Master
06-30-2014, 10:11 AM
Nope :(

White page immediately on attempt.

No go ..and I really do suspect something with the lang file setting.

Hwona
06-30-2014, 10:16 AM
Try this:
<?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']);
$document = $mysidia->frame->getDocument();
$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);
$document->add(new Comment($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 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);
}
}
?>

Missy Master
06-30-2014, 10:26 AM
Still white page... we really need HOF to help on this possibly.

IntoRain
06-30-2014, 11:51 AM
It might be this?

$message = $message .= (restOfCode)

Try just

$message .= (restOfCode)

or

$message = $message . (restOfCode)

Missy Master
06-30-2014, 11:54 AM
Good call but it didn't change it white paging ....good eye though!

Hwona
06-30-2014, 12:07 PM
^Actually, can you link me to the levelup page where it showed as an error... I want to check something. :3

Missy Master
06-30-2014, 12:12 PM
http://sim-life.com/simpets/levelup/click/1

http://sim-life.com/simpets/stats

There you go :)

Hwona
06-30-2014, 12:22 PM
^Would you mind putting the error code back real quick for me(the one that shows the stats)

Missy Master
06-30-2014, 12:32 PM
http://sim-life.com/simpets/stats

from there clicking gives the white page too. I have the error still happening ( as in white page ) for attempting to Boost any of them.

You can view the stats themselves in myadopts but you cannot Boost ( levelup )

Missy Master
06-30-2014, 12:44 PM
I have to put back the good code now, though, I am opening my sites in a few days and I am crunched for time to get this all ready :)

I am really hoping HOF can possibly swing in here and help, I think this would be a really great mod !!

Hwona
06-30-2014, 01:10 PM
^Okay, I still have to wrap up the v.1.3.3 tutorial and my own site. XP

IntoRain
06-30-2014, 03:10 PM
The error is probably because in the file it's supposed to throw an exception if the adoptable has already been clicked. In 1.3.4 all pages are separated into two files: One manages the controller (database accesses and verifications) and the other (in the folder view) manages what is shown to the user. The exchange of variables between these files is done through a hashmap. What's happening is that, when the user has already clicked an adoptable, this should throw an exception:

elseif($this->adopt->hasVoter($mysidia->user, $date)){
$message = ($mysidia->user instanceof Member)?"already_leveled_member":"already_leveled_guest";
throw new LevelupException($message);
}

And it stops the levelupview.php page from generating text.

If you don't throw an exception there, the view file will try to access two variables called Reward and Adopt, which are set by the controller only in the case they pass all conditions:

(from levelup.php)
else{
//stuff
$this->setField("adopt", $this->adopt);
$this->setField("reward", new Integer($reward));
}

So it's basically trying to use two variables it can't find in the hashmap:

(from levelupview.php)
$adopt = $this->getField("adopt");
$reward = $this->getField("reward")->getValue();


-----

Maybe try setting both variables at the beginning instead of being inside the else clause?

Hwona
06-30-2014, 04:06 PM
^Hmmm... which code would be best to try this with?

Hwona
07-01-2014, 05:58 PM
The guide is now fully updated! :D

Missy Master
07-01-2014, 07:35 PM
That's wonderful!! :)

Hwona
07-01-2014, 08:04 PM
I'm going to try and figure out how to do this with v.1.3.4 now... :L

Kesstryl
07-01-2014, 09:18 PM
This is really great! Please do get it working with the latest version, I love what I'm seeing here!

Hwona
07-01-2014, 10:29 PM
^Oh thank you! Actually, I think everything is compaticle with v.1.3.4(at least the assigning stats to new adopts part). The only part I'm stuck on is displaying information on the levelup page... :3

Hwona
07-02-2014, 02:47 PM
I updated the guide! Promocode adopts can now be assigned stats!(Sorry for forgetting!) Just go to step 4 of the "assigning stats" post and update your code. :3

Abronsyth
09-21-2014, 08:56 AM
Some of the photos on the first, third, and fourth post no longer are up, would you be able to replace them?

Looks like a super cool mod, at any rate!

ilrak
11-02-2014, 08:42 PM
I'd also love to use this mod, but I'm not sure what to enter into the database at the start. ^v^;

parayna
12-11-2014, 07:44 AM
Me too XD The images no longer work ^_^''

Kyttias
12-11-2014, 12:15 PM
Since the images are gone, here's supplementary instructions:

Post 1 (http://www.mysidiaadoptables.com/forum/showpost.php?p=30374&postcount=1): Assigning Stats to Created Adoptables

Open the owned_adoptables table in your database, go to the second tab at the top, which is Structure, at the bottom right of the page there is a Go button that will, by default, add 1 column at the end of the table. Press it, and on the next page it will ask for field data.

For stats that will have number values, intergers, that is, Type INT will suffice:

Name: statname, Type: INT, Length/Values: 11

(If you want a default value, then select 'As defined' in the Default dropdown and supply a value in the new text box provided below it. This will ensure this default value to all pre-existing adoptables.)

Reminder: Whatever statname you choose, you will need to change it in ALL files we're changing, so search for 'statname' in the material this mod is adding and replace it with your own stat's name.

Continue following the steps on Post 1 (http://www.mysidiaadoptables.com/forum/showpost.php?p=30374&postcount=1), starting with Step 2.

Post 2 (http://www.mysidiaadoptables.com/forum/showpost.php?p=30375&postcount=2): Display Stats on an Adoptable's Click Page
For Mysidia v1.3.3, follow instructions in the original Post 2 (http://www.mysidiaadoptables.com/forum/showpost.php?p=30375&postcount=2).
For Mysidia v.1.3.4, the line numbers are wrong, and some things may be difficult to find. If there are questions on the instructions here, let me know and I'll add a write up.

Post 3 (http://www.mysidiaadoptables.com/forum/showpost.php?p=30376&postcount=3): Creating Items to Raise Stats
Open up your database. In the items_functions table, make note of how many rows there are (check out the ifid column for help), hit the word Copy on the row holding the Level1 function. Fill in the first blank with the next number. If you had 13 item functions, this will be 14. Since this is a copy of Level1, rename it. The original instructions imply naming it Statname. The description you can fill in here is mostly for your sake on the admin side of things, and won't be seen by your users.

Continue following the steps on Post 3 (http://www.mysidiaadoptables.com/forum/showpost.php?p=30376&postcount=3), starting with Step 2.

Post 4 (http://www.mysidiaadoptables.com/forum/showpost.php?p=30389&postcount=6): Rewards Through Training
Open the owned_adoptables table in your database, go to the second tab at the top, which is Structure, at the bottom right of the page there is a Go button that will, by default, add 1 column at the end of the table. Press it, and on the next page it will ask for field data.

I'm not exactly sure on the data being inserted here, but I think this will do it???
Name: statnamemedalstatus, Type: VARCHAR, Length/Values: 11

Continue on starting at Step 2, however, Wallie's Step 3 is just an example with a statname of Obedience, yours should be:
public function getAdoptStatNameMedalStatus(){
return $this->statnamemedalstatus;
}

Best of luck!

parayna
12-11-2014, 12:21 PM
Thank you! ^_^

AndromedaKerova
04-19-2015, 10:39 PM
I'd still like to see an example image of the stats since the original images no longer work.

Kyttias
04-20-2015, 01:17 AM
Wallie's site is still up and running, you can find a link to it her signature. Pick a random pet to view (http://caterpillarcave.com/stats/random), then click the first link (or refresh the page) and you'll see a live example.

AndromedaKerova
04-20-2015, 01:45 AM
Looks awesome!
If nobody minds, I've added a screenshot of what I see on the little fuzzies page
http://i.imgur.com/AmNBYDd.png

Abronsyth
01-12-2016, 04:02 PM
For users who want to use this with Mys 1.3.4 there are some adjustments you'll need to make. Firstly, in the first post step 3:
Instead of shop.php, you'll want to go into the file .../classes/class_stockadopt.php, and around line 66 you should see some variables being defined;
$mysidia = Registry::get("mysidia");
$this->owner = (!empty($owner))?$owner:$this->owner;
$alts = $this->getaltstatus(0);
$code = codegen(10, 0);
$genders = array('f', 'm');

Below gender add this;
$statname = rand(min,max) ;
(replace "statname" with the name of your stat, and min with the minimum possible level for the stat, and max with the maximum value)
And then in the string that starts with
$mysidia->db->insert("owned_adoptables", array("aid" => NULL
Add this in somewhere in the array;
"statname" => $statname

---

I will edit this post as I continue adapting it to 1.3.4 :)

Kyttias
01-12-2016, 06:42 PM
In v1.3.4, adoptables are created in five places - adopt.php, admincp/ownedadopt.php, classes/class_breeding.php, classes/class_promocode.php and classes/class_stockadopt.php. You'll want to add stats in all these places.

Otherwise, everyone should be sure to reference this post (http://www.mysidiaadoptables.com/forum/showpost.php?p=31640&postcount=74) from a few up (in it, the post numbers are links to the original versions of posts). I installed on v1.3.4 and really the only thing that changed were line numbers. It's better to search for exact contents than rely on line numbers!!

Oh, and in addition to just number stats, you can also give a pet a random personality, for example --

$personality_array = array('brave','honest','loyal');
shuffle($personality_array);
$personality = $personality[0];


A reminder that when adding this mod, be sure to add a default value while creating a column, that way any existing pets will have that value. It won't be random, but hey, they'll have something.

Abronsyth
01-12-2016, 07:17 PM
Now if only I could get the stat value to show in from the levelupview.php file, haha (unfortunately {$adopt->getStatname()}, {$this->adopt->getStatname()}, and {$statname} do not work, though {$statname} works just fine in the levelup.php file).

Ooh, that's a cool idea, Kyttias!

Kyttias
01-12-2016, 07:48 PM
Try {$adopt->statname}?

Abronsyth
01-12-2016, 08:16 PM
Ended up with this error;
Fatal error: Cannot access protected property OwnedAdoptable::$magic in /home/catisserie/public_html/view/levelupview.php on line 27

(magic being the name of the stat)

Still trying several things to try to work around it.

Kyttias
01-12-2016, 10:01 PM
In classes/class_ownedadoptable.php add public $magic; to the variables at the start.

Abronsyth
01-13-2016, 06:40 AM
Well, it's not coming up with an error now, but instead it's simply displaying a blank where the data should be displayed.
(.../view/levelupview.php):
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->add($image);
$summary->add (new Comment("<ul>
<li><b>Name:</b> {$adopt->getName()}</li>
<li><b>Owner:</b> <a href='/profile/view/{$adopt->getOwner()}'>{$adopt->getOwner()}</a></li>
<li><b>Birthday:</b> {$adopt->getBirthday()}</li>
<li><b>Type:</b> {$adopt->getType()}</li>
<li><b>Sex:</b> {$adopt->getGender()}</li>
<li><b>LVL:</b> {$adopt->getCurrentLevel()}</li>
<li><b>Total EXP:</b> {$adopt->getTotalClicks()}</li>
<li><b>Magic:</b> {$adopt->magic}</li>
</ul>"));
$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 cat. "));
$summary->add(new Comment("You now have {$mysidia->user->getcash()} {$mysidia->settings->cost}"));
$document->add($summary);
}

And, just to make things even more fun, I'm also having a funny issue with the item that raises the stat. For some reason instead of adding +1 to the stat, it sets the stat itself to 1. I'll play around with this, though, and see if I can get it to work by studying the other functions more.

Edit:
OK, I got the function to work by doing this;
function items_magic($item, $adopt){
$mysidia = Registry::get("mysidia");
$magic = $mysidia->db->select("owned_adoptables", array("magic"), "aid='{$adopt->aid}'");
$newmagic = $magic + $item->value;
$mysidia->db->update("owned_adoptables", array("magic" => $newmagic), "aid='{$adopt->aid}'and owner='{$item->owner}'");
$note = "By using {$item->itemname}, the cat's magical skill has raised by {$item->value}! This cat now has {$newmagic} skill!<br>";
//Update item quantity...
$delitem = $item->remove();
return $note;
}
So at least I fixed that issue ^^

Kyttias
01-13-2016, 09:36 AM
*shrug* Bizarre. This is exactly what I use for my pet's personality (so, same concept of rendering it to levelupview.php):

This is a {$adopt->size}-sized, {$adopt->nature} {$adopt->type} that likes {$adopt->likes} and dislikes {$adopt->dislikes}.

Keeping in mind that in just levelup.php it has to be:

This is a {$this->adopt->size}-sized, {$this->adopt->nature} {$this->adopt->type} that likes {$this->adopt->likes} and dislikes {$this->adopt->dislikes}.

Because it wants the '$this' involved.

If you really wanted to you could create a function by copying over one of the existing ones in class_ownedadoptable.php but it seems really redundant.

Then again, I also display my birthdays with just $adopt->birthday and you should also really be able to call gender with just $adopt->gender (after making it no longer protected). At least in v1.3.4, because of how things pull from the database. Basically any column name should be able to show up this way. Check if there's value in it for that specific adopt???

Abronsyth
01-13-2016, 04:50 PM
There is indeed a value in for that adopt (and for all of them I've tested), but it simply will not show up (though it does show up when I re-visit that adopt so it loads the "you've already seen this pet today" page). I've even tried adding the function to the levelupview.php page. I'm having the same issue with displaying the "medals" with the levelupview.php file, as well. What's really odd is that I use {$adopt->getBirthday();} to show the adoptable's birth-date, and that shows up just fine, so I do not understand why {$adopt->getMagic();} isn't working, since they're both defined in all the same places, the same way in class_ownedadoptable.php:
public function getBirthday(){
return $this->birthday;
}

public function getMagic(){
return $this->magic;
}

public function getMagicMedalStatus(){
return $this->magicmedalstatus;
}

aiiree
03-24-2016, 05:51 PM
Does anyone have a copy of the screenshots for this mod since the images aren't avalible in the first post?

:)

Ittermat
03-24-2016, 06:03 PM
Heres the post kyttias made to try to help explain the parts from the images

http://mysidiaadoptables.com/forum/showpost.php?p=31640&postcount=74

aiiree
03-25-2016, 10:27 AM
Thank you!

Sorry, Is there a way to have more than one stat, would I just add another colum or would it change the directions? I'm fairly new thisthis so I'm not really sure.

Kyttias
03-25-2016, 11:15 AM
Yes! Just add more columns as necessary. You could technically even store minipet data with a pet this way - just a thought. Letting user's name their pet's minipet would be more complicated, but, just displaying an image by the pet of a minipet species would be really easy - so long as the data in the column correlates to a file name. I personally use this mod just to show pets likes/dislikes/personality.

Ruri Lesavka
06-15-2016, 04:50 AM
Is there a way to do a max limit for a stat? I want to do a stat like hp or energy that doesn't go beyond a certain number like 10 or 100. Exploring will take down the stat a random number but giving the pet food will increase the stat again. I don't want it to go past the max number.

ffsharriet
01-15-2017, 10:04 AM
The photos aren't showing?