View Full Version : Error When Using Item
Abronsyth
08-13-2014, 12:08 PM
Purchasing an item works fine, and it works perfectly when I go to inventory>item>use.
I can get to the select adoptable page, but after I try to actually use it, it brings me to a blank white page and doesn't work. Sorry if my explanation doesn't make sense!
So this page is fine;
http://i.imgur.com/PxBFvxr.png
But after I click "Choose This Adopt" I end up on a blank page.
Does anyone else have this issue, or know how to fix it?
Warm regards,
Abron
Hall of Famer
08-13-2014, 03:30 PM
umm did you modify the item functions or the inventory.php file? If you get a white page its most likely a syntax error.
Abronsyth
08-13-2014, 03:34 PM
No, I have not touched it., or at least not that I recall. ((I wish PHP made more sense to me XD))
<?php
class InventoryController extends AppController{
const PARAM = "confirm";
private $view;
private $subController;
public function __construct(){
parent::__construct("member");
}
public function index(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$document->setTitle($mysidia->lang->inventory);
$inventory = new Inventory($mysidia->user);
if($inventory->gettotal() == 0) throw new InvalidIDException($mysidia->lang->inventory_empty);
$inventory->display();
}
public function uses(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new InvalidIDException("It appears that you do not have this item in your inventory.");
if($mysidia->input->post("aid")){
if(!$item->checktarget($mysidia->input->post("aid")) or $mysidia->input->post("validation") != "valid"){
$document->setTitle($mysidia->lang->use_title);
$document->addLangvar($mysidia->lang->use_fail);
}
elseif(!$item->randomchance()){
$item->remove();
$document->setTitle($mysidia->lang->badluck);
$document->addLangvar($mysidia->lang->effect);
}
else $item->apply($mysidia->input->post("aid"));
return;
}
$document->setTitle($mysidia->lang->select_title);
$document->addLangvar($mysidia->lang->select);
$chooseFrom = new Form("chooseform", "uses", "post");
$adoptable = new DropdownList("aid");
$ids = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}'")->fetchAll(PDO::FETCH_COLUMN);
$names = $mysidia->db->select("owned_adoptables", array("name"), "owner = '{$mysidia->user->username}'")->fetchAll(PDO::FETCH_COLUMN);
$adoptable->add(new Option("None Selected", "none"));
$adoptable->fill($names, $ids);
$chooseFrom->add($adoptable);
$chooseFrom->add(new PasswordField("hidden", "itemname", $mysidia->input->post("itemname")));
$chooseFrom->add(new PasswordField("hidden", "validation", "valid"));
$chooseFrom->add(new Button("Choose this Adopt", "submit", "submit"));
$document->add($chooseFrom);
}
public function sell(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new InvalidIDException("It appears that you do not have this item in your inventory.");
if(!$mysidia->input->post("quantity")){
$document->setTitle($mysidia->lang->global_action_title);
$document->addLangvar($mysidia->lang->sell_empty);
}
elseif($item->quantity < $mysidia->input->post("quantity")){
$document->setTitle($mysidia->lang->global_action_title);
$document->addLangvar($mysidia->lang->sell_quantity);
}
else{
$item->sell($mysidia->input->post("quantity"));
$document->setTitle("Transaction Completed");
$document->addLangvar("{$mysidia->lang->sell}{$mysidia->input->post("quantity")} {$mysidia->input->post("itemname")} {$mysidia->lang->sell2}");
}
}
public function toss(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new InvalidIDException("It appears that you do not have this item in your inventory.");
if($mysidia->input->get("confirm")){
$item->toss();
$document->setTitle($mysidia->lang->global_action_complete);
$document->addLangvar($mysidia->lang->toss.$mysidia->input->post("itemname").$mysidia->lang->toss2);
return;
}
$warning = "Are you sure you wish to toss {$mysidia->input->post("itemname")}?<br>
It will be permanently removed from your inventory, and this action cannot be undone!<br>";
$document->setTitle("Confirm your Action");
$document->add(new Comment($warning));
$confirmForm = new FormBuilder("confirmform", "toss/confirm", "post");
$confirmForm->buildPasswordField("hidden", "action", "toss")
->buildPasswordField("hidden", "itemname", $mysidia->input->post("itemname"))
->buildButton("Please Toss", "confirm", "confirm");
$document->add($confirmForm);
}
}
?>
Missy Master
08-13-2014, 04:14 PM
Ugh it did this for me too, several times now!
I am really praying for an answer to this! It's gotten to where I can't use ANY items now, once it does it to one .. plus, if I go in as a diff user? Then it works ok!
Missy Master
08-13-2014, 04:22 PM
Okay this is a huge problem now for me, if we cant figure it out Im going to have to take Simmland offline.
Just had it happen again and it locks up all use of ALL items, once it happens.
Go in under another name, and it's fine. So it cant be the ip ...
Hall of Famer
08-13-2014, 05:10 PM
I see, sounds serious. If anyone of you dont mind giving me ftp access to your server Id love to test something and see where the error is. Send me a PM of the information if you want to.
Missy Master
08-13-2014, 07:07 PM
Messaged you :)
Hwona
08-13-2014, 07:43 PM
Oh dear - is this affecting both v.1.3.3 and v.1.3.4?
Missy Master
08-13-2014, 09:24 PM
As far as I know, just .4.
But wow, its really bad and I have looked through everything and cannot find a trigger for it at ALL.
Abronsyth
08-13-2014, 09:54 PM
I am running 1.3.3 and having this issue. I can't remember if I've had it happen before, or not.
Missy Master
08-13-2014, 10:03 PM
Ah, thats a shame then! When it happens, I look at the user tables, everything, nothing has altered at all I can see, but it's just that user it happens to, for the moment. No idea why it happens, no idea how to undo it, but a few people had brought it to my attention and now it's happening to me too .. and it's so bad I might have to shut down totally.
No use of the toys or pets or any of that really screws up the whole site :(
Missy Master
08-14-2014, 02:55 PM
Okay, finally got it to happen on the secondary account ( miloe ) -- I used item after item and it was great, then I went and bought a few new pets --- got them fine --- then went back and tried to add an item and BAM!
White screen! http://sim-life.com/Simmland/inventory/uses
Hall of Famer
08-14-2014, 03:01 PM
umm do you find any patterns in this? Does this tend to happen to certain adoptables of yours or when you use certain items?
Missy Master
08-14-2014, 03:06 PM
No pattern so far, and I've been looking --- can be any pet, any species, any item. And I was wondering if it had something to do with the level of the pet or something, but then I realized, this happens - the white screen - at a point where you aren't even able to choose a pet yet, at least for me it does.
But just to be sure, i just applied items to level 0's and level 3's just fine.
On my third account, my test, since I cant use the others now.
Out of nowhere, you click use on something, and white screen.
Abronsyth
08-14-2014, 03:09 PM
For me it happens with either of the adoptables (only two exist right now on my site). I will try adding a new item and testing it out with that item.
If you need my FTP info just ask!
Missy Master
08-14-2014, 03:17 PM
I strongly suspect a bug located in inventory.php or something to do with it, but I could be wrong!
Missy Master
08-14-2014, 05:56 PM
If this helps ??
Going to Toss or Sell both DO still work, on all items!
It's just 'Use' that gets the white out!
I think its in function uses, but I just cant find it ..............
Hwona
08-14-2014, 06:10 PM
If this helps ??
Going to Toss or Sell both DO still work, on all items!
It's just 'Use' that gets the white out!
I think its in function uses, but I just cant find it ..............
If you have an inventory.php file in v.1.3.4, I THINK it's the first function that shows up...
umm, you said you're getting a blank screen? Doesn't that usually mean syntax error or something similar? O.o
Did this work before?
Missy Master
08-14-2014, 06:12 PM
Yeah it's on there as inventory.php ...
the thing is, it works for a while, then it suddenly stops, and you get white out on all items, from then on, on that account, to 'use ' them --- sign in under a diff name, and you are good to go.
It's really affecting things on my site, I didn't realize it was this bad. I'm looking at the function code to try to see whats wrong...
Missy Master
08-14-2014, 06:15 PM
This is inventoryview.php 'use' code:
public function uses(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
if($mysidia->input->post("aid")){
$message = (string)$this->getField("message");
$document->setTitle($mysidia->lang->global_action_complete);
$document->addLangvar($message);
return;
}
$petMap = $this->getField("petMap");
$document->setTitle($mysidia->lang->select_title);
$document->addLangvar($mysidia->lang->select);
$chooseFrom = new Form("chooseform", "uses", "post");
$adoptable = new DropdownList("aid");
$adoptable->add(new Option("None Selected", "none"));
if($petMap->size() > 0){
$iterator = $petMap->iterator();
while($iterator->hasNext()){
$adopt = $iterator->nextEntry();
$adoptable->add(new Option($adopt->getValue(), $adopt->getKey()));
}
}
$chooseFrom->add($adoptable);
$chooseFrom->add(new PasswordField("hidden", "itemname", $mysidia->input->post("itemname")));
$chooseFrom->add(new PasswordField("hidden", "validation", "valid"));
$chooseFrom->add(new Button("Choose this Adopt", "submit", "submit"));
$document->add($chooseFrom);
}
and
from inventory.php
public function uses(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new ItemException("use_none");
if($mysidia->input->post("aid")){
if(!$item->checktarget($mysidia->input->post("aid")) or $mysidia->input->post("validation") != "valid"){
throw new ItemException("use_fail");
}
elseif(!$item->randomchance()){
$item->remove();
throw new ItemException("use_effect");
}
else{
$message = $item->apply($mysidia->input->post("aid"));
$this->setField("message", $message);
}
return;
}
$stmt = $mysidia->db->select("owned_adoptables", array("aid", "name"), "owner = '{$mysidia->user->username}'");
$map = $mysidia->db->fetchMap($stmt);
$this->setField("petMap", $map);
}
Hwona
08-14-2014, 07:15 PM
This is really wierd. I'm using v.1.3.3 but I don't have this... wait, what host are you huys using?
Missy Master
08-14-2014, 07:17 PM
I'm on Skyehosting.
Hwona
08-14-2014, 07:43 PM
Do you both have the same host? I don't know...
@Abronsyth
You can borrow my site's inventory file! It works... for now. :L
Abronsyth
08-14-2014, 08:07 PM
I use iPage, so it's not to do with the host.
Wallie, thanks! If you can either post it or PM the code to me I can at least compare them and see if there's something different in there.
Missy Master
08-14-2014, 08:08 PM
I wonder if that would help me with mine? If I dont get this fixed, I'm going to have to shut down Simmland :(
No one can use items now.
Hwona
08-14-2014, 08:12 PM
Here you go(not I may have customized a thing or two in there):
<?php
class InventoryController extends AppController{
const PARAM = "confirm";
private $view;
private $subController;
public function __construct(){
parent::__construct("member");
}
public function index(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$document->setTitle($mysidia->lang->inventory);
$inventory = new Inventory($mysidia->user);
if($inventory->gettotal() == 0) throw new InvalidIDException($mysidia->lang->inventory_empty);
$inventory->display();
}
public function uses(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new InvalidIDException("It appears that you do not have this item in your inventory.");
if($mysidia->input->post("aid")){
if(!$item->checktarget($mysidia->input->post("aid")) or $mysidia->input->post("validation") != "valid"){
$document->setTitle($mysidia->lang->use_title);
$document->addLangvar($mysidia->lang->use_fail);
}
elseif(!$item->randomchance()){
$item->remove();
$document->setTitle($mysidia->lang->badluck);
$document->addLangvar($mysidia->lang->effect);
}
else $item->apply($mysidia->input->post("aid"));
return;
}
$document->setTitle($mysidia->lang->select_title);
$document->addLangvar($mysidia->lang->select);
$chooseFrom = new Form("chooseform", "uses", "post");
$adoptable = new DropdownList("aid");
$ids = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}'")->fetchAll(PDO::FETCH_COLUMN);
$names = $mysidia->db->select("owned_adoptables", array("name"), "owner = '{$mysidia->user->username}'")->fetchAll(PDO::FETCH_COLUMN);
$adoptable->add(new Option("None Selected", "none"));
$adoptable->fill($names, $ids);
$chooseFrom->add($adoptable);
$chooseFrom->add(new PasswordField("hidden", "itemname", $mysidia->input->post("itemname")));
$chooseFrom->add(new PasswordField("hidden", "validation", "valid"));
$chooseFrom->add(new Button("Choose this Adopt", "submit", "submit"));
$document->add($chooseFrom);
}
public function sell(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new InvalidIDException("It appears that you do not have this item in your inventory.");
if(!$mysidia->input->post("quantity")){
$document->setTitle($mysidia->lang->global_action_title);
$document->addLangvar($mysidia->lang->sell_empty);
}
elseif($item->quantity < $mysidia->input->post("quantity")){
$document->setTitle($mysidia->lang->global_action_title);
$document->addLangvar($mysidia->lang->sell_quantity);
}
else{
$item->sell($mysidia->input->post("quantity"));
$document->setTitle("Transaction Completed");
$document->addLangvar("{$mysidia->lang->sell}{$mysidia->input->post("quantity")} {$mysidia->input->post("itemname")} {$mysidia->lang->sell2}");
}
}
public function toss(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new InvalidIDException("It appears that you do not have this item in your inventory.");
if($mysidia->input->get("confirm")){
$item->toss();
$document->setTitle($mysidia->lang->global_action_complete);
$document->addLangvar($mysidia->lang->toss.$mysidia->input->post("itemname").$mysidia->lang->toss2);
return;
}
$warning = "Are you sure you wish to toss {$mysidia->input->post("itemname")}?<br>
It will be permanently removed from your inventory, and this action cannot be undone!<br>";
$document->setTitle("Confirm your Action");
$document->add(new Comment($warning));
$confirmForm = new FormBuilder("confirmform", "toss/confirm", "post");
$confirmForm->buildPasswordField("hidden", "action", "toss")
->buildPasswordField("hidden", "itemname", $mysidia->input->post("itemname"))
->buildButton("Please Toss", "confirm", "confirm");
$document->add($confirmForm);
}
}
?>
@Annatar
That would be horrible! You have a lot of custom stuff there no?
Missy Master
08-14-2014, 08:14 PM
I have a lot I've worked on for it, yes, and I have three more sites I really want to open, and use our great code here!
But no use of items means I cant do anything at all right now.
Ah, thanks for posting that!
The strangest thing is, sell works, and toss .. it's just use.
Hwona
08-14-2014, 08:22 PM
Wait....
I'm going to make a quick list of differences that I can find...
1. only the use function "returns" anything
2. only the use function works with adoptables
Missy Master
08-14-2014, 08:25 PM
Aww it wont work for me, hehehe.
Hwona
08-14-2014, 08:37 PM
Aww it wont work for me, hehehe.
I believe it's because you're using v.1.3.4. :L
Missy Master
08-14-2014, 08:40 PM
Yep I think so :)
Hall of Famer
08-15-2014, 05:53 AM
I have an account on your site now, I've purchased some items and I will adopt a few pets too. With this, I will try to reproduce the same white screen as you've encountered. I am sure theres a way to find out, I will let you know once I figure out. ^^
Missy Master
08-15-2014, 09:32 AM
Great!!
It took me ten times on one account and 20 on another to get it to happen, but once it did, there was no going back. Most of the members cant use items it seems now ...
Hwona
08-15-2014, 10:30 AM
@Annatar
Wait... do you think it's a problem with the database?
Missy Master
08-15-2014, 10:45 AM
Well, I really cant tell, because I've looked at everything after this happens, and right before, too, noted what all the user, item, inventory, banning, all those tables for all that, and I can't find one thing different in anything.
But it's likely some obscure value that gets inserted, or possibly there is a 'cut off' ?? Of how many items can be used?
It might possibly be something in where the amount of clicks and leveling gets cut off, there's something that seems to reach a cut off and then you error out and white out. Syntax is bad for it or something, but once you reach this critical point, you get no more chances then lol.
And bingo make a new account and log in, and you're right as rain.
Can't be ip based.
Hwona
08-15-2014, 10:52 AM
@Annatar
I tried over 30 times on my test site...
Nothing. Everything works.
What browser are you all using and how many items, pets, and users do you have?
Missy Master
08-15-2014, 10:55 AM
I know it isn't just me since others are having it happen on their sites, and once it happens, it doesn't matter what browser or anything, I have used Chrome, FF and IE.
Happens on all of them :(
I have about 20 users, 15 items, 10 pet species.
Try making an account on Simmland and see if it happens? I had to do it 15 times but it did happen again, and then 20 times later on a second account.
Hwona
08-15-2014, 10:57 AM
I know it isn't just me since others are having it happen on their sites, and once it happens, it doesn't matter what browser or anything, I have used Chrome, FF and IE.
Happens on all of them :(
I have about 20 users, 15 items, 10 pet species.
Try making an account on Simmland and see if it happens? I had to do it 15 times but it did happen again, and then 20 times later on a second account.
I'll try on your site... What kinds of items have you been using? O.o
Missy Master
08-15-2014, 11:03 AM
I've used Mature ( kicks a baby to level 3 ), and toys.
Let me paste the codes here for the toys for you :)
This is from functions_items.php, and is the basic outlay for all my add on toys. They work fine over and over, and then --- they don't. The only diff for any of these is they insert toys into different 'slots' to allow for more to be seen at a time.
Possibly it's reaching a cut off from the leveling of clicks or something? But then, why am I not the only one having it happen on their site ...
function items_click4($item, $adopt){
$mysidia = Registry::get("mysidia");
$newclicks = $item->value;
$mysidia->db->update("owned_adoptables", array("totalclicks" => $newclicks), "aid='{$adopt->aid}'and owner='{$item->owner}'");
$mysidia->db->update("owned_adoptables", array("toy_1" => $newclicks), "aid='{$adopt->aid}'and owner='{$item->owner}'");
$note = "You added a {$item->itemname}, and the Pet has just received a {$item->value}<br>";
//Now lets check if the adoptable has reached a new level.
$ownedAdopt = new OwnedAdoptable($adopt->aid);
if($ownedAdopt->hasNextLevel()){
//new level exists, time to check if the total clicks have reached required minimum clicks for next level.
$nextLevel = $ownedAdopt->getNextLevel();
$requiredClicks = $nextLevel->getRequiredClicks();
if($newclicks >= $requiredClicks and $requiredClicks != 0 and $requiredClicks != ""){
// We need to level this adoptable up...
$mysidia->db->update("owned_adoptables", array("currentlevel" => $nextlevel), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$note .= "And it has gained a new level!";
}
}
//Update item quantity...
$delitem = $item->remove();
return $note;
}
Hwona
08-15-2014, 11:05 AM
@Annatar
Okay... well, I tried this on canis, but I don't seem to be having any problems... O.o
Are you only having this on SIMLAND?
Edit: Can you test it out on my site?
Missy Master
08-15-2014, 11:09 AM
In class_ownedadoptable, you can see where the items are designated.
The only reason I can think for an item -- any item-- to work and work and then cut off, is that some barrier is being reached.
<?php
class OwnedAdoptable extends Adoptable{
protected $aid;
protected $name;
protected $owner;
protected $currentlevel;
protected $totalclicks;
protected $code;
protected $imageurl;
protected $usealternates;
protected $tradestatus;
protected $isfrozen;
protected $gender;
protected $offsprings;
protected $lastbred;
protected $nextlevel;
protected $voters;
protected $statname;
protected $mother;
protected $father;
protected $toy_1;
protected $toy_2;
protected $toy_3;
protected $toy_4;
protected $toy_5;
protected $unique;
protected $adoptablepersonality;
public function __construct($aid, $owner = ""){
$mysidia = Registry::get("mysidia");
$whereClause = "aid ='{$aid}'";
if(!empty($owner)) $whereClause .= " and owner = '{$owner}'";
$row = $mysidia->db->select("owned_adoptables", array(), $whereClause)->fetchObject();
if(!is_object($row)) throw new AdoptNotfoundException("Pet{$adoptinfo} does not exist or does not belong to the owner specified...");
parent::__construct($row->type);
foreach($row as $key => $val){
$this->$key = $val;
}
}
public function getAdoptID(){
return $this->aid;
}
public function getName(){
return $this->name;
}
public function getAdoptstatname(){
return $this->statname;
}
public function getAdoptPersonality(){
return $this->personality;
}
public function setName($name, $assignMode = ""){
if($assignMode == Model::UPDATE) $this->save("name", $name);
$this->name = $name;
}
public function getOwner($fetchMode = ""){
if($fetchMode == Model::MODEL) return new Member($this->owner);
else return $this->owner;
}
public function setOwner($owner, $assignMode = ""){
if($assignMode == Model::UPDATE) $this->save("owner", $owner);
$this->owner = $owner;
}
public function getCurrentLevel($fetchMode = ""){
if($fetchMode == Model::MODEL) return new AdoptLevel($this->type, $this->currentlevel);
else return $this->currentlevel;
}
public function setCurrentLevel($level, $assignMode = ""){
if($assignMode == Model::UPDATE){
$this->save("currentlevel", $level);
if($this->getAltStatus() == "yes") $this->save("usealternates", "yes");
}
$this->currentlevel = $level;
}
public function getTotalClicks(){
return $this->totalclicks;
}
public function setTotalClicks($clicks, $assignMode = ""){
if($assignMode == Model::UPDATE) $this->save("totalclicks", $clicks);
$this->totalclicks = $clicks;
}
public function getCode(){
return $this->code;
}
public function getImageURL($fetchMode = ""){
if($fetchMode == Model::GUI) return new Image($this->imageurl);
else return $this->imageurl;
}
public function useAlternates(){
return $this->usealternates;
}
public function getTradeStatus(){
return $this->tradestatus;
}
public function getUnique(){
return $this->unique;
}
public function getMother(){
return $this->mother;
}
public function getFather(){
return $this->father;
}
public function getToy_1(){
return $this->toy_1;
}
public function getToy_2(){
return $this->toy_2;
}
public function getToy_3(){
return $this->toy_3;
}
public function getToy_4(){
return $this->toy_4;
}
public function getToy_5(){
return $this->toy_5;
}
public function setTradeStatus($status, $assignMode = ""){
if($assignMode == Model::UPDATE) $this->save("tradestatus", $status);
$this->tradestatus = $status;
}
public function isFrozen(){
return $this->isfrozen;
}
public function setFrozen($frozen = TRUE, $assignMode = ""){
if($assignMode == Model::UPDATE) $this->save("isfrozen", $frozen);
$this->isfrozen = $frozen;
}
public function getGender($fetchMode = ""){
if($fetchMode == Model::GUI) return new Image("picuploads/{$this->gender}.png");
else return $this->gender;
}
public function getOffsprings(){
return $this->offsprings;
}
public function setOffsprings($offsprings = 1, $assignMode = ""){
$this->offsprings = $offsprings;
if($assignMode == Model::UPDATE) $this->save("offsprings", $this->offsprings);
}
public function getLastBred($fetchMode = ""){
if($fetchMode == Model::OBJ) return new DateTime($this->lastbred);
return $this->lastbred;
}
public function setLastBred($lastBred = 0, $assignMode = ""){
if($assignMode == Model::UPDATE) $this->save("lastbred", $lastBred);
$this->lastbred = $lastBred;
}
public function getAltStatus(){
if($this->alternates == "enabled" and $this->currentlevel == $this->altoutlevel){
$rand = mt_rand(1, $this->altchance);
if($rand == 1) return "yes";
}
return "no";
}
public function getImage($fetchMode = ""){
if($this->imageurl and $this->currentlevel >= 3) return $this->getImageUrl($fetchMode);
if($this->currentlevel == 0) return $this->getEggImage($fetchMode);
$mysidia = Registry::get("mysidia");
$level = $this->getCurrentLevel("model");
if($this->useAlternates() == "yes") return $level->getAlternateImage($fetchMode);
else return $level->getPrimaryImage($fetchMode);
}
public function hasNextLevel(){
try{
$this->nextlevel = new AdoptLevel($this->type, $this->currentlevel + 1);
return TRUE;
}
catch(LevelNotfoundException $lne){
return FALSE;
}
}
public function getNextLevel(){
if(!$this->nextlevel) return FALSE;
return $this->nextlevel;
}
public function getLevelupClicks(){
if(!$this->nextlevel) return FALSE;
return $this->nextlevel->getRequiredClicks() - $this->totalclicks;
}
public function getStats(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$stats = new Division("adoptstats");
$stats->add(new Image("picuploads/{$this->toy_1}.png"));
$stats->add(new Image("picuploads/{$this->toy_2}.png"));;
$stats->add(new Image("picuploads/{$this->toy_3}.png"));;
$stats->add(new Image("picuploads/{$this->toy_4}.png"));;
$stats->add(new Image("picuploads/{$this->toy_5}.gif"));;
$stats->add(new Comment("<br><br><b>Total Boosts: {$this->totalclicks}"));
if($this->hasNextLevel()){
$level = $this->getNextLevel();
$levelupClicks = $this->getLevelupClicks();
$nextLevel = $level->getLevel().$mysidia->lang->clicks.$levelupClicks;
}
else $nextLevel = $mysidia->lang->maximum;
$stats->add(new Comment("Gender: ", FALSE));
$stats->add(new Image("picuploads/{$this->gender}.png"));
$adoptStats = "<br>Trade Status: {$this->tradestatus}<br>
Father: {$this->father}<br>
Mother: {$this->mother}<br>
Value: {$this->statname}<br>
Unique: {$this->unique}<br>
Current Status: {$this->currentlevel}<br>Next Status: {$nextLevel}</b>";
$stats->add(new Comment($adoptStats));
return $stats;
}
public function hasVoter($user, $date = ""){
if(!$date) $date = new DateTime;
$mysidia = Registry::get("mysidia");
if($user instanceof Member){
$whereClause = "adoptableid='{$this->aid}' and username = '{$user->username}' and date = '{$date->format('Y-m-d')}'";
}
else{
$ip = secure($_SERVER['REMOTE_ADDR']);
$whereClause = "adoptableid='{$mysidia->input->get("aid")}' and ip = '{$ip}' and date = '{$date->format('Y-m-d')}'";
}
$void = $mysidia->db->select("vote_voters", array("void"), $whereClause)->fetchColumn();
if(is_numeric($void)) return TRUE;
else return FALSE;
}
protected function save($field, $value){
$mysidia = Registry::get("mysidia");
$mysidia->db->update("owned_adoptables", array($field => $value), "aid='{$this->aid}'");
}
}
?>
Abronsyth
08-15-2014, 11:09 AM
Here's my inventory.php;
<?php
class InventoryController extends AppController{
const PARAM = "confirm";
private $view;
private $subController;
public function __construct(){
parent::__construct("member");
}
public function index(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$document->setTitle($mysidia->lang->inventory);
$inventory = new Inventory($mysidia->user);
if($inventory->gettotal() == 0) throw new InvalidIDException($mysidia->lang->inventory_empty);
$inventory->display();
}
public function uses(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new InvalidIDException("It appears that you do not have this item in your inventory.");
if($mysidia->input->post("aid")){
if(!$item->checktarget($mysidia->input->post("aid")) or $mysidia->input->post("validation") != "valid"){
$document->setTitle($mysidia->lang->use_title);
$document->addLangvar($mysidia->lang->use_fail);
}
elseif(!$item->randomchance()){
$item->remove();
$document->setTitle($mysidia->lang->badluck);
$document->addLangvar($mysidia->lang->effect);
}
else $item->apply($mysidia->input->post("aid"));
return;
}
$document->setTitle($mysidia->lang->select_title);
$document->addLangvar($mysidia->lang->select);
$chooseFrom = new Form("chooseform", "uses", "post");
$adoptable = new DropdownList("aid");
$ids = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}'")->fetchAll(PDO::FETCH_COLUMN);
$names = $mysidia->db->select("owned_adoptables", array("name"), "owner = '{$mysidia->user->username}'")->fetchAll(PDO::FETCH_COLUMN);
$adoptable->add(new Option("None Selected", "none"));
$adoptable->fill($names, $ids);
$chooseFrom->add($adoptable);
$chooseFrom->add(new PasswordField("hidden", "itemname", $mysidia->input->post("itemname")));
$chooseFrom->add(new PasswordField("hidden", "validation", "valid"));
$chooseFrom->add(new Button("Choose this Adopt", "submit", "submit"));
$document->add($chooseFrom);
}
public function sell(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new InvalidIDException("It appears that you do not have this item in your inventory.");
if(!$mysidia->input->post("quantity")){
$document->setTitle($mysidia->lang->global_action_title);
$document->addLangvar($mysidia->lang->sell_empty);
}
elseif($item->quantity < $mysidia->input->post("quantity")){
$document->setTitle($mysidia->lang->global_action_title);
$document->addLangvar($mysidia->lang->sell_quantity);
}
else{
$item->sell($mysidia->input->post("quantity"));
$document->setTitle("Transaction Completed");
$document->addLangvar("{$mysidia->lang->sell}{$mysidia->input->post("quantity")} {$mysidia->input->post("itemname")} {$mysidia->lang->sell2}");
}
}
public function toss(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new InvalidIDException("It appears that you do not have this item in your inventory.");
if($mysidia->input->get("confirm")){
$item->toss();
$document->setTitle($mysidia->lang->global_action_complete);
$document->addLangvar($mysidia->lang->toss.$mysidia->input->post("itemname").$mysidia->lang->toss2);
return;
}
$warning = "Are you sure you wish to toss {$mysidia->input->post("itemname")}?<br>
It will be permanently removed from your inventory, and this action cannot be undone!<br>";
$document->setTitle("Confirm your Action");
$document->add(new Comment($warning));
$confirmForm = new FormBuilder("confirmform", "toss/confirm", "post");
$confirmForm->buildPasswordField("hidden", "action", "toss")
->buildPasswordField("hidden", "itemname", $mysidia->input->post("itemname"))
->buildButton("Please Toss", "confirm", "confirm");
$document->add($confirmForm);
}
}
?>
Missy Master
08-15-2014, 11:11 AM
It's only on SIMMLAND yes .. Canis and Felis are diff scripts.
Yes I will test it on yours, on Caterpillar ?
Hwona
08-15-2014, 11:16 AM
@Annatar
Please do. :3 I've done it over 50 time on canis - that's working...
wait, are they both using mysidia?
Edit: can you post a link to simmland
Missy Master
08-15-2014, 11:20 AM
Canis and Felis both use my own heavily modded version of the old script.
Only Simmland uses Mysidia right now, but it's going to be used for all my upcoming sites so getting this to work is critical.
So yeah, if you can do this on Simmland that would be great :)
And I am off to Caterpillar to try !
Hwona
08-15-2014, 11:21 AM
Canis and Felis both use my own heavily modded version of the old script.
Only Simmland uses Mysidia right now, but it's going to be used for all my upcoming sites so getting this to work is critical.
So yeah, if you can do this on Simmland that would be great :)
And I am off to Caterpillar to try !
Link to simmland please?
Missy Master
08-15-2014, 11:26 AM
Wallie... you have a seriously gorgeous and well laid out site, I just had to comment :)
Just really beautifully laid out!
http://sim-life.com/Simmland
Hwona
08-15-2014, 11:31 AM
@Annater
Thank you! Umm, I'm testing right now...
Missy Master
08-15-2014, 11:41 AM
It took me a good many tries, but boy, once it goes bad, there's no making it good again without making a new account D:
Hwona
08-15-2014, 11:42 AM
It took me a good many tries, but boy, once it goes bad, there's no making it good again without making a new account D:
So how did it go? I tested over 60 times on simmland...
@Abronsyth
Apparently, there IS a difference in our code.
Here:
https://www.diffchecker.com/diff
Check this out with our codes... it looks like things are in different positions.
Missy Master
08-15-2014, 11:45 AM
It never happened on Caterpillar at all .. and wow, 60 times and nothing.
I just don't get it, its baffling to me. And Abronsyth is having it happen too, so I know it isn't just my site.
I don't get it!!
Thanks for trying Wallie .. what a mystery ... hopefully HoF is having some luck.
Hwona
08-15-2014, 11:52 AM
@Annatar
You said that this is only affecting the USE function???
O.o ???????
Missy Master
08-15-2014, 11:53 AM
Yep!!
Isnt that weird? Toss and Sell both continue to work fine!
But Use gets the white out, once it starts!
Hwona
08-15-2014, 11:58 AM
@Annatar
Wait, do you have an invetory.php file I could take a peek at?
Missy Master
08-15-2014, 12:00 PM
Sure ! here you go :)
<?php
class InventoryController extends AppController{
const PARAM = "confirm";
public function __construct(){
parent::__construct("member");
}
public function index(){
$mysidia = Registry::get("mysidia");
$inventory = new Inventory($mysidia->user);
if($inventory->gettotal() == 0) throw new InvalidIDException("inventory_empty");
$this->setField("inventory", $inventory);
}
public function uses(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new ItemException("use_none");
if($mysidia->input->post("aid")){
if(!$item->checktarget($mysidia->input->post("aid")) or $mysidia->input->post("validation") != "valid"){
throw new ItemException("use_fail");
}
elseif(!$item->randomchance()){
$item->remove();
throw new ItemException("use_effect");
}
else{
$message = $item->apply($mysidia->input->post("aid"));
$this->setField("message", $message);
}
return;
}
$stmt = $mysidia->db->select("owned_adoptables", array("aid", "name"), "owner = '{$mysidia->user->username}'");
$map = $mysidia->db->fetchMap($stmt);
$this->setField("petMap", $map);
}
public function sell(){
$mysidia = Registry::get("mysidia");
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new ItemException("sell_none");
if(!$mysidia->input->post("quantity")) throw new ItemException("sell_empty");
elseif($item->quantity < $mysidia->input->post("quantity")) throw new ItemException("sell_quantity");
else $item->sell($mysidia->input->post("quantity"));
}
public function toss(){
$mysidia = Registry::get("mysidia");
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new ItemException("toss_none");
if($mysidia->input->get("confirm")){
$item->toss();
return;
}
}
public function alchemy(){
$mysidia = Registry::get("mysidia");
$settings = new AlchemySetting($mysidia->db);
if($settings->system == "disabled") throw new ItemException("alchemy_disabled");
if($mysidia->input->post("iid") and $mysidia->input->post("iid2")){
$alchemy = new Alchemy($mysidia->input->post("iid"), $mysidia->input->post("iid2"), $settings);
$alchemy->mix();
$this->setField("alchemy", $alchemy);
return;
}
$stmt = $mysidia->db->select("inventory", array("iid", "itemname"), "owner = '{$mysidia->user->username}'");
$map = $mysidia->db->fetchMap($stmt);
$this->setField("itemMap", $map);
$this->setField("settings", $settings);
}
}
?>
Hwona
08-15-2014, 12:07 PM
@Annatar
Of course there are some differences because of our versions, but there may just be something in there... I checked, but I couldn't catch anything that really stood out... maybe you're sharper?
Missy Master
08-15-2014, 12:11 PM
I've looked and looked and looked, for days now .. the only thing i can think is its something to do with the adding clicks or leveling or something, getting to a point it just cuts off the 'Use' function for ALL items suddenly.
HoF is going to have to cure this I think, lol, I am stumped, totally now.
Hall of Famer
08-15-2014, 12:31 PM
So if it affects an account it will not be able to use items anymore? I think I am starting to understand this a bit, I cant describe it yet but it will help me better if anyone of you provide me link to your control panel. If I can access your database in phpmyadmin and take a look there. There may be some corrupted data that I can fix for you and your account can be used again. But of course, I still need to find where the corrupted data is generated then, but that can be done later.
Missy Master
08-15-2014, 12:39 PM
Sent you a PM !
Hall of Famer
08-15-2014, 04:06 PM
I've found the solution to this glitch now, it has something to do with a single line in script file classes/resource/collection/class_linkedhashmap.php. Someone already pointed it out before, but it was back in January so its after Mys v1.3.4 was released. This error will go away in Mys v1.4.0 completely:
http://mysidiaadoptables.com/forum/project.php?issueid=37
To fix this issue, find this line:
for($entry = $this->header->getAfter(); $entry != $this->header; $entry = $entry->getAfter()){
Change it to:
for($entry = $this->header->getAfter(); $entry !== $this->header; $entry = $entry->getAfter()){
It basically changes != into !==, and everything will work like a charm. ^^
Hwona
08-15-2014, 04:13 PM
@HoF
That's great! :D What about Abronsyth's problem with v.1.3.3? There's no linkedhashmap in this version. :3
Hall of Famer
08-15-2014, 04:15 PM
Umm I think it could be some other issues, if she has an error log file Id like her to present it to me so I can look it up. Otherwise I will have to log into her ftp to see where the problem is. XD
Missy Master
08-15-2014, 04:44 PM
Well you have certainly saved the day for me, dear friend.
Off to create more sites with this fabulous script!! :)
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.