Log in

View Full Version : Active pet widget?


Ittermat
03-05-2016, 04:02 PM
EDIT: heres the post with the working code- (http://mysidiaadoptables.com/forum/showpost.php?p=34228&postcount=26)


How would I make a thing to display on my side bar that shows your active/spotlight pet? And maybe make them say random things?

So for a picture example- and we'll say this pets name is...Marian?

-----------------------------
http://atrocity.mysidiahost.com/picuploads/png/c130f7955dbfe6ac72e874b9045b182f.png

Marian says: "Lets go exploring!"
_____________________________

But that there would be a list of different things you can make them say? So it would choose from a random assortment of Phrases Or sometimes nothing at all? Possibly depending on the pet species if possible?

So one species would have a different List of things they could say.
But if thats too hard its fine XD Same list is okay.

I was just wondering if this was possible. and if so how it would be done.

Kyttias
03-05-2016, 05:18 PM
To make a favpet display inthe sidebar, first in the AdminCP you'll create a module (surprisingly not a widget):
http://fc03.deviantart.net/fs71/f/2015/013/e/a/sc_by_kyttias-d8dr0j8.png

Then in classes/class_sidebar.php you'll need to add these functions:

public function getFavPetSB(){
return $this->FavPetSB;
}

protected function setFavPetSB(){
$mysidia = Registry::get("mysidia");

$userfavpet = $mysidia->db->select("users_profile", array("favpet"), "username = '{$mysidia->user->username}'")->fetchColumn();
if ($this->userfavpet == "0"){
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
}
else{
$adopt = new OwnedAdoptable($userfavpet);
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>Favorite Pet!</b> <br/>
<a href='/myadopts/manage/{$userfavpet}'><img src='{$adopt->getImage()}'></a>
"));
}

$this->setDivision($this->FavPetSB);
}


Using "$adopt = new OwnedAdoptable($userfavpet);" you can also pull up data like {$adopt->getName()} and {$adopt->getCurrentLevel()} - these are functions found in classes/class_ownedadoptable.php, but you should also be able to use {$adopt->type} (which is not a function) to pull raw data from the database from the 'type' column - this holds the species.

But I'll get back to that. Let me know if you can at least get the pet into the sidebar and then I'll be back later help you set up a switch statement to display random phrases for pets to say. :meow:

Ittermat
03-05-2016, 05:31 PM
thank you! I'll mess with it and get back to you after I eat dinner!! ^^

Ittermat
03-05-2016, 05:53 PM
Yup Got him in the sidebar! Whats next? ^___^

Corsair
03-06-2016, 11:23 AM
Ittermat do you mind if I use this too? I was going to screw around with the code to try to make a active pet too.

Ittermat
03-06-2016, 11:47 AM
Of course not! Lol ^^

Ittermat
03-07-2016, 05:38 PM
Also another question- what if I wanted that pet to randomly find items or money- or have "fake" Status effects happen to it?

Kyttias
03-07-2016, 06:49 PM
That can be done, too. :pleased: Sounds quite fun, really! (I had work today so I'm super tired. I should be be able to get to this tomorrow, though.)

Ittermat
03-07-2016, 07:33 PM
no its fine! get some rest! Help me when you can ^^ thank you!! <3

Kyttias
03-08-2016, 11:19 AM
We're going to set it up like this: 1% of the time the pet may get a status effect. Of the 99% of the time that the pet does not come away with a status effect, 75% of the remaining time - nothing will happen at all. Of the other 25% of the time, 5% of the time it will either be because it found some money or an item (about 50% toward either). The remaining 20% of the time it will say a random phrase based on its species. Below is commented but empty code just to get the odds of each event happening right:
$status_chance = mt_rand(1, 100);
if ($status_chance <= 1){ # One percent chance the pet will obtain a status effect.
/* We would apply a status effect here...*/
} else { # Ninety-nine percent chance the pet will not get a status effect. Will something else happen?
$something_chance = mt_rand(1, 100);
if ($something_chance <= 25){ # Twenty-five percent chance something will happen.
$gift_chance = mt_rand(1, 100);
if ($gift_chance <= 5){ # Five percent chance the user will receive a gift from their pet.
$item_chance = mt_rand(1, 100);
if ($item_chance <= 50){ # Fifty percent chance the gift from their pet will be an item.
/* The pet has found an item for you! */
} else { # Fifty percent chance the gift from their pet will be money.
/* The pet has found some money for you! */
}
} else { # Twenty percent chance the pet will talk but have no gift.
/* No gift will be given but a neat species-specific phrase can still be said! */
}
} else { # Seventy-five percent chance nothing will happen whatsoever.
/* Nothing will happen with the pet at all. */
}
}

Basically, just a tower of if-else statements so far, using PHP's built in mt_rand() function - we're feeding it the numbers 1 and 100 so it'll choose a random number between the two, just like rolling (if possible) a 100-sided dice. It's the easiest way to fudge in percents.

More soon! I've got to go look up some of the code I've used to give items and such again.

1) Is it alright if items and money are automatically collected, even without the user clicking or doing anything? It becomes much more complicated otherwise.

2) Inevitably if you wanted to, say, make it so your active pet can find an abandoned egg 1/500th of the time (about 0.2% chance of happening) but require that the user also be paying attention and clicking that message, remind me - I should be able to think this one through, given enough time. Let me know if this is something you want.

3) These percents should all be easy to modify. Let me know if you have questions and I can help tweak the code. If you change an mt_rand(1,100) to mt_rand(1,200) you will literally make something twice as hard to get and this will be relevant as soon as you want things to happen less than 1% of the time. One percent of that (1,200) would be 0.5% instead of (1,100)'s obvious 1%.

4) The fake status... placeholders for potentially real ones later? Is there a list of random events (nice ones are better than mean ones) you'd be interested in? Such as the pet suddenly gaining experience (as if clicked) or an entire level (if it's not frozen)? More complicated things (that existing item functions can't do) I might be interested in helping out with later, once everything else is done. For now, status effects will be the last on the list of things I'll do, and we'll fill it in with a message of "a status effect would have happened here" so long as we're testing. There are also some ideas I have that would be optional status effects that would require the user to click to accept and have it explained that the changes are somewhat permanent but entirely optional - such as the pet's gender or species changing, or the species' alternate appearance activated. Most of the time the user would be enthusiastically agreeing to this change but what if they really like their pet exactly how it is? We wouldn't want to force something, no matter how cool we think it is.

Ittermat
03-08-2016, 12:15 PM
Yes automatically getting the items and money is fine! Also no need to worry about 2 right now..maybe later? And 3 ill mess with lol. As for status effects is it possible to give me bases for what different things can be done? Id like the effects to do things to them, and if possible have the pet say something like if they gain am item or lose money or something? But im unsure what i want the status effects to say lol..ill think more on it and use what you gave me when i get home from work ^_^

Also thank you again you are amazing!

_______

EDIT EDIT:

Heres some ideas for status effects.. if you give me the base coding to use I can modify from there for these. (like have it set the effects- but allow me to change what it says and add more of them to it you know?)

Status effects:

-Looks like ( Petname) found a some food! They've gained some exp! (Gains Clicks)

- (petname) Ate some garbage! Gross!

-Oh no! (Petname) has been cursed! (Clicks reset for day)

-They grow up so fast dont they? Lets fix that! (petname) is now a baby again! (reverts to baby stage)

-(petname) Won a fight! They gained a level! (gains one level)

-The love fairy came by and waved her wand! (petname) can now breed again! (enables breeding again)

-A mad scientist is loose! (Petname) no longer has species barriers when being bred! (Enables cross species breeding)

-----



Edit: Where do I put this code in at btw?

Hall of Famer
03-09-2016, 06:07 PM
Well when debugging your site, I find that it has a very serious glitch resulted from this Active Pet Module. For a newly registered user, they do not own any adoptable yet, and therefore do not have favorite pet. However, the script assumes that this new user has favorite pet, and try to fetch the adoptable ID 0 instead(favorite pet ID defaults to 0 if it does not exist). This leads to an uncaught exception 'adoptable ID does not exist', and will prevent any newly registered users from browsing your site.

To fix this, you need to take care of the scenario in which the user has no favorite pet(ID = 0). In this case, you will either just not fetch adoptable at all, or catch exception using a try...catch block. The choice is up to you.


Edit: Strangely the solution Kyttias offered seems to have taken care of nonexistent favorite pet ID already, but when I dont have a favorite pet I still receive errors. Did you copy/paste her code exactly? Or something else is wrong?

Ittermat
03-09-2016, 06:31 PM
I copy pasted..the first code she put up- but i havent done anything with her second one since Im not sure exactly where to put it.

Kyttias
03-09-2016, 06:34 PM
The code (with all the percent discussion) isn't done yet/doesn't do anything yet. It'll go inside the setFavPetSB() we made, inside the else half of the if statement, all this inside class_sidebar.php.

:happyc: Sorry, I've had along day and don't think I can work on this tonight - good news is that I don't have work again until at least Sunday so I'll have a few days to think on all of this.

edit - @HoF, I vaguely remember this issue but I'm not sure how it was resolved. =/

Ittermat
03-09-2016, 06:35 PM
no its fine kyttias! I know you have a life... Im sorry to be so bothersome..Im seriously bad at this coding thing...I am trying to learn though honest...its just not clicking or sticking..

Ittermat
03-10-2016, 02:44 PM
I tried to fix the error- but couldnt so for now I just removed the active pet widget until we can figure out how to fix that problem XD

Ittermat
03-20-2016, 12:33 PM
Did we ever figure out how to fix this?

I even made an adoptable to put in its place-when one has no favorite pet

http://i63.tinypic.com/1zc0c50.jpg

The Adoptable id (in adopt_Adoptables table) is 30

if that helps any?

Kyttias
03-20-2016, 02:03 PM
Actually the above won't work because if the user doesn't own pet 30 it might cause errors.

Send me the code we put in classes/class_sidebar.php - I'd like to make some changes to it.

protected function setFavPetSB(){
$mysidia = Registry::get("mysidia");
$profile = $mysidia->user->getprofile();

if ($this->userfavpet == "0"){
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
}

if ($profile->getFavpetID() != "0"){
$favpet = new OwnedAdoptable($profile->getFavpetID());
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>Favorite Pet!</b> <br/>
<a href='/myadopts/manage/{$favpet}'><img src='{$favpet->getImage()}'></a>
"));
}

$this->setDivision($this->FavPetSB);
}

I'm changing where we get information from, basically. And then we're more closely checking only if its zero or not zero. If it's empty, at least it won't error.

If you're afraid of editting the code, I can do it.

Ittermat
03-20-2016, 02:07 PM
all of the coding you gave me is on the first page.. 0.o....I havent done anything to it..
Also im not sure how I would edit it... XD

Kyttias
03-20-2016, 02:25 PM
If you haven't done anything to it then you should be able to just replace it.

Ittermat
03-20-2016, 02:26 PM
so just put the code you put up there in my sidebar file?

Kyttias
03-20-2016, 02:31 PM
We created setFavPetSB() before, just replace the old setFavPetSB() we made with the new setFavPetSB() above, yeah.

Ittermat
03-20-2016, 02:36 PM
When I do that I get this error..

Catchable fatal error: Argument 1 passed to Sidebar::setDivision() must be an instance of GUIComponent, null given, called in /home/atrocity/public_html/classes/class_sidebar.php on line 235 and defined in /home/atrocity/public_html/classes/class_sidebar.php on line 62

this is what my line 62-68 looks like

protected function setDivision(GUIComponent $module){
if(!$this->division){
$this->division = new Division;
$this->division->setClass("sidebar");
}
$this->division->add($module);
}

And this is line 235

$this->setDivision($this->FavPetSB);
}

Kyttias
03-20-2016, 05:48 PM
I'm gonna need the whole file.

Ittermat
03-20-2016, 06:00 PM
okay jas...

Mind you I dont have the code you gave me in this- because it causes an error... so its omitted..I was gonna add it again once we figured out how to fix it.

<?php

/**
* The Sidebar Class, defines a standard HTML Sidebar component.
* It extends from the Widget class, while adding its own implementation.
* @category Resource
* @package Widget
* @author Hall of Famer
* @copyright Mysidia Adoptables Script
* @link http://www.mysidiaadoptables.com
* @since 1.3.3
* @todo Not much at this point.
*
*/

class Sidebar extends Widget{

/**
* The moneyBar property, specifies the money/donation bar for members.
* @access protected
* @var Paragraph
*/
protected $moneyBar;

/**
* The linksBar property, stores all useful links for members.
* @access protected
* @var Paragraph
*/
protected $linksBar;

/**
* The wolBar property, determines the who's online url in the sidebar.
* @access protected
* @var Link
*/
protected $wolBar;

/**
* The loginBar property, specifies the loginBar for guests.
* @access protected
* @var FormBuilder
*/
protected $loginBar;

/**
* Constructor of Sidebar Class, it initializes basic sidebar properties
* @access public
* @return Void
*/
public function __construct(){
parent::__construct(4, "sidebar");
}

/**
* The setDivision method, setter method for property $division.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @param GUIComponent $module
* @access protected
* @return Void
*/
protected function setDivision(GUIComponent $module){
if(!$this->division){
$this->division = new Division;
$this->division->setClass("sidebar");
}
$this->division->add($module);
}
/**
* The getMoneyBar method, getter method for property $moneyBar.
* @access public
* @return Paragraph
*/
public function getMoneyBar(){
return $this->moneyBar;
}

/**
* The setMoneyBar method, setter method for property $moneyBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;
$this->moneyBar->add(new Comment("You have <span id='cashonhand'>{$mysidia->user->money}</span> {$mysidia->settings->cost}."));

$donate = new Link("donate");
$donate->setText("Donate Money to Friends");
$this->moneyBar->add($donate);
$this->setDivision($this->moneyBar);
}

/**
* The getLinksBar method, getter method for property $linksBar.
* @access public
* @return Paragraph
*/
public function getLinksBar(){
return $this->linksBar;
}

/**
* The setLinksBar method, setter method for property $linksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinksBar(){
$mysidia = Registry::get("mysidia");
$this->linksBar = new Paragraph;
$linkTitle = new Comment("{$mysidia->user->username}'s Links:");
$linkTitle->setBold();
$this->linksBar->add($linkTitle);

$linksList = new LinksList("ul");
$this->setLinks($linksList);

$this->linksBar->add($linksList);
$this->setDivision($this->linksBar);
}

/**
* The setLinks method, append all links to the LinksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinks(LinksList $linksList){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("links", array("id", "linktext", "linkurl"), "linktype = 'sidelink' ORDER BY linkorder");
if($stmt->rowCount() == 0) Throw new Exception("There is an error with sidebar links, please contact the admin immediately for help.");

while($sideLink = $stmt->fetchObject()){
$link = new Link($sideLink->linkurl);
$link->setText($sideLink->linktext);
if($sideLink->linkurl == "messages"){
$num = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->rowCount();
if($num > 0) $link->setText("<b>{$link->getText()} ({$num})</b>");
}
$link->setListed(TRUE);
$linksList->add($link);
}

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);
}
}

/**
* The getWolBar method, getter method for property $wolBar.
* @access public
* @return LinksList
*/
public function getWolBar(){
return $this->wolBar;
}

/**
* The setWolBar method, setter method for property $wolBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setWolBar(){
$mysidia = Registry::get("mysidia");
$this->wolBar = new Link("online");
$online = $mysidia->db->select("online", array(), "username != 'Visitor'")->rowCount();
$offline = $mysidia->db->select("online", array(), "username = 'Visitor'")->rowCount();
$this->wolBar->setText("This site has {$online} members and {$offline} guests online.");
$this->setDivision($this->wolBar);
}

/**
* The getLoginBar method, getter method for property $loginBar.
* @access public
* @return FormBuilder
*/
public function getLoginBar(){
return $this->loginBar;
}

/**
* The setLoginBar method, setter method for property $loginBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLoginBar(){
$this->loginBar = new FormBuilder("login", "login", "post");
$loginTitle = new Comment("Member Login:");
$loginTitle->setBold();
$loginTitle->setUnderlined();
$this->loginBar->add($loginTitle);

$this->loginBar->buildComment("username: ", FALSE)
->buildTextField("username")
->buildComment("password: ", FALSE)
->buildPasswordField("password", "password", "", TRUE)
->buildButton("Log In", "submit", "submit")
->buildComment("Don't have an account?");

$register = new Link("register");
$register->setText("Register New Account");
$register->setLineBreak(TRUE);
$forgot = new Link("forgotpass");
$forgot->setText("Forgot Password?");

$this->loginBar->add($register);
$this->loginBar->add($forgot);
$this->setDivision($this->loginBar);
}
}
?>

Kyttias
03-20-2016, 08:39 PM
<?php

/**
* The Sidebar Class, defines a standard HTML Sidebar component.
* It extends from the Widget class, while adding its own implementation.
* @category Resource
* @package Widget
* @author Hall of Famer
* @copyright Mysidia Adoptables Script
* @link http://www.mysidiaadoptables.com
* @since 1.3.3
* @todo Not much at this point.
*
*/

class Sidebar extends Widget{

/**
* The moneyBar property, specifies the money/donation bar for members.
* @access protected
* @var Paragraph
*/
protected $moneyBar;

/**
* The linksBar property, stores all useful links for members.
* @access protected
* @var Paragraph
*/
protected $linksBar;

/**
* The wolBar property, determines the who's online url in the sidebar.
* @access protected
* @var Link
*/
protected $wolBar;

/**
* The loginBar property, specifies the loginBar for guests.
* @access protected
* @var FormBuilder
*/
protected $loginBar;

/**
* Constructor of Sidebar Class, it initializes basic sidebar properties
* @access public
* @return Void
*/
public function __construct(){
parent::__construct(4, "sidebar");
}

/**
* The setDivision method, setter method for property $division.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @param GUIComponent $module
* @access protected
* @return Void
*/
protected function setDivision(GUIComponent $module){
if(!$this->division){
$this->division = new Division;
$this->division->setClass("sidebar");
}
$this->division->add($module);
}



#
#
#
/**** BEGIN: FOR THE FAVPET WIDGET ****/
public function getFavPetSB(){
return $this->FavPetSB;
}

protected function setFavPetSB(){
$mysidia = Registry::get("mysidia");
$profile = $mysidia->user->getprofile();

/* IF THE USER DOES *NOT* HAVE A FAVPET: */
if ($profile->getFavpetID() == "0"){
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
}

/* IF THE USER *DOES* HAVE A FAVPET: */
if ($profile->getFavpetID() != "0"){
$favpet = new OwnedAdoptable($profile->getFavpetID());
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>Favorite Pet!</b>"));
$this->FavPetSB->add(new Comment("{$message}"));
$this->FavPetSB->add(new Comment("<a href='/myadopts/manage/{$profile->getFavpetID()}'><img src='{$favpet->getImage()}'></a>"));

#
#
#
/**** BEGIN: CREATE RANDOM MESSAGES ****/
$message = "<div class='speechbubble'>";

$status_chance = mt_rand(1, 100);
if ($status_chance <= 1){ # One percent chance the pet will obtain a status effect.

/* We would apply a status effect here...*/
$message .= "Placeholder text: A status effect would have happened here!";
#### We'll do this later!!!

} else { # Ninety-nine percent chance the pet will not get a status effect. Will something else happen?
$something_chance = mt_rand(1, 100);
if ($something_chance <= 25){ # Twenty-five percent chance something will happen.
$gift_chance = mt_rand(1, 100);
if ($gift_chance <= 5){ # Five percent chance the user will receive a gift from their pet.
$item_chance = mt_rand(1, 100);
if ($item_chance <= 50){ # Fifty percent chance the gift from their pet will be an item.

/* The pet has found an item for you! */
$num = mt_rand(1,4); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $item = "Fancy Cupcake"; break;
case 2: $item = "Delicious Icecream"; break;
case 3: $item = "Savory Sweet"; break;
case 4: $item = "Shiny Gem"; break;
}
$message .= "I found a {$item} for you!";
$newitem = new StockItem($item);
$newitem->append(1, $mysidia->user->username);

} else { # Fifty percent chance the gift from their pet will be money.

/* The pet has found some money for you! */
$currency = $mysidia->settings->cost;
$amount = mt_rand(100, 1000); # Between 100 and 1000
$message .= "Found {$amount} {$currency}!";
$mysidia->user->changecash($amount);

}
} else { # Twenty percent chance the pet will talk but have no gift.
/* No gift will be given but a neat species-specific phrase can still be said! */

$species = $favpet->type;

switch ($species){
case "Cat": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,4); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
}
break;

case "Dog":
$num = mt_rand(1,4);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
}
break;

default: # If the species isn't defined above, it'll choose one of these default phrases instead.
$num = mt_rand(1,4);
switch ($num){
case 1: $message .= "What an awesome day!"; break;
case 2: $message .= "Hey, did you know you're amazing?!"; break;
case 3: $message .= "Inner beauty is important!"; break;
case 4: $message .= "You look fantastic today!"; break;
}
break;
}

}
} else { # Seventy-five percent chance nothing will happen whatsoever.
/* Nothing will happen with the pet at all. */
$message = "";
}
}

if ($message == "") { $message = ""; } else { $message .= "</div>"; }
/**** END: CREATE RANDOM MESSAGES ****/
#
#
#

}
$this->setDivision($this->FavPetSB);
}
/**** END: FOR THE FAVPET WIDGET ****/
#
#
#









/**
* The getMoneyBar method, getter method for property $moneyBar.
* @access public
* @return Paragraph
*/
public function getMoneyBar(){
return $this->moneyBar;
}

/**
* The setMoneyBar method, setter method for property $moneyBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;
$this->moneyBar->add(new Comment("You have <span id='cashonhand'>{$mysidia->user->money}</span> {$mysidia->settings->cost}."));

$donate = new Link("donate");
$donate->setText("Donate Money to Friends");
$this->moneyBar->add($donate);
$this->setDivision($this->moneyBar);
}

/**
* The getLinksBar method, getter method for property $linksBar.
* @access public
* @return Paragraph
*/
public function getLinksBar(){
return $this->linksBar;
}

/**
* The setLinksBar method, setter method for property $linksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinksBar(){
$mysidia = Registry::get("mysidia");
$this->linksBar = new Paragraph;
$linkTitle = new Comment("{$mysidia->user->username}'s Links:");
$linkTitle->setBold();
$this->linksBar->add($linkTitle);

$linksList = new LinksList("ul");
$this->setLinks($linksList);

$this->linksBar->add($linksList);
$this->setDivision($this->linksBar);
}

/**
* The setLinks method, append all links to the LinksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinks(LinksList $linksList){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("links", array("id", "linktext", "linkurl"), "linktype = 'sidelink' ORDER BY linkorder");
if($stmt->rowCount() == 0) Throw new Exception("There is an error with sidebar links, please contact the admin immediately for help.");

while($sideLink = $stmt->fetchObject()){
$link = new Link($sideLink->linkurl);
$link->setText($sideLink->linktext);
if($sideLink->linkurl == "messages"){
$num = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->rowCount();
if($num > 0) $link->setText("<b>{$link->getText()} ({$num})</b>");
}
$link->setListed(TRUE);
$linksList->add($link);
}

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);
}
}

/**
* The getWolBar method, getter method for property $wolBar.
* @access public
* @return LinksList
*/
public function getWolBar(){
return $this->wolBar;
}

/**
* The setWolBar method, setter method for property $wolBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setWolBar(){
$mysidia = Registry::get("mysidia");
$this->wolBar = new Link("online");
$online = $mysidia->db->select("online", array(), "username != 'Visitor'")->rowCount();
$offline = $mysidia->db->select("online", array(), "username = 'Visitor'")->rowCount();
$this->wolBar->setText("This site has {$online} members and {$offline} guests online.");
$this->setDivision($this->wolBar);
}

/**
* The getLoginBar method, getter method for property $loginBar.
* @access public
* @return FormBuilder
*/
public function getLoginBar(){
return $this->loginBar;
}

/**
* The setLoginBar method, setter method for property $loginBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLoginBar(){
$this->loginBar = new FormBuilder("login", "login", "post");
$loginTitle = new Comment("Member Login:");
$loginTitle->setBold();
$loginTitle->setUnderlined();
$this->loginBar->add($loginTitle);

$this->loginBar->buildComment("username: ", FALSE)
->buildTextField("username")
->buildComment("password: ", FALSE)
->buildPasswordField("password", "password", "", TRUE)
->buildButton("Log In", "submit", "submit")
->buildComment("Don't have an account?");

$register = new Link("register");
$register->setText("Register New Account");
$register->setLineBreak(TRUE);
$forgot = new Link("forgotpass");
$forgot->setText("Forgot Password?");

$this->loginBar->add($register);
$this->loginBar->add($forgot);
$this->setDivision($this->loginBar);
}
}
?>

We're going to go with that for now. IT HASN'T BEEN TESTED.

This has added the chance for the pet to say random phrases, find money, and items - so do look it over! You'll want to change the item names to actual items you have right away that way no errors are thrown when it tries to add an item that doesn't exist. :wutno:

The message that pet says will show up in a div with a class of "speechbubble" so if you want to add some css for that in your stylesheet, go for it.

Ittermat
03-20-2016, 10:22 PM
Thank you so much kyttias!! I'll test it out <3 and get back with you!

Ittermat
03-20-2016, 10:42 PM
It still gives me this error if I have no favorite pet..

Fatal error: Call to a member function getFavpetID() on null in /home/atrocity/public_html/classes/class_sidebar.php on line 91

It apparently still does it even when I DO have a favorite pet

Kyttias
03-20-2016, 11:16 PM
Oh! Sorry, line 82 is wrong!

Instead of:
$userfavpet = $mysidia->db->select("users_profile", array("favpet"), "username = '{$mysidia->user->username}'")->fetchColumn();
It should be:
$profile = $mysidia->user->getprofile();

Ittermat
03-20-2016, 11:21 PM
okay now when I dont have a fave pet I get this

Catchable fatal error: Argument 1 passed to Sidebar::setDivision() must be an instance of GUIComponent, null given, called in /home/atrocity/public_html/classes/class_sidebar.php on line 278 and defined in /home/atrocity/public_html/classes/class_sidebar.php on line 62

and when I do have a fave pet I get this-

Catchable fatal error: Method OwnedAdoptable::__toString() must return a string value in /home/atrocity/public_html/classes/class_sidebar.php on line 96

Kyttias
03-20-2016, 11:49 PM
Ok you've made some major changes to the code because those line numbers don't correlate to anything. =/ You'll have to send me the entire code with your changes for me to fix a basic syntax error, probably. (You have to be really carefully about making sure closing brackets and quotes are never ever broken or interrupted in any way.)

I've tested it now on my site and it IS working.
http://orig09.deviantart.net/166e/f/2016/080/7/6/activepet_by_kyttias-d9w06wl.gif and http://orig11.deviantart.net/60b0/f/2016/080/0/e/noactivepet_by_kyttias-d9w085i.png

I did make a couple tiny edits just now (just to fix the div surrounding the text, it would break when a message was not there and double up accidentally, and so I fixed both) - but should have nothing to do with whether or not you have a pet.

Ittermat
03-20-2016, 11:53 PM
I just added in the items, the actual pet breeds and some more stuff for them to say 0.o


<?php

/**
* The Sidebar Class, defines a standard HTML Sidebar component.
* It extends from the Widget class, while adding its own implementation.
* @category Resource
* @package Widget
* @author Hall of Famer
* @copyright Mysidia Adoptables Script
* @link http://www.mysidiaadoptables.com
* @since 1.3.3
* @todo Not much at this point.
*
*/

class Sidebar extends Widget{

/**
* The moneyBar property, specifies the money/donation bar for members.
* @access protected
* @var Paragraph
*/
protected $moneyBar;

/**
* The linksBar property, stores all useful links for members.
* @access protected
* @var Paragraph
*/
protected $linksBar;

/**
* The wolBar property, determines the who's online url in the sidebar.
* @access protected
* @var Link
*/
protected $wolBar;

/**
* The loginBar property, specifies the loginBar for guests.
* @access protected
* @var FormBuilder
*/
protected $loginBar;

/**
* Constructor of Sidebar Class, it initializes basic sidebar properties
* @access public
* @return Void
*/
public function __construct(){
parent::__construct(4, "sidebar");
}

/**
* The setDivision method, setter method for property $division.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @param GUIComponent $module
* @access protected
* @return Void
*/
protected function setDivision(GUIComponent $module){
if(!$this->division){
$this->division = new Division;
$this->division->setClass("sidebar");
}
$this->division->add($module);
}



#
#
#
/**** BEGIN: FOR THE FAVPET WIDGET ****/
public function getFavPetSB(){
return $this->FavPetSB;
}

protected function setFavPetSB(){
$mysidia = Registry::get("mysidia");
$profile = $mysidia->user->getprofile();

/* IF THE USER DOES *NOT* HAVE A FAVPET: */
if ($this->userfavpet == "0"){
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
}

/* IF THE USER *DOES* HAVE A FAVPET: */
if ($profile->getFavpetID() != "0"){
$favpet = new OwnedAdoptable($profile->getFavpetID());
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>Favorite Pet!</b>"));
$this->FavPetSB->add(new Comment("<div class='speechbubble'>{$message}</div>"));
$this->FavPetSB->add(new Comment("<a href='/myadopts/manage/{$favpet}'><img src='{$favpet->getImage()}'></a>"));

#
#
#
/**** BEGIN: CREATE RANDOM MESSAGES ****/
$message = "<div class='speechbubble'>";

$status_chance = mt_rand(1, 100);
if ($status_chance <= 1){ # One percent chance the pet will obtain a status effect.

/* We would apply a status effect here...*/
$message .= "Placeholder text: A status effect would have happened here!";
#### We'll do this later!!!

} else { # Ninety-nine percent chance the pet will not get a status effect. Will something else happen?
$something_chance = mt_rand(1, 100);
if ($something_chance <= 25){ # Twenty-five percent chance something will happen.
$gift_chance = mt_rand(1, 100);
if ($gift_chance <= 5){ # Five percent chance the user will receive a gift from their pet.
$item_chance = mt_rand(1, 100);
if ($item_chance <= 50){ # Fifty percent chance the gift from their pet will be an item.

/* The pet has found an item for you! */
$num = mt_rand(1,5); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $item = "Ball of Yarn"; break;
case 2: $item = "Bernard plushie"; break;
case 3: $item = "Madeline plushie "; break;
case 4: $item = "Maria plushie"; break;
case 4: $item = "Honey comb"; break;
}
$message .= "I found a {$item} for you!";
$newitem = new StockItem($item);
$newitem->append(1, $mysidia->user->username);

} else { # Fifty percent chance the gift from their pet will be money.

/* The pet has found some money for you! */
$currency = $mysidia->settings->cost;
$amount = mt_rand(100, 1000); # Between 100 and 1000
$message .= "Found {$amount} {$currency}!";
$mysidia->user->changecash($amount);

}
} else { # Twenty percent chance the pet will talk but have no gift.
/* No gift will be given but a neat species-specific phrase can still be said! */

$species = $favpet->type;

switch ($species){
case "Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "silver tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "ginger tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "tuxedo tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "Black and white Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "brown and black Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "Black and white floopy eared Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

default: # If the species isn't defined above, it'll choose one of these default phrases instead.
$num = mt_rand(1,6);
switch ($num){
case 1: $message .= "What an awesome day!"; break;
case 2: $message .= "Hey, did you know you're amazing?!"; break;
case 3: $message .= "Inner beauty is important!"; break;
case 4: $message .= "You look fantastic today!"; break;
case 5: $message .= "You're the best!!"; break;
case 6: $message .= "I love adventure!!"; break;
}
break;
}

}
} else { # Seventy-five percent chance nothing will happen whatsoever.
/* Nothing will happen with the pet at all. */
$message = "";
}
}

$message .= "</div>";
/**** END: CREATE RANDOM MESSAGES ****/
#
#
#

}
$this->setDivision($this->FavPetSB);
}
/**** END: FOR THE FAVPET WIDGET ****/
#
#
#









/**
* The getMoneyBar method, getter method for property $moneyBar.
* @access public
* @return Paragraph
*/
public function getMoneyBar(){
return $this->moneyBar;
}

/**
* The setMoneyBar method, setter method for property $moneyBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;
$this->moneyBar->add(new Comment("You have <span id='cashonhand'>{$mysidia->user->money}</span> {$mysidia->settings->cost}."));

$donate = new Link("donate");
$donate->setText("Donate Money to Friends");
$this->moneyBar->add($donate);
$this->setDivision($this->moneyBar);
}

/**
* The getLinksBar method, getter method for property $linksBar.
* @access public
* @return Paragraph
*/
public function getLinksBar(){
return $this->linksBar;
}

/**
* The setLinksBar method, setter method for property $linksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinksBar(){
$mysidia = Registry::get("mysidia");
$this->linksBar = new Paragraph;
$linkTitle = new Comment("{$mysidia->user->username}'s Links:");
$linkTitle->setBold();
$this->linksBar->add($linkTitle);

$linksList = new LinksList("ul");
$this->setLinks($linksList);

$this->linksBar->add($linksList);
$this->setDivision($this->linksBar);
}

/**
* The setLinks method, append all links to the LinksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinks(LinksList $linksList){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("links", array("id", "linktext", "linkurl"), "linktype = 'sidelink' ORDER BY linkorder");
if($stmt->rowCount() == 0) Throw new Exception("There is an error with sidebar links, please contact the admin immediately for help.");

while($sideLink = $stmt->fetchObject()){
$link = new Link($sideLink->linkurl);
$link->setText($sideLink->linktext);
if($sideLink->linkurl == "messages"){
$num = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->rowCount();
if($num > 0) $link->setText("<b>{$link->getText()} ({$num})</b>");
}
$link->setListed(TRUE);
$linksList->add($link);
}

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);
}
}

/**
* The getWolBar method, getter method for property $wolBar.
* @access public
* @return LinksList
*/
public function getWolBar(){
return $this->wolBar;
}

/**
* The setWolBar method, setter method for property $wolBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setWolBar(){
$mysidia = Registry::get("mysidia");
$this->wolBar = new Link("online");
$online = $mysidia->db->select("online", array(), "username != 'Visitor'")->rowCount();
$offline = $mysidia->db->select("online", array(), "username = 'Visitor'")->rowCount();
$this->wolBar->setText("This site has {$online} members and {$offline} guests online.");
$this->setDivision($this->wolBar);
}

/**
* The getLoginBar method, getter method for property $loginBar.
* @access public
* @return FormBuilder
*/
public function getLoginBar(){
return $this->loginBar;
}

/**
* The setLoginBar method, setter method for property $loginBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLoginBar(){
$this->loginBar = new FormBuilder("login", "login", "post");
$loginTitle = new Comment("Member Login:");
$loginTitle->setBold();
$loginTitle->setUnderlined();
$this->loginBar->add($loginTitle);

$this->loginBar->buildComment("username: ", FALSE)
->buildTextField("username")
->buildComment("password: ", FALSE)
->buildPasswordField("password", "password", "", TRUE)
->buildButton("Log In", "submit", "submit")
->buildComment("Don't have an account?");

$register = new Link("register");
$register->setText("Register New Account");
$register->setLineBreak(TRUE);
$forgot = new Link("forgotpass");
$forgot->setText("Forgot Password?");

$this->loginBar->add($register);
$this->loginBar->add($forgot);
$this->setDivision($this->loginBar);
}
}
?>

Kyttias
03-21-2016, 12:16 AM
Change line 85 to this:
if ($profile->getFavpetID() == "0"){

And change line 96 to this:
$this->FavPetSB->add(new Comment("<a href='/myadopts/manage/{$profile->getFavpetID()}'><img src='{$favpet->getImage()}'></a>"));

Using {$profile->getFavpetID()} instead of {$favpet} should help!! Sorry about this. Those two things should fix the errors, but--


Also! Two other things. I'd also change line 95 to:
$this->FavPetSB->add(new Comment("{$message}"));
Because we're actually adding the div elsewhere now, oops.

And at 271, we should close the message like this now:
if ($message == "") { $message = ""; } else { $message .= "</div>"; }

/**** END: CREATE RANDOM MESSAGES ****/

Ittermat
03-21-2016, 12:19 AM
No need to apologize Kyttias!! Im more than anything grateful for all the work and help you're giving me!!

It showed up but I went to go to my account to change out my favorite pet to see if it worked without one- and It gave me this error...?


Fatal error: Cannot access protected property OwnedAdoptable::$type in /home/atrocity/public_html/classes/class_sidebar.php on line 144

Should I change it to Public? or something?

ah that seems to have worked! (The extra two you added XD)

THANK YOU KYTTIAS!! YOU ARE AMAZING <3

Kyttias
03-21-2016, 12:22 AM
Yeah. I wasn't quite sure how to access it by default. So in classes/class_ownedadoptable.php see if $type is in the list of variables at the top, if it is, change it, or else add it.

public $type;

Also see my last post again for two other additional edits you should make, just in case you missed it. :happyc:

Ittermat
03-21-2016, 12:25 AM
Its working now! no errors to be found currently! THANKS!

I will let you know if something comes up though <3

Kyttias
03-21-2016, 12:26 AM
Great! I made the changes to post #26 so it should be relatively safe for anyone else who comes across this thread to use without too much trouble.

Ittermat
03-21-2016, 08:17 AM
Im not sure if this is because of The active pet mod? But now I cant login? It gives me these... (I couldnt highlight all of the top one...) It says my login was successful but then It puts me back to the login screen...? To login again.

/class_cookies.php on line 85

Warning: Cannot modify header information - headers already sent by (output started at /home/atrocity/public_html/classes/class_sidebar.php:1) in /home/atrocity/public_html/classes/class_cookies.php on line 88

Warning: Cannot modify header information - headers already sent by (output started at /home/atrocity/public_html/classes/class_sidebar.php:1) in /home/atrocity/public_html/classes/class_cookies.php on line 90

Warning: Cannot modify header information - headers already sent by (output started at /home/atrocity/public_html/classes/class_sidebar.php:1) in /home/atrocity/public_html/classes/class_cookies.php on line 92

Kyttias
03-21-2016, 09:28 AM
You can try to send me the file again but it really shouldn't be related (necessarily). I mean, I can log in and out just fine with my version. :hmmm:

Header errors can be caused by a file attempting to render anything not code. Check for blank space at the beginning and end of the file and remove any that you find. But this is caused by cookies, so it thinks? In which case I'm really not sure.

Ittermat
03-21-2016, 10:04 AM
Heres my file- It works amazing when im logged in... but when im not and I try to log in it wont let me... same thing with logging out- I cant do either. 0.o

I have no idea if anyone else has this issue.

<?php

/**
* The Sidebar Class, defines a standard HTML Sidebar component.
* It extends from the Widget class, while adding its own implementation.
* @category Resource
* @package Widget
* @author Hall of Famer
* @copyright Mysidia Adoptables Script
* @link http://www.mysidiaadoptables.com
* @since 1.3.3
* @todo Not much at this point.
*
*/

class Sidebar extends Widget{

/**
* The moneyBar property, specifies the money/donation bar for members.
* @access protected
* @var Paragraph
*/
protected $moneyBar;

/**
* The linksBar property, stores all useful links for members.
* @access protected
* @var Paragraph
*/
protected $linksBar;

/**
* The wolBar property, determines the who's online url in the sidebar.
* @access protected
* @var Link
*/
protected $wolBar;

/**
* The loginBar property, specifies the loginBar for guests.
* @access protected
* @var FormBuilder
*/
protected $loginBar;

/**
* Constructor of Sidebar Class, it initializes basic sidebar properties
* @access public
* @return Void
*/
public function __construct(){
parent::__construct(4, "sidebar");
}

/**
* The setDivision method, setter method for property $division.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @param GUIComponent $module
* @access protected
* @return Void
*/
protected function setDivision(GUIComponent $module){
if(!$this->division){
$this->division = new Division;
$this->division->setClass("sidebar");
}
$this->division->add($module);
}



#
#
#
/**** BEGIN: FOR THE FAVPET WIDGET ****/
public function getFavPetSB(){
return $this->FavPetSB;
}

public function setFavPetSB(){
$mysidia = Registry::get("mysidia");
$profile = $mysidia->user->getprofile();

/* IF THE USER DOES *NOT* HAVE A FAVPET: */
if ($profile->getFavpetID() == "0"){
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
}

/* IF THE USER *DOES* HAVE A FAVPET: */
if ($profile->getFavpetID() != "0"){
$favpet = new OwnedAdoptable($profile->getFavpetID());
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>Favorite Pet!</b>"));
$this->FavPetSB->add(new Comment("{$message}"));
$this->FavPetSB->add(new Comment("<a href='/myadopts/manage/{$profile->getFavpetID()}'><img src='{$favpet->getImage()}'></a>"));

#
#
#
/**** BEGIN: CREATE RANDOM MESSAGES ****/
$message = "<div class='speechbubble'>";

$status_chance = mt_rand(1, 100);
if ($status_chance <= 1){ # One percent chance the pet will obtain a status effect.

/* We would apply a status effect here...*/
$message .= "Placeholder text: A status effect would have happened here!";
#### We'll do this later!!!

} else { # Ninety-nine percent chance the pet will not get a status effect. Will something else happen?
$something_chance = mt_rand(1, 100);
if ($something_chance <= 25){ # Twenty-five percent chance something will happen.
$gift_chance = mt_rand(1, 100);
if ($gift_chance <= 5){ # Five percent chance the user will receive a gift from their pet.
$item_chance = mt_rand(1, 100);
if ($item_chance <= 50){ # Fifty percent chance the gift from their pet will be an item.

/* The pet has found an item for you! */
$num = mt_rand(1,5); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $item = "Ball of Yarn"; break;
case 2: $item = "Bernard plushie"; break;
case 3: $item = "Madeline plushie "; break;
case 4: $item = "Maria plushie"; break;
case 5: $item = "Honey comb"; break;
}
$message .= "I found a {$item} for you!";
$newitem = new StockItem($item);
$newitem->append(1, $mysidia->user->username);

} else { # Fifty percent chance the gift from their pet will be money.

/* The pet has found some money for you! */
$currency = $mysidia->settings->cost;
$amount = mt_rand(100, 1000); # Between 100 and 1000
$message .= "Found {$amount} {$currency}!";
$mysidia->user->changecash($amount);

}
} else { # Twenty percent chance the pet will talk but have no gift.
/* No gift will be given but a neat species-specific phrase can still be said! */

$species = $favpet->type;

switch ($species){
case "Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "silver tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "ginger tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "tuxedo tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "Black and white Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "brown and black Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "Black and white floopy eared Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

default: # If the species isn't defined above, it'll choose one of these default phrases instead.
$num = mt_rand(1,6);
switch ($num){
case 1: $message .= "What an awesome day!"; break;
case 2: $message .= "Hey, did you know you're amazing?!"; break;
case 3: $message .= "Inner beauty is important!"; break;
case 4: $message .= "You look fantastic today!"; break;
case 5: $message .= "You're the best!!"; break;
case 6: $message .= "I love adventure!!"; break;
}
break;
}

}
} else { # Seventy-five percent chance nothing will happen whatsoever.
/* Nothing will happen with the pet at all. */
$message = "";
}
}

if ($message == "") { $message = ""; } else { $message .= "</div>"; }

/**** END: CREATE RANDOM MESSAGES ****/
#
#
#

}
$this->setDivision($this->FavPetSB);
}
/**** END: FOR THE FAVPET WIDGET ****/
#
#
#









/**
* The getMoneyBar method, getter method for property $moneyBar.
* @access public
* @return Paragraph
*/
public function getMoneyBar(){
return $this->moneyBar;
}

/**
* The setMoneyBar method, setter method for property $moneyBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;
$this->moneyBar->add(new Comment("You have <span id='cashonhand'>{$mysidia->user->money}</span> {$mysidia->settings->cost}."));

$donate = new Link("donate");
$donate->setText("Donate Money to Friends");
$this->moneyBar->add($donate);
$this->setDivision($this->moneyBar);
}

/**
* The getLinksBar method, getter method for property $linksBar.
* @access public
* @return Paragraph
*/
public function getLinksBar(){
return $this->linksBar;
}

/**
* The setLinksBar method, setter method for property $linksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinksBar(){
$mysidia = Registry::get("mysidia");
$this->linksBar = new Paragraph;
$linkTitle = new Comment("{$mysidia->user->username}'s Links:");
$linkTitle->setBold();
$this->linksBar->add($linkTitle);

$linksList = new LinksList("ul");
$this->setLinks($linksList);

$this->linksBar->add($linksList);
$this->setDivision($this->linksBar);
}

/**
* The setLinks method, append all links to the LinksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinks(LinksList $linksList){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("links", array("id", "linktext", "linkurl"), "linktype = 'sidelink' ORDER BY linkorder");
if($stmt->rowCount() == 0) Throw new Exception("There is an error with sidebar links, please contact the admin immediately for help.");

while($sideLink = $stmt->fetchObject()){
$link = new Link($sideLink->linkurl);
$link->setText($sideLink->linktext);
if($sideLink->linkurl == "messages"){
$num = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->rowCount();
if($num > 0) $link->setText("<b>{$link->getText()} ({$num})</b>");
}
$link->setListed(TRUE);
$linksList->add($link);
}

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);
}
}

/**
* The getWolBar method, getter method for property $wolBar.
* @access public
* @return LinksList
*/
public function getWolBar(){
return $this->wolBar;
}

/**
* The setWolBar method, setter method for property $wolBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setWolBar(){
$mysidia = Registry::get("mysidia");
$this->wolBar = new Link("online");
$online = $mysidia->db->select("online", array(), "username != 'Visitor'")->rowCount();
$offline = $mysidia->db->select("online", array(), "username = 'Visitor'")->rowCount();
$this->wolBar->setText("This site has {$online} members and {$offline} guests online.");
$this->setDivision($this->wolBar);
}

/**
* The getLoginBar method, getter method for property $loginBar.
* @access public
* @return FormBuilder
*/
public function getLoginBar(){
return $this->loginBar;
}

/**
* The setLoginBar method, setter method for property $loginBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLoginBar(){
$this->loginBar = new FormBuilder("login", "login", "post");
$loginTitle = new Comment("Member Login:");
$loginTitle->setBold();
$loginTitle->setUnderlined();
$this->loginBar->add($loginTitle);

$this->loginBar->buildComment("username: ", FALSE)
->buildTextField("username")
->buildComment("password: ", FALSE)
->buildPasswordField("password", "password", "", TRUE)
->buildButton("Log In", "submit", "submit")
->buildComment("Don't have an account?");

$register = new Link("register");
$register->setText("Register New Account");
$register->setLineBreak(TRUE);
$forgot = new Link("forgotpass");
$forgot->setText("Forgot Password?");

$this->loginBar->add($register);
$this->loginBar->add($forgot);
$this->setDivision($this->loginBar);
}
}
?>

Kyttias
03-21-2016, 10:26 AM
Alright right at the top of your file, check that there is not a blank space before <?php - because in what you copy pasted above there is and that could cause the issue. Maybe. Probably not, though.

See, the thing is, I just replaced my entire file with yours and everything still works fine - I can log in and out.

Might I suggest clearing your browser's cache/cookies?

Ittermat
03-21-2016, 10:29 AM
ah okay....LEmme try that...

Sorry to cause so much trouble...Im trying to learn.. XD

thank you for your patience with me.

EDIT nope... that did not solve the problem.... still gives me the errors...?

Kyttias
03-21-2016, 10:30 AM
Made an edit above.

But yeah I'm completely baffled by this one. :ti:

Ittermat
03-21-2016, 10:34 AM
I'll try clearing my cookies XD one moment... XD

EDIT: Nope still the same problem..

Ittermat
03-21-2016, 01:46 PM
I just wanted you to see how much of a ***** I am... the problem?

Apparently was an unseen space at the END of the coding....

so there was a space after-?>

Im an idiot... it works now.. XD

Ittermat
03-22-2016, 01:03 PM
Also I have a question I was going to message you about but i have to post in here-- The active pet widget works- but I dont get the "speech bubbles" telling me something happened.. do you happen to know what in my browser settings/internet settings might prevent that from happening?

Kyttias
03-22-2016, 03:26 PM
??? The text is appearing, right? (And it should only appear sometimes, not all the time. If you really want something to appear all the time I'll have to modify the code.) If you want the text to appear in a speech bubble, you're going to need to style the div the text is in with css. I already told you that the div has a css class of "speechbubble". You can add something like this to your template theme's css:

.speechbubble {
position: relative;
padding: 15px;
text-align: center;
background: #FFFFFF;
-webkit-border-radius: 53px;
-moz-border-radius: 53px;
border-radius: 53px;
border: #7F7F7F solid 2px;
}

.speechbubble:after {
content: '';
position: absolute;
border-style: solid;
border-width: 15px 15px 0;
border-color: #FFFFFF transparent;
display: block;
width: 0;
z-index: 1;
margin-left: -15px;
bottom: -15px;
left: 50%;
}

.speechbubble:before {
content: '';
position: absolute;
border-style: solid;
border-width: 16px 16px 0;
border-color: #7F7F7F transparent;
display: block;
width: 0;
z-index: 0;
margin-left: -16px;
bottom: -18px;
left: 50%;
}

Here's a neat site (http://ilikepixels.co.uk/drop/bubbler/) where you can use a generator to style a speech bubble. When you're done, look at the very top edge of the page for a button that "CSS" and it'll pull down the code - change the class name from .bubble to .speechbubble and then that should work. Above, I've also done three other things that their generator doesn't do - I removed the width and height, for one, and two, I centered the text. This way it'll be only as big as it needs to be.

Ittermat
03-22-2016, 05:51 PM
well I havent seen the pet say anything yet.. XD (I know it doesnt happen ALL the time) but I havent noticed if there was text? I just kinda was clicking around to test it and then went to my inventory to find I had gained the items without anything that I noticed telling me...

I'll check this out! thanks.. I thought maybe I was just blocking it somehow because im paranoid and blocked stuff from appearing on webpages

EDIT: another quick question- if Im using bootstrap- which CSS File do I add this to?

Ittermat
03-22-2016, 08:34 PM
Also no...apparently none of the text is appearing for me... my money amount changed but I saw no "(pet) has found some money!"

Or whatever it says..?

No speechbubbles for me either (though I admit I havent added the css you gave me since I dont know in which boostrap css to put it XD)

Kyttias
03-22-2016, 08:59 PM
??? Send me your file, I guess. I tested your file previously, your exact file, and it was working just fine on mine.

Ittermat
03-22-2016, 08:59 PM
I even changed it to yours to see if it was my file- and its not the file- its something with my laptop I think- thats blocking it? but I cant figure out what??
Im using mozilla firefox? but it also wont show up with text or speech bubbles on chrome either..

Kyttias
03-22-2016, 10:17 PM
That's really ridiculous? PHP renders text from server side, it has nothing to do with what browser you're using.

I even have adblock. You could always remove the class from the div, I guess. =/ The line right after:
/**** BEGIN: CREATE RANDOM MESSAGES ****/
Just change the class name to something else, like pancakes or something. If something browser related was blocking it, that'd be the only difference.

But go ahead and share the file one more time just in case?

Ittermat
03-22-2016, 10:19 PM
Im not sure what else it would be to be honest? but yea I'll hand it over again-

<?php

/**
* The Sidebar Class, defines a standard HTML Sidebar component.
* It extends from the Widget class, while adding its own implementation.
* @category Resource
* @package Widget
* @author Hall of Famer
* @copyright Mysidia Adoptables Script
* @link http://www.mysidiaadoptables.com
* @since 1.3.3
* @todo Not much at this point.
*
*/

class Sidebar extends Widget{

/**
* The moneyBar property, specifies the money/donation bar for members.
* @access protected
* @var Paragraph
*/
protected $moneyBar;

/**
* The linksBar property, stores all useful links for members.
* @access protected
* @var Paragraph
*/
protected $linksBar;

/**
* The wolBar property, determines the who's online url in the sidebar.
* @access protected
* @var Link
*/
protected $wolBar;

/**
* The loginBar property, specifies the loginBar for guests.
* @access protected
* @var FormBuilder
*/
protected $loginBar;

/**
* Constructor of Sidebar Class, it initializes basic sidebar properties
* @access public
* @return Void
*/
public function __construct(){
parent::__construct(4, "sidebar");
}

/**
* The setDivision method, setter method for property $division.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @param GUIComponent $module
* @access protected
* @return Void
*/
protected function setDivision(GUIComponent $module){
if(!$this->division){
$this->division = new Division;
$this->division->setClass("sidebar");
}
$this->division->add($module);
}



#
#
#
/**** BEGIN: FOR THE FAVPET WIDGET ****/
public function getFavPetSB(){
return $this->FavPetSB;
}

public function setFavPetSB(){
$mysidia = Registry::get("mysidia");
$profile = $mysidia->user->getprofile();

/* IF THE USER DOES *NOT* HAVE A FAVPET: */
if ($profile->getFavpetID() == "0"){
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
}

/* IF THE USER *DOES* HAVE A FAVPET: */
if ($profile->getFavpetID() != "0"){
$favpet = new OwnedAdoptable($profile->getFavpetID());
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>Favorite Pet!</b>"));
$this->FavPetSB->add(new Comment("{$message}"));
$this->FavPetSB->add(new Comment("<a href='/myadopts/manage/{$profile->getFavpetID()}'><img src='{$favpet->getImage()}'></a>"));

#
#
#
/**** BEGIN: CREATE RANDOM MESSAGES ****/
$message = "<div class='speechbubble'>";

$status_chance = mt_rand(1, 100);
if ($status_chance <= 1){ # One percent chance the pet will obtain a status effect.

/* We would apply a status effect here...*/
$message .= "Placeholder text: A status effect would have happened here!";
#### We'll do this later!!!

} else { # Ninety-nine percent chance the pet will not get a status effect. Will something else happen?
$something_chance = mt_rand(1, 100);
if ($something_chance <= 25){ # Twenty-five percent chance something will happen.
$gift_chance = mt_rand(1, 100);
if ($gift_chance <= 5){ # Five percent chance the user will receive a gift from their pet.
$item_chance = mt_rand(1, 100);
if ($item_chance <= 50){ # Fifty percent chance the gift from their pet will be an item.

/* The pet has found an item for you! */
$num = mt_rand(1,5); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $item = "Ball of Yarn"; break;
case 2: $item = "Bernard plushie"; break;
case 3: $item = "Madeline plushie "; break;
case 4: $item = "Maria plushie"; break;
case 5: $item = "Honey comb"; break;
}
$message .= "I found a {$item} for you!";
$newitem = new StockItem($item);
$newitem->append(1, $mysidia->user->username);

} else { # Fifty percent chance the gift from their pet will be money.

/* The pet has found some money for you! */
$currency = $mysidia->settings->cost;
$amount = mt_rand(100, 1000); # Between 100 and 1000
$message .= "Found {$amount} {$currency}!";
$mysidia->user->changecash($amount);

}
} else { # Twenty percent chance the pet will talk but have no gift.
/* No gift will be given but a neat species-specific phrase can still be said! */

$species = $favpet->type;

switch ($species){
case "Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "silver tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "ginger tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "tuxedo tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "Black and white Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "brown and black Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "Black and white floopy eared Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

default: # If the species isn't defined above, it'll choose one of these default phrases instead.
$num = mt_rand(1,6);
switch ($num){
case 1: $message .= "What an awesome day!"; break;
case 2: $message .= "Hey, did you know you're amazing?!"; break;
case 3: $message .= "Inner beauty is important!"; break;
case 4: $message .= "You look fantastic today!"; break;
case 5: $message .= "You're the best!!"; break;
case 6: $message .= "I love adventure!!"; break;
}
break;
}

}
} else { # Seventy-five percent chance nothing will happen whatsoever.
/* Nothing will happen with the pet at all. */
$message = "";
}
}

if ($message == "") { $message = ""; } else { $message .= "</div>"; }

/**** END: CREATE RANDOM MESSAGES ****/
#
#
#

}
$this->setDivision($this->FavPetSB);
}
/**** END: FOR THE FAVPET WIDGET ****/
#
#
#









/**
* The getMoneyBar method, getter method for property $moneyBar.
* @access public
* @return Paragraph
*/
public function getMoneyBar(){
return $this->moneyBar;
}

/**
* The setMoneyBar method, setter method for property $moneyBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;
$this->moneyBar->add(new Comment("You have <span id='cashonhand'>{$mysidia->user->money}</span> {$mysidia->settings->cost}."));

$donate = new Link("donate");
$donate->setText("Donate Money to Friends");
$this->moneyBar->add($donate);
$this->setDivision($this->moneyBar);
}

/**
* The getLinksBar method, getter method for property $linksBar.
* @access public
* @return Paragraph
*/
public function getLinksBar(){
return $this->linksBar;
}

/**
* The setLinksBar method, setter method for property $linksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinksBar(){
$mysidia = Registry::get("mysidia");
$this->linksBar = new Paragraph;
$linkTitle = new Comment("{$mysidia->user->username}'s Links:");
$linkTitle->setBold();
$this->linksBar->add($linkTitle);

$linksList = new LinksList("ul");
$this->setLinks($linksList);

$this->linksBar->add($linksList);
$this->setDivision($this->linksBar);
}

/**
* The setLinks method, append all links to the LinksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinks(LinksList $linksList){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("links", array("id", "linktext", "linkurl"), "linktype = 'sidelink' ORDER BY linkorder");
if($stmt->rowCount() == 0) Throw new Exception("There is an error with sidebar links, please contact the admin immediately for help.");

while($sideLink = $stmt->fetchObject()){
$link = new Link($sideLink->linkurl);
$link->setText($sideLink->linktext);
if($sideLink->linkurl == "messages"){
$num = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->rowCount();
if($num > 0) $link->setText("<b>{$link->getText()} ({$num})</b>");
}
$link->setListed(TRUE);
$linksList->add($link);
}

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);
}
}

/**
* The getWolBar method, getter method for property $wolBar.
* @access public
* @return LinksList
*/
public function getWolBar(){
return $this->wolBar;
}

/**
* The setWolBar method, setter method for property $wolBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setWolBar(){
$mysidia = Registry::get("mysidia");
$this->wolBar = new Link("online");
$online = $mysidia->db->select("online", array(), "username != 'Visitor'")->rowCount();
$offline = $mysidia->db->select("online", array(), "username = 'Visitor'")->rowCount();
$this->wolBar->setText("This site has {$online} members and {$offline} guests online.");
$this->setDivision($this->wolBar);
}

/**
* The getLoginBar method, getter method for property $loginBar.
* @access public
* @return FormBuilder
*/
public function getLoginBar(){
return $this->loginBar;
}

/**
* The setLoginBar method, setter method for property $loginBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLoginBar(){
$this->loginBar = new FormBuilder("login", "login", "post");
$loginTitle = new Comment("Member Login:");
$loginTitle->setBold();
$loginTitle->setUnderlined();
$this->loginBar->add($loginTitle);

$this->loginBar->buildComment("username: ", FALSE)
->buildTextField("username")
->buildComment("password: ", FALSE)
->buildPasswordField("password", "password", "", TRUE)
->buildButton("Log In", "submit", "submit")
->buildComment("Don't have an account?");

$register = new Link("register");
$register->setText("Register New Account");
$register->setLineBreak(TRUE);
$forgot = new Link("forgotpass");
$forgot->setText("Forgot Password?");

$this->loginBar->add($register);
$this->loginBar->add($forgot);
$this->setDivision($this->loginBar);
}
}
?>

It works fine other than the stuff not appearing for me...

RestlessThoughts
03-24-2016, 05:01 PM
I moved the message assignment below the message creation. That seems to fix the blank message display.


<?php

/**
* The Sidebar Class, defines a standard HTML Sidebar component.
* It extends from the Widget class, while adding its own implementation.
* @category Resource
* @package Widget
* @author Hall of Famer
* @copyright Mysidia Adoptables Script
* @link http://www.mysidiaadoptables.com
* @since 1.3.3
* @todo Not much at this point.
*
*/

class Sidebar extends Widget{

/**
* The moneyBar property, specifies the money/donation bar for members.
* @access protected
* @var Paragraph
*/
protected $moneyBar;

/**
* The linksBar property, stores all useful links for members.
* @access protected
* @var Paragraph
*/
protected $linksBar;

/**
* The wolBar property, determines the who's online url in the sidebar.
* @access protected
* @var Link
*/
protected $wolBar;

/**
* The loginBar property, specifies the loginBar for guests.
* @access protected
* @var FormBuilder
*/
protected $loginBar;

/**
* Constructor of Sidebar Class, it initializes basic sidebar properties
* @access public
* @return Void
*/
public function __construct(){
parent::__construct(4, "sidebar");
}

/**
* The setDivision method, setter method for property $division.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @param GUIComponent $module
* @access protected
* @return Void
*/
protected function setDivision(GUIComponent $module){
if(!$this->division){
$this->division = new Division;
$this->division->setClass("sidebar");
}
$this->division->add($module);
}



#
#
#
/**** BEGIN: FOR THE FAVPET WIDGET ****/
public function getFavPetSB(){
return $this->FavPetSB;
}

public function setFavPetSB(){
$mysidia = Registry::get("mysidia");
$profile = $mysidia->user->getprofile();

/* IF THE USER DOES *NOT* HAVE A FAVPET: */
if ($profile->getFavpetID() == "0"){
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
}

/* IF THE USER *DOES* HAVE A FAVPET: */
if ($profile->getFavpetID() != "0"){

$favpet = new OwnedAdoptable($profile->getFavpetID());
#
#
#
/**** BEGIN: CREATE RANDOM MESSAGES ****/
$message = "<div class='speechbubble'>";

$status_chance = mt_rand(1, 100);
if ($status_chance <= 1){ # One percent chance the pet will obtain a status effect.

/* We would apply a status effect here...*/
$message .= "Placeholder text: A status effect would have happened here!";
#### We'll do this later!!!

} else { # Ninety-nine percent chance the pet will not get a status effect. Will something else happen?
$something_chance = mt_rand(1, 100);
if ($something_chance <= 25){ # Twenty-five percent chance something will happen.
$gift_chance = mt_rand(1, 100);
if ($gift_chance <= 5){ # Five percent chance the user will receive a gift from their pet.
$item_chance = mt_rand(1, 100);
if ($item_chance <= 50){ # Fifty percent chance the gift from their pet will be an item.

/* The pet has found an item for you! */
$num = mt_rand(1,5); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $item = "Ball of Yarn"; break;
case 2: $item = "Bernard plushie"; break;
case 3: $item = "Madeline plushie "; break;
case 4: $item = "Maria plushie"; break;
case 5: $item = "Honey comb"; break;
}
$message .= "I found a {$item} for you!";
$newitem = new StockItem($item);
$newitem->append(1, $mysidia->user->username);

} else { # Fifty percent chance the gift from their pet will be money.

/* The pet has found some money for you! */
$currency = $mysidia->settings->cost;
$amount = mt_rand(100, 1000); # Between 100 and 1000
$message .= "Found {$amount} {$currency}!";
$mysidia->user->changecash($amount);

}
} else { # Twenty percent chance the pet will talk but have no gift.
/* No gift will be given but a neat species-specific phrase can still be said! */

$species = trim($favpet->type);

switch ($species){
case "Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "silver tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "ginger tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "tuxedo tabby Catari": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Meow!"; break;
case 2: $message .= "*purr*"; break;
case 3: $message .= "Do you have catnip?"; break;
case 4: $message .= "I saw a squirrel today!"; break;
case 5: $message .= "I should catch that mouse!"; break;
case 6: $message .= "I love you!"; break;
case 7: $message .= "I feel special being owned by you!"; break;
}
break;

case "Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "Black and white Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "brown and black Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

case "Black and white floopy eared Hounda":
$num = mt_rand(1,7);
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "what adventure are we going on today??!"; break;
case 6: $message .= "Lets be best friends forever!!"; break;
case 7: $message .= "Im the luckiest hounda ever!!"; break;
}
break;

default: # If the species isn't defined above, it'll choose one of these default phrases instead.
$num = mt_rand(1,6);
switch ($num){
case 1: $message .= "What an awesome day!"; break;
case 2: $message .= "Hey, did you know you're amazing?!"; break;
case 3: $message .= "Inner beauty is important!"; break;
case 4: $message .= "You look fantastic today!"; break;
case 5: $message .= "You're the best!!"; break;
case 6: $message .= "I love adventure!!"; break;
}
break;
}

}
} else { # Seventy-five percent chance nothing will happen whatsoever.
/* Nothing will happen with the pet at all. */
$message = "";
}
}

if ($message == "") { $message = ""; } else { $message .= "</div>"; }

/**** END: CREATE RANDOM MESSAGES ****/
#
#
#

$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>Favorite Pet!</b>"));
$this->FavPetSB->add(new Comment("{$message}"));
$this->FavPetSB->add(new Comment("<a href='/myadopts/manage/{$profile->getFavpetID()}'><img src='{$favpet->getImage()}'></a>"));

}
$this->setDivision($this->FavPetSB);
}
/**** END: FOR THE FAVPET WIDGET ****/
#
#
#









/**
* The getMoneyBar method, getter method for property $moneyBar.
* @access public
* @return Paragraph
*/
public function getMoneyBar(){
return $this->moneyBar;
}

/**
* The setMoneyBar method, setter method for property $moneyBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;
$this->moneyBar->add(new Comment("You have <span id='cashonhand'>{$mysidia->user->money}</span> {$mysidia->settings->cost}."));

$donate = new Link("donate");
$donate->setText("Donate Money to Friends");
$this->moneyBar->add($donate);
$this->setDivision($this->moneyBar);
}

/**
* The getLinksBar method, getter method for property $linksBar.
* @access public
* @return Paragraph
*/
public function getLinksBar(){
return $this->linksBar;
}

/**
* The setLinksBar method, setter method for property $linksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinksBar(){
$mysidia = Registry::get("mysidia");
$this->linksBar = new Paragraph;
$linkTitle = new Comment("{$mysidia->user->username}'s Links:");
$linkTitle->setBold();
$this->linksBar->add($linkTitle);

$linksList = new LinksList("ul");
$this->setLinks($linksList);

$this->linksBar->add($linksList);
$this->setDivision($this->linksBar);
}

/**
* The setLinks method, append all links to the LinksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinks(LinksList $linksList){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("links", array("id", "linktext", "linkurl"), "linktype = 'sidelink' ORDER BY linkorder");
if($stmt->rowCount() == 0) Throw new Exception("There is an error with sidebar links, please contact the admin immediately for help.");

while($sideLink = $stmt->fetchObject()){
$link = new Link($sideLink->linkurl);
$link->setText($sideLink->linktext);
if($sideLink->linkurl == "messages"){
$num = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->rowCount();
if($num > 0) $link->setText("<b>{$link->getText()} ({$num})</b>");
}
$link->setListed(TRUE);
$linksList->add($link);
}

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);
}
}

/**
* The getWolBar method, getter method for property $wolBar.
* @access public
* @return LinksList
*/
public function getWolBar(){
return $this->wolBar;
}

/**
* The setWolBar method, setter method for property $wolBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setWolBar(){
$mysidia = Registry::get("mysidia");
$this->wolBar = new Link("online");
$online = $mysidia->db->select("online", array(), "username != 'Visitor'")->rowCount();
$offline = $mysidia->db->select("online", array(), "username = 'Visitor'")->rowCount();
$this->wolBar->setText("This site has {$online} members and {$offline} guests online.");
$this->setDivision($this->wolBar);
}

/**
* The getLoginBar method, getter method for property $loginBar.
* @access public
* @return FormBuilder
*/
public function getLoginBar(){
return $this->loginBar;
}

/**
* The setLoginBar method, setter method for property $loginBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLoginBar(){
$this->loginBar = new FormBuilder("login", "login", "post");
$loginTitle = new Comment("Member Login:");
$loginTitle->setBold();
$loginTitle->setUnderlined();
$this->loginBar->add($loginTitle);

$this->loginBar->buildComment("username: ", FALSE)
->buildTextField("username")
->buildComment("password: ", FALSE)
->buildPasswordField("password", "password", "", TRUE)
->buildButton("Log In", "submit", "submit")
->buildComment("Don't have an account?");

$register = new Link("register");
$register->setText("Register New Account");
$register->setLineBreak(TRUE);
$forgot = new Link("forgotpass");
$forgot->setText("Forgot Password?");

$this->loginBar->add($register);
$this->loginBar->add($forgot);
$this->setDivision($this->loginBar);
}
}

LUC1G07CH1
04-01-2016, 04:52 PM
Obviously using this when my site is installed! :meow:

NobodysHero
04-03-2016, 11:50 AM
The mystfell.com page isn’t working

mystfell.com is currently unable to handle this request.

500

Without changing anything. It seems to only happen when it's trying to send a message, if it's not posting anything but the pet it's fine.

Edit: "not changing anything" isn't accurate. I changed the messages and the items to items that were for my site. I double checked it and tried it several times, always throws up the quoted message when it gets to the adopt saying something or giving an item.

Ittermat
04-03-2016, 04:22 PM
Did you see the post from Restless about switching the messages around? its right above yours ^^

NobodysHero
04-03-2016, 07:20 PM
Yeah, I tried that one too. x.x It'll show just the pet, but even clearing cache and cookies made it worse.

RestlessThoughts
04-05-2016, 09:08 AM
If this is still a problem, could you please turn on error reporting or check your error log?

You should be able to turn on error reporting by going to classes/class_initializer.php and putting this bit of code at the top, right under the opening php tag:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

Or post your sidebar page after making the breaking changes. If you don't want to post it, you can message me it instead and I'll see if I can spot the problem.

NobodysHero
04-05-2016, 04:37 PM
Okay, lemme put it all back together and post it here again. >.> I was going to give up, but I really like this and want to use it. x.x

Hope you're up for a slight challenge. T_T I starting testing some things out on my own and it didn't go well.


<?php

/**
* The Sidebar Class, defines a standard HTML Sidebar component.
* It extends from the Widget class, while adding its own implementation.
* @category Resource
* @package Widget
* @author Hall of Famer
* @copyright Mysidia Adoptables Script
* @link http://www.mysidiaadoptables.com
* @since 1.3.3
* @todo Not much at this point.
*
*/

class Sidebar extends Widget{

/**
* The moneyBar property, specifies the money/donation bar for members.
* @access protected
* @var Paragraph
*/
protected $moneyBar;

/**
* The linksBar property, stores all useful links for members.
* @access protected
* @var Paragraph
*/
protected $linksBar;

/**
* The wolBar property, determines the who's online url in the sidebar.
* @access protected
* @var Link
*/
protected $wolBar;

/**
* The loginBar property, specifies the loginBar for guests.
* @access protected
* @var FormBuilder
*/
protected $loginBar;

/**
* Constructor of Sidebar Class, it initializes basic sidebar properties
* @access public
* @return Void
*/
public function __construct(){
parent::__construct(4, "sidebar");
}

/**
* The setDivision method, setter method for property $division.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @param GUIComponent $module
* @access protected
* @return Void
*/
protected function setDivision(GUIComponent $module){
if(!$this->division){
$this->division = new Division;
$this->division->setClass("sidebar");
}
$this->division->add($module);
}



#
#
#
/**** BEGIN: FOR THE FAVPET WIDGET ****/
public function getFavPetSB(){
return $this->FavPetSB;
}

public function setFavPetSB(){
$mysidia = Registry::get("mysidia");
$profile = $mysidia->user->getprofile();

/* IF THE USER DOES *NOT* HAVE A FAVPET: */
if ($profile->getFavpetID() == "0"){
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
}

/* IF THE USER *DOES* HAVE A FAVPET: */
if ($profile->getFavpetID() != "0"){

$favpet = new OwnedAdoptable($profile->getFavpetID());
#
#
#
/**** BEGIN: CREATE RANDOM MESSAGES ****/
$message = "<div class='speechbubble'>";

$status_chance = mt_rand(1, 100);
if ($status_chance <= 1){ # One percent chance the pet will obtain a status effect.

/* We would apply a status effect here...*/
$message .= "<center>WHOOHOO! {$favpet->getImage()} is having a great day!</center>";
#### We'll do this later!!!

} else { # Ninety-nine percent chance the pet will not get a status effect. Will something else happen?
$something_chance = mt_rand(1, 100);
if ($something_chance <= 25){ # Twenty-five percent chance something will happen.
$gift_chance = mt_rand(1, 100);
if ($gift_chance <= 5){ # Five percent chance the user will receive a gift from their pet.
$item_chance = mt_rand(1, 100);
if ($item_chance <= 50){ # Fifty percent chance the gift from their pet will be an item.

/* The pet has found an item for you! */
$num = mt_rand(1,5); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $item = "Juicy Carrot"; break;
case 2: $item = "Spice Spoon"; break;
case 3: $item = "Red Rose"; break;
case 4: $item = "Obsidian Arrowhead"; break;
case 5: $item = "Misshapen Zulk Plushie"; break;
}
$message .= "I found a {$item} for you!";
$newitem = new StockItem($item);
$newitem->append(1, $mysidia->user->username);

} else { # Fifty percent chance the gift from their pet will be money.

/* The pet has found some money for you! */
$currency = $mysidia->settings->cost;
$amount = mt_rand(100, 1000); # Between 100 and 1000
$message .= "Found {$amount} {$tyleans}!";
$mysidia->user->changecash($amount);

}
} else { # Twenty percent chance the pet will talk but have no gift.
/* No gift will be given but a neat species-specific phrase can still be said! */

$species = trim($favpet->type);

switch ($species){
case "Wind Raptor": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Who, who!"; break;
case 2: $message .= "I like to soar through the sky."; break;
case 3: $message .= "Wanna share a berry?"; break;
case 4: $message .= "Don't worry! Anything shiny and I'll get it!"; break;
case 5: $message .= "Do you feel that breeze?"; break;
case 6: $message .= "Nocturnal? Nah, I'm awake when you're awake!"; break;
case 7: $message .= "Look what I can do!"; break;
}
break;

case "Terrahound": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "Where do ya wanna to explore today?"; break;
case 6: $message .= "Terrahounds are the best totem pet!"; break;
case 7: $message .= "Today is a great day to be a Terrahound"; break;
}
break;

case "Water Selkie": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Ort, ort, ort!"; break;
case 2: $message .= "Let's go swimming!"; break;
case 3: $message .= "My favorite place is the Ice Flows."; break;
case 4: $message .= "OH! Something shiny! Awww, it melted."; break;
case 5: $message .= "Know what my favorite food is? Fish!"; break;
case 6: $message .= "The water is my natural element, but I'll go anywhere you go."; break;
case 7: $message .= "Cool as a cucumber, slick as a ice patch!"; break;
}
break;

case "Flame Bison": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Chaaaaaaaarrrrrge!"; break;
case 2: $message .= "Don't mind me, I'm just grazing."; break;
case 3: $message .= "I'm blazing fast!"; break;
case 4: $message .= "Do you have any carrots?"; break;
case 5: $message .= "My favorite place is the Hills."; break;
case 6: $message .= "No need to fear when I'm around!"; break;
case 7: $message .= "Yeah, I'm pretty hot stuff."; break;
}
break;

default: # If the species isn't defined above, it'll choose one of these default phrases instead.
$num = mt_rand(1,6);
switch ($num){
case 1: $message .= "It's a beautiful day! I love to explore!"; break;
case 2: $message .= "I always knew I was favorite material!"; break;
case 3: $message .= "I'm a little hungry. Think we could get a bite to eat?"; break;
case 4: $message .= "You're the only friend I'll ever need."; break;
case 5: $message .= "I found something! I foun- Oh, no. False alarm."; break;
case 6: $message .= "Don't worry! I'm on the look out for anything shine"; break;
}
break;
}

}
} else { # Seventy-five percent chance nothing will happen whatsoever.
/* Nothing will happen with the pet at all. */
$message = "";
}
}

if ($message == "") { $message = ""; } else { $message .= "</div>"; }

/**** END: CREATE RANDOM MESSAGES ****/
#
#
#

$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b><center>{$favpet->getName()}</center></b>"));
$this->FavPetSB->add(new Comment("{$message}"));
$this->FavPetSB->add(new Comment("<a href='/myadopts/manage/{$profile->getFavpetID()}'><img src='{$favpet->getImage()}'></a>"));

}
$this->setDivision($this->FavPetSB);
}
/**** END: FOR THE FAVPET WIDGET ****/
#
#
#









/**
* The getMoneyBar method, getter method for property $moneyBar.
* @access public
* @return Paragraph
*/
public function getMoneyBar(){
return $this->moneyBar;
}

/**
* The setMoneyBar method, setter method for property $moneyBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;
$this->moneyBar->add(new Comment("You have <span id='cashonhand'>{$mysidia->user->money}</span> {$mysidia->settings->cost}."));

$donate = new Link("donate");
$donate->setText("Donate Money to Friends");
$this->moneyBar->add($donate);
$this->setDivision($this->moneyBar);
}

/**
* The getLinksBar method, getter method for property $linksBar.
* @access public
* @return Paragraph
*/
public function getLinksBar(){
return $this->linksBar;
}

/**
* The setLinksBar method, setter method for property $linksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinksBar(){
$mysidia = Registry::get("mysidia");
$this->linksBar = new Paragraph;
$linkTitle = new Comment("{$mysidia->user->username}'s Links:");
$linkTitle->setBold();
$this->linksBar->add($linkTitle);

$linksList = new LinksList("ul");
$this->setLinks($linksList);

$this->linksBar->add($linksList);
$this->setDivision($this->linksBar);
}

/**
* The setLinks method, append all links to the LinksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinks(LinksList $linksList){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("links", array("id", "linktext", "linkurl"), "linktype = 'sidelink' ORDER BY linkorder");
if($stmt->rowCount() == 0) Throw new Exception("There is an error with sidebar links, please contact the admin immediately for help.");

while($sideLink = $stmt->fetchObject()){
$link = new Link($sideLink->linkurl);
$link->setText($sideLink->linktext);
if($sideLink->linkurl == "messages"){
$num = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->rowCount();
if($num > 0) $link->setText("<b>{$link->getText()} ({$num})</b>");
}
$link->setListed(TRUE);
$linksList->add($link);
}

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);
}
}

/**
* The getWolBar method, getter method for property $wolBar.
* @access public
* @return LinksList
*/
public function getWolBar(){
return $this->wolBar;
}

/**
* The setWolBar method, setter method for property $wolBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setWolBar(){
$mysidia = Registry::get("mysidia");
$this->wolBar = new Link("online");
$online = $mysidia->db->select("online", array(), "username != 'Visitor'")->rowCount();
$offline = $mysidia->db->select("online", array(), "username = 'Visitor'")->rowCount();
$this->wolBar->setText("This site has {$online} members and {$offline} guests online.");
$this->setDivision($this->wolBar);
}

/**
* The getLoginBar method, getter method for property $loginBar.
* @access public
* @return FormBuilder
*/
public function getLoginBar(){
return $this->loginBar;
}

/**
* The setLoginBar method, setter method for property $loginBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLoginBar(){
$this->loginBar = new FormBuilder("login", "login", "post");
$loginTitle = new Comment("Member Login:");
$loginTitle->setBold();
$loginTitle->setUnderlined();
$this->loginBar->add($loginTitle);

$this->loginBar->buildComment("username: ", FALSE)
->buildTextField("username")
->buildComment("password: ", FALSE)
->buildPasswordField("password", "password", "", TRUE)
->buildButton("Log In", "submit", "submit")
->buildComment("Don't have an account?");

$register = new Link("register");
$register->setText("Register New Account");
$register->setLineBreak(TRUE);
$forgot = new Link("forgotpass");
$forgot->setText("Forgot Password?");

$this->loginBar->add($register);
$this->loginBar->add($forgot);
$this->setDivision($this->loginBar);
}
}
?>

Thanks for all the help! I'm excited to be able to offer this to my members!

I left it up on my site, in case you want to see it.

http://i.imgur.com/Amwjl14.png?1 (http://mystfell.com/)

NobodysHero
04-08-2016, 03:16 PM
Okay, so it works as long as I'm logged in, but as soon as I'm logged out, it gives me the error message again. Is there a way to set a condition or something that corrects that?

Here's my sidebar.

<?php

/**
* The Sidebar Class, defines a standard HTML Sidebar component.
* It extends from the Widget class, while adding its own implementation.
* @category Resource
* @package Widget
* @author Hall of Famer
* @copyright Mysidia Adoptables Script
* @link http://www.mysidiaadoptables.com
* @since 1.3.3
* @todo Not much at this point.
*
*/

class Sidebar extends Widget{

/**
* The moneyBar property, specifies the money/donation bar for members.
* @access protected
* @var Paragraph
*/
protected $moneyBar;

/**
* The linksBar property, stores all useful links for members.
* @access protected
* @var Paragraph
*/
protected $linksBar;

/**
* The wolBar property, determines the who's online url in the sidebar.
* @access protected
* @var Link
*/
protected $wolBar;

/**
* The loginBar property, specifies the loginBar for guests.
* @access protected
* @var FormBuilder
*/
protected $loginBar;

/**
* Constructor of Sidebar Class, it initializes basic sidebar properties
* @access public
* @return Void
*/
public function __construct(){
parent::__construct(4, "sidebar");
}

/**
* The setDivision method, setter method for property $division.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @param GUIComponent $module
* @access protected
* @return Void
*/
protected function setDivision(GUIComponent $module){
if(!$this->division){
$this->division = new Division;
$this->division->setClass("sidebar");
}
$this->division->add($module);
}



#
#
#
/**** BEGIN: FOR THE FAVPET WIDGET ****/
public function getFavPetSB(){
return $this->FavPetSB;
}

public function setFavPetSB(){
$mysidia = Registry::get("mysidia");
$profile = $mysidia->user->getprofile();

/* IF THE USER DOES *NOT* HAVE A FAVPET: */
if ($profile->getFavpetID() == "0"){
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
}

/* IF THE USER *DOES* HAVE A FAVPET: */
if ($profile->getFavpetID() != "0"){

$favpet = new OwnedAdoptable($profile->getFavpetID());
#
#
#
/**** BEGIN: CREATE RANDOM MESSAGES ****/
$message = "<div class='speechbubble'>";

$status_chance = mt_rand(1, 100);
if ($status_chance <= 1){ # One percent chance the pet will obtain a status effect.

/* We would apply a status effect here...*/
$message .= "<center>WHOOHOO! " . $favpet->getName() . " is having a great day!</center>";
#### We'll do this later!!!

} else { # Ninety-nine percent chance the pet will not get a status effect. Will something else happen?
$something_chance = mt_rand(1, 100);
if ($something_chance <= 25){ # Twenty-five percent chance something will happen.
$gift_chance = mt_rand(1, 100);
if ($gift_chance <= 5){ # Five percent chance the user will receive a gift from their pet.
$item_chance = mt_rand(1, 100);
if ($item_chance <= 50){ # Fifty percent chance the gift from their pet will be an item.

/* The pet has found an item for you! */
$num = mt_rand(1,5); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $item = "Juicy Carrot"; break;
case 2: $item = "Spice Spoon"; break;
case 3: $item = "Red Rose"; break;
case 4: $item = "Obsidian Arrowhead"; break;
case 5: $item = "Misshapen Zulk Plushie"; break;
}
$message .= "I found a {$item} for you!";
$newitem = new StockItem($item);
$newitem->append(1, $mysidia->user->username);

} else { # Fifty percent chance the gift from their pet will be money.

/* The pet has found some money for you! */
$currency = $mysidia->settings->cost;
$amount = mt_rand(100, 1000); # Between 100 and 1000
$message .= "Found {$amount} {$tyleans}!";
$mysidia->user->changecash($amount);

}
} else { # Twenty percent chance the pet will talk but have no gift.
/* No gift will be given but a neat species-specific phrase can still be said! */

$species = trim($favpet->getType());

switch ($species){
case "Wind Raptor": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Who, who!"; break;
case 2: $message .= "I like to soar through the sky."; break;
case 3: $message .= "Wanna share a berry?"; break;
case 4: $message .= "Don't worry! Anything shiny and I'll get it!"; break;
case 5: $message .= "Do you feel that breeze?"; break;
case 6: $message .= "Nocturnal? Nah, I'm awake when you're awake!"; break;
case 7: $message .= "Look what I can do!"; break;
}
break;

case "Terrahound": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "Where do ya wanna to explore today?"; break;
case 6: $message .= "Terrahounds are the best totem pet!"; break;
case 7: $message .= "Today is a great day to be a Terrahound"; break;
}
break;

case "Water Selkie": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Ort, ort, ort!"; break;
case 2: $message .= "Let's go swimming!"; break;
case 3: $message .= "My favorite place is the Ice Flows."; break;
case 4: $message .= "OH! Something shiny! Awww, it melted."; break;
case 5: $message .= "Know what my favorite food is? Fish!"; break;
case 6: $message .= "The water is my natural element, but I'll go anywhere you go."; break;
case 7: $message .= "Cool as a cucumber, slick as a ice patch!"; break;
}
break;

case "Flame Bison": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Chaaaaaaaarrrrrge!"; break;
case 2: $message .= "Don't mind me, I'm just grazing."; break;
case 3: $message .= "I'm blazing fast!"; break;
case 4: $message .= "Do you have any carrots?"; break;
case 5: $message .= "My favorite place is the Hills."; break;
case 6: $message .= "No need to fear when I'm around!"; break;
case 7: $message .= "Yeah, I'm pretty hot stuff."; break;
}
break;

default: # If the species isn't defined above, it'll choose one of these default phrases instead.
$num = mt_rand(1,6);
switch ($num){
case 1: $message .= "It's a beautiful day! I love to explore!"; break;
case 2: $message .= "I always knew I was favorite material!"; break;
case 3: $message .= "I'm a little hungry. Think we could get a bite to eat?"; break;
case 4: $message .= "You're the only friend I'll ever need."; break;
case 5: $message .= "I found something! I foun- Oh, no. False alarm."; break;
case 6: $message .= "Don't worry! I'm on the look out for anything shine"; break;
}
break;
}

}
} else { # Seventy-five percent chance nothing will happen whatsoever.
/* Nothing will happen with the pet at all. */
$message = "";
}
}

if ($message == "") { $message = ""; } else { $message .= "</div>"; }

/**** END: CREATE RANDOM MESSAGES ****/
#
#
#

$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<img src='" . $favpet->getImage() . "' width='200px' height='200px'></br>"));
$this->FavPetSB->add(new Comment("<b><center><a href='/myadopts/manage/" . $profile->getFavpetID() . "'>{$favpet->getName()}</a></center></b>"));
$this->FavPetSB->add(new Comment("<p>" . $message . "</p>"));

}
$this->setDivision($this->FavPetSB);
}
/**** END: FOR THE FAVPET WIDGET ****/
#
#
#









/**
* The getMoneyBar method, getter method for property $moneyBar.
* @access public
* @return Paragraph
*/
public function getMoneyBar(){
return $this->moneyBar;
}

/**
* The setMoneyBar method, setter method for property $moneyBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;
$this->moneyBar->add(new Comment("<center><span id='cashonhand'><b>{$mysidia->settings->cost} :</b> {$mysidia->user->money}</span></center>"));

$donate = new Link("donate");
$donate->setText("<center>Donate Money to Friends</center>");
$this->moneyBar->add($donate);
$this->setDivision($this->moneyBar);
}

/**
* The getLinksBar method, getter method for property $linksBar.
* @access public
* @return Paragraph
*/
public function getLinksBar(){
return $this->linksBar;
}

/**
* The setLinksBar method, setter method for property $linksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinksBar(){
$mysidia = Registry::get("mysidia");
$this->linksBar = new Paragraph;
$linkTitle = new Comment("{$mysidia->user->username}'s Links:");
$linkTitle->setBold();
$this->linksBar->add($linkTitle);

$linksList = new LinksList("ul");
$this->setLinks($linksList);

$this->linksBar->add($linksList);
$this->setDivision($this->linksBar);
}

/**
* The setLinks method, append all links to the LinksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinks(LinksList $linksList){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("links", array("id", "linktext", "linkurl"), "linktype = 'sidelink' ORDER BY linkorder");
if($stmt->rowCount() == 0) Throw new Exception("There is an error with sidebar links, please contact the admin immediately for help.");

while($sideLink = $stmt->fetchObject()){
$link = new Link($sideLink->linkurl);
$link->setText($sideLink->linktext);
if($sideLink->linkurl == "messages"){
$num = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->rowCount();
if($num > 0) $link->setText("<b>{$link->getText()} ({$num})</b>");
}
$link->setListed(TRUE);
$linksList->add($link);
}

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);
}
}

/**
* The getWolBar method, getter method for property $wolBar.
* @access public
* @return LinksList
*/
public function getWolBar(){
return $this->wolBar;
}

/**
* The setWolBar method, setter method for property $wolBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setWolBar(){
$mysidia = Registry::get("mysidia");
$this->wolBar = new Link("online");
$online = $mysidia->db->select("online", array(), "username != 'Visitor'")->rowCount();
$offline = $mysidia->db->select("online", array(), "username = 'Visitor'")->rowCount();
$this->wolBar->setText("This site has {$online} members and {$offline} guests online.");
$this->setDivision($this->wolBar);
}

/**
* The getLoginBar method, getter method for property $loginBar.
* @access public
* @return FormBuilder
*/
public function getLoginBar(){
return $this->loginBar;
}

/**
* The setLoginBar method, setter method for property $loginBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLoginBar(){
$this->loginBar = new FormBuilder("login", "login", "post");
$loginTitle = new Comment("Member Login:");
$loginTitle->setBold();
$loginTitle->setUnderlined();
$this->loginBar->add($loginTitle);

$this->loginBar->buildComment("username: ", FALSE)
->buildTextField("username")
->buildComment("password: ", FALSE)
->buildPasswordField("password", "password", "", TRUE)
->buildButton("Log In", "submit", "submit")
->buildComment("Don't have an account?");

$register = new Link("register");
$register->setText("Register New Account");
$register->setLineBreak(TRUE);
$forgot = new Link("forgotpass");
$forgot->setText("Forgot Password?");

$this->loginBar->add($register);
$this->loginBar->add($forgot);
$this->setDivision($this->loginBar);
}
}
?>

Kyttias
04-08-2016, 03:50 PM
You can use $mysidia->user->isloggedin to run a check, its a variable that holds a true/false value.

NobodysHero
04-08-2016, 04:46 PM
God Bless Coders. Just gonna say that right now.


Okay, Kyttias, thanks for replying, but just before checking this page, my back-up coder (Don't worry, i'm not the primary. LOL) figured out a fix. For those that want/need it, here's the code that works for MystFell.


<?php

/**
* The Sidebar Class, defines a standard HTML Sidebar component.
* It extends from the Widget class, while adding its own implementation.
* @category Resource
* @package Widget
* @author Hall of Famer
* @copyright Mysidia Adoptables Script
* @link http://www.mysidiaadoptables.com
* @since 1.3.3
* @todo Not much at this point.
*
*/

class Sidebar extends Widget{

/**
* The moneyBar property, specifies the money/donation bar for members.
* @access protected
* @var Paragraph
*/
protected $moneyBar;

/**
* The linksBar property, stores all useful links for members.
* @access protected
* @var Paragraph
*/
protected $linksBar;

/**
* The wolBar property, determines the who's online url in the sidebar.
* @access protected
* @var Link
*/
protected $wolBar;

/**
* The loginBar property, specifies the loginBar for guests.
* @access protected
* @var FormBuilder
*/
protected $loginBar;

/**
* Constructor of Sidebar Class, it initializes basic sidebar properties
* @access public
* @return Void
*/
public function __construct(){
parent::__construct(4, "sidebar");
}

/**
* The setDivision method, setter method for property $division.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @param GUIComponent $module
* @access protected
* @return Void
*/
protected function setDivision(GUIComponent $module){
if(!$this->division){
$this->division = new Division;
$this->division->setClass("sidebar");
}
$this->division->add($module);
}



#
#
#
/**** BEGIN: FOR THE FAVPET WIDGET ****/
public function getFavPetSB(){
return $this->FavPetSB;
}

public function setFavPetSB(){
$mysidia = Registry::get("mysidia");
$profile = $mysidia->user->getprofile();

if($profile->uid != 0) {

/* IF THE USER DOES *NOT* HAVE A FAVPET: */
if ($profile->getFavpetID() == "0"){
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
}

/* IF THE USER *DOES* HAVE A FAVPET: */
if ($profile->getFavpetID() != "0"){

$favpet = new OwnedAdoptable($profile->getFavpetID());
#
#
#
/**** BEGIN: CREATE RANDOM MESSAGES ****/
$message = "<div class='speechbubble'>";

$status_chance = mt_rand(1, 100);
if ($status_chance <= 1){ # One percent chance the pet will obtain a status effect.

/* We would apply a status effect here...*/
$message .= "<center>WHOOHOO! " . $favpet->getName() . " is having a great day!</center>";
#### We'll do this later!!!

} else { # Ninety-nine percent chance the pet will not get a status effect. Will something else happen?
$something_chance = mt_rand(1, 100);
if ($something_chance <= 25){ # Twenty-five percent chance something will happen.
$gift_chance = mt_rand(1, 100);
if ($gift_chance <= 5){ # Five percent chance the user will receive a gift from their pet.
$item_chance = mt_rand(1, 100);
if ($item_chance <= 50){ # Fifty percent chance the gift from their pet will be an item.

/* The pet has found an item for you! */
$num = mt_rand(1,5); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $item = "Juicy Carrot"; break;
case 2: $item = "Spice Spoon"; break;
case 3: $item = "Red Rose"; break;
case 4: $item = "Obsidian Arrowhead"; break;
case 5: $item = "Misshapen Zulk Plushie"; break;
}
$message .= "I found a {$item} for you!";
$newitem = new StockItem($item);
$newitem->append(1, $mysidia->user->username);

} else { # Fifty percent chance the gift from their pet will be money.

/* The pet has found some money for you! */
$currency = $mysidia->settings->cost;
$amount = mt_rand(100, 1000); # Between 100 and 1000
$message .= "Found {$amount} {$tyleans}!";
$mysidia->user->changecash($amount);

}
} else { # Twenty percent chance the pet will talk but have no gift.
/* No gift will be given but a neat species-specific phrase can still be said! */

$species = trim($favpet->getType());

switch ($species){
case "Wind Raptor": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Who, who!"; break;
case 2: $message .= "I like to soar through the sky."; break;
case 3: $message .= "Wanna share a berry?"; break;
case 4: $message .= "Don't worry! Anything shiny and I'll get it!"; break;
case 5: $message .= "Do you feel that breeze?"; break;
case 6: $message .= "Nocturnal? Nah, I'm awake when you're awake!"; break;
case 7: $message .= "Look what I can do!"; break;
}
break;

case "Terrahound": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!!"; break;
case 3: $message .= "Let's play fetch!"; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "Where do ya wanna to explore today?"; break;
case 6: $message .= "Terrahounds are the best totem pet!"; break;
case 7: $message .= "Today is a great day to be a Terrahound"; break;
}
break;

case "Water Selkie": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Ort, ort, ort!"; break;
case 2: $message .= "Let's go swimming!"; break;
case 3: $message .= "My favorite place is the Ice Flows."; break;
case 4: $message .= "OH! Something shiny! Awww, it melted."; break;
case 5: $message .= "Know what my favorite food is? Fish!"; break;
case 6: $message .= "The water is my natural element, but I'll go anywhere you go."; break;
case 7: $message .= "Cool as a cucumber, slick as a ice patch!"; break;
}
break;

case "Flame Bison": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Chaaaaaaaarrrrrge!"; break;
case 2: $message .= "Don't mind me, I'm just grazing."; break;
case 3: $message .= "I'm blazing fast!"; break;
case 4: $message .= "Do you have any carrots?"; break;
case 5: $message .= "My favorite place is the Hills."; break;
case 6: $message .= "No need to fear when I'm around!"; break;
case 7: $message .= "Yeah, I'm pretty hot stuff."; break;
}
break;

default: # If the species isn't defined above, it'll choose one of these default phrases instead.
$num = mt_rand(1,6);
switch ($num){
case 1: $message .= "It's a beautiful day! I love to explore!"; break;
case 2: $message .= "I always knew I was favorite material!"; break;
case 3: $message .= "I'm a little hungry. Think we could get a bite to eat?"; break;
case 4: $message .= "You're the only friend I'll ever need."; break;
case 5: $message .= "I found something! I foun- Oh, no. False alarm."; break;
case 6: $message .= "Don't worry! I'm on the look out for anything shine"; break;
}
break;
}

}
} else { # Seventy-five percent chance nothing will happen whatsoever.
/* Nothing will happen with the pet at all. */
$message = "";
}
}

if ($message == "") { $message = ""; } else { $message .= "</div>"; }

/**** END: CREATE RANDOM MESSAGES ****/
#
#
#

$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<img src='" . $favpet->getImage() . "' width='200px' height='200px'></br>"));
$this->FavPetSB->add(new Comment("<b><center><a href='/myadopts/manage/" . $profile->getFavpetID() . "'>{$favpet->getName()}</a></center></b>"));
$this->FavPetSB->add(new Comment("<p>" . $message . "</p>"));

}
$this->setDivision($this->FavPetSB);
}
}
/**** END: FOR THE FAVPET WIDGET ****/
#
#
#









/**
* The getMoneyBar method, getter method for property $moneyBar.
* @access public
* @return Paragraph
*/
public function getMoneyBar(){
return $this->moneyBar;
}

/**
* The setMoneyBar method, setter method for property $moneyBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;
$this->moneyBar->add(new Comment("<center><span id='cashonhand'><b>{$mysidia->settings->cost} :</b> {$mysidia->user->money}</span></center>"));

$donate = new Link("donate");
$donate->setText("<center>Donate Money to Friends</center>");
$this->moneyBar->add($donate);
$this->setDivision($this->moneyBar);
}

/**
* The getLinksBar method, getter method for property $linksBar.
* @access public
* @return Paragraph
*/
public function getLinksBar(){
return $this->linksBar;
}

/**
* The setLinksBar method, setter method for property $linksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinksBar(){
$mysidia = Registry::get("mysidia");
$this->linksBar = new Paragraph;
$linkTitle = new Comment("{$mysidia->user->username}'s Links:");
$linkTitle->setBold();
$this->linksBar->add($linkTitle);

$linksList = new LinksList("ul");
$this->setLinks($linksList);

$this->linksBar->add($linksList);
$this->setDivision($this->linksBar);
}

/**
* The setLinks method, append all links to the LinksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinks(LinksList $linksList){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("links", array("id", "linktext", "linkurl"), "linktype = 'sidelink' ORDER BY linkorder");
if($stmt->rowCount() == 0) Throw new Exception("There is an error with sidebar links, please contact the admin immediately for help.");

while($sideLink = $stmt->fetchObject()){
$link = new Link($sideLink->linkurl);
$link->setText($sideLink->linktext);
if($sideLink->linkurl == "messages"){
$num = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->rowCount();
if($num > 0) $link->setText("<b>{$link->getText()} ({$num})</b>");
}
$link->setListed(TRUE);
$linksList->add($link);
}

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);
}
}

/**
* The getWolBar method, getter method for property $wolBar.
* @access public
* @return LinksList
*/
public function getWolBar(){
return $this->wolBar;
}

/**
* The setWolBar method, setter method for property $wolBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setWolBar(){
$mysidia = Registry::get("mysidia");
$this->wolBar = new Link("online");
$online = $mysidia->db->select("online", array(), "username != 'Visitor'")->rowCount();
$offline = $mysidia->db->select("online", array(), "username = 'Visitor'")->rowCount();
$this->wolBar->setText("This site has {$online} members and {$offline} guests online.");
$this->setDivision($this->wolBar);
}

/**
* The getLoginBar method, getter method for property $loginBar.
* @access public
* @return FormBuilder
*/
public function getLoginBar(){
return $this->loginBar;
}

/**
* The setLoginBar method, setter method for property $loginBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLoginBar(){
$this->loginBar = new FormBuilder("login", "login", "post");
$loginTitle = new Comment("Member Login:");
$loginTitle->setBold();
$loginTitle->setUnderlined();
$this->loginBar->add($loginTitle);

$this->loginBar->buildComment("username: ", FALSE)
->buildTextField("username")
->buildComment("password: ", FALSE)
->buildPasswordField("password", "password", "", TRUE)
->buildButton("Log In", "submit", "submit")
->buildComment("Don't have an account?");

$register = new Link("register");
$register->setText("Register New Account");
$register->setLineBreak(TRUE);
$forgot = new Link("forgotpass");
$forgot->setText("Forgot Password?");

$this->loginBar->add($register);
$this->loginBar->add($forgot);
$this->setDivision($this->loginBar);
}
}
?>

THANK YOU EVERYONE THAT HELPED AND REPLIED! You're all amazing and give me a buzz if you ever sign up for MystFell. I'll totally hook you up. 8D

RestlessThoughts
04-10-2016, 02:21 AM
Yay, glad it's working for you now! :) I think you maybe left the user level blank instead of putting it as members only when creating the module, which probably caused the login error.
As an aside, {$tyleans} should probably just be tyleans and not set as a variable x)


I refactored this code a bit mostly for weighted item drops per species but I dunno about posting it. Kyttias' code works fine as is.