Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 04-16-2015, 01:58 PM
kristhasirah's Avatar
kristhasirah kristhasirah is offline
Member
 
Join Date: Jan 2010
Location: In middle of the nothingness
Posts: 196
Gender: Female
Credits: 32,650
kristhasirah
Default limit adopted eggs

need help converting this code from ver. 1.3.2 to 1.3.4
already tried to change the code but cant make it work.

PHP Code:
else
{
$stmt $mysidia->db->select("owned_adoptables", array(), constant("PREFIX")."owned_adoptables.owner = '{$mysidia->user->username}'");
$count 0;
while(
$adopt $stmt->fetchObject())
{
if(
$adopt->currentlevel <= 6) { $count++;}
}
if(
$count >= 5)
{
$mysidia->page->settitle("Too many eggs");
$mysidia->page->addcontent("You've got too many eggs and should wait until you've hatched one.");

__________________
Reply With Quote
  #2  
Old 04-16-2015, 05:28 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,039
Kyttias is on a distinguished road
Default

The way of writing the database query has changed, as well as setting a document's title and contents. I'll try to take a look at it a bit later.

From what I can make of it, you're trying to prevent a user from adopting any more pets if they already own so many pets under a certain level?
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #3  
Old 04-16-2015, 09:34 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,039
Kyttias is on a distinguished road
Default

Alright, inside adoptview.php, find this function:

PHP Code:
if($mysidia->input->post("submit")){ 
     
/* The current contents of this function... */ 

You'll be placing the current contents of this function inside an else statement.

PHP Code:
if($mysidia->input->post("submit")){
    
$number 5/* You want users to have no more than THIS ($number) many pets with...*/
    
$level 6/* ...a level less than or equal to THIS ($level) number! */
    
$petsAtLevel $mysidia->db->select("owned_adoptables", array(), "owner = '{$mysidia->user->username}' AND currentlevel <= $level")->rowCount();
    if (
$petsAtLevel $number){ /* If the number of pets at this level is greater than number... */
        
$document->setTitle("Too Many Eggs!");
        
$document->add(new Comment("You've got too many eggs and should wait until you've hatched one."FALSE));
    }
    else { 
        
/* Else show the previously existing contents of input->post("submit") and let users adopt things... */            
    
}

Try this for me and see if it works as intended? Make sure the old contents of the function get pasted inside the else statement.

When a person goes to try to adopt a new pet now, the error will display instead.

However, the bottom of this file also contains the button that will send the form. You might consider wrapping it in an if statement and removing access to it entirely when the user has too many low level pets/eggs and replacing it with a memo instructing them to go level things up instead.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 04-16-2015 at 09:38 PM.
Reply With Quote
  #4  
Old 04-17-2015, 04:45 AM
draugluin's Avatar
draugluin draugluin is offline
Member
 
Join Date: Oct 2011
Location: germany
Posts: 120
Gender: Unknown/Other
Credits: 12,436
draugluin is on a distinguished road
Default

Umm... I've tried that.

but I got both. The comment, I've too many eggs AND "Congratulations...you just adopt..."



Is it possible to get this function for the adopt-shop too ?

Last edited by draugluin; 04-17-2015 at 04:48 AM.
Reply With Quote
  #5  
Old 04-17-2015, 09:22 AM
kristhasirah's Avatar
kristhasirah kristhasirah is offline
Member
 
Join Date: Jan 2010
Location: In middle of the nothingness
Posts: 196
Gender: Female
Credits: 32,650
kristhasirah
Default

yes im trying to prevent users from adopting more eggs...
I think im doing something wrong because i only get a blank page when i click the submit botton... and when i look at my owned adopts the adopt is there...

PHP Code:
<?php

class AdoptView extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
         
        if(
$mysidia->input->post("submit")){
    
$number 5/* You want users to have no more than THIS ($number) many pets with...*/
    
$level 6/* ...a level less than or equal to THIS ($level) number! */
    
$petsAtLevel $mysidia->db->select("owned_adoptables", array(), "owner = '{$mysidia->user->username}' AND currentlevel <= $level")->rowCount();
    if (
$petsAtLevel $number){ /* If the number of pets at this level is greater than number... */
        
$document->setTitle("Too Many Eggs!");
        
$document->add(new Comment("You've got too many eggs and should wait until you've hatched one."FALSE));
    }
    else { 
        
            
$aid $this->getField("aid")->getValue();
            
$name $this->getField("name")->getValue();
            
$eggImage $this->getField("eggImage")->getValue();
            
$image = new Image($eggImage);
            
$image->setLineBreak(TRUE);    
            
            
$document->setTitle("{$name} adopted successfully");            
            
$document->add($image);
            
$document->addLangvar("Congratulations!  You just adopted {$name}.  You can now manage {$name} on the ");
            
$document->add(new Link("myadopts""Myadopts Page."));
            
$document->add(new Comment(""));
            
$document->add(new Link("myadopts/manage/{$aid}""Click Here to Manage {$name}"));
            
$document->add(new Comment(""));
            
$document->add(new Link("myadopts/bbcode/{$aid}""Click Here to get BBCodes/HTML Codes for {$name}"));
            
$document->add(new Comment(""));
            
$document->addLangvar("Be sure and");
            
$document->add(new Link("levelup/click/{$aid}""feed "));
            
$document->addLangvar("{$name} with clicks so that they grow!");
            return;
        }
}
        
$document->setTitle($mysidia->lang->title);
        
$document->addLangvar((!$mysidia->user->isloggedin)?$mysidia->lang->guest:$mysidia->lang->member); 

        
        
$adoptForm = new Form("form""adopt""post");
        
$adoptTitle = new Comment("Available Adoptables");
        
$adoptTitle->setHeading(3);
        
$adoptForm->add($adoptTitle);
        
$adoptTable = new Table("table"""FALSE);
         
        
$adopts $this->getField("adopts");
        for(
$i 0$i $adopts->length(); $i++){
            
$row = new TRow;
            
$idCell = new TCell(new RadioButton("""id"$adopts[$i]->getID()));                
            
$imageCell = new TCell(new Image($adopts[$i]->getEggImage(), $adopts[$i]->getType()));
            
$imageCell->setAlign(new Align("center"));
                
            
$type = new Comment($adopts[$i]->getType());
            
$type->setBold();
            
$description = new Comment($adopts[$i]->getDescription(), FALSE);
            
$typeCell = new TCell;
            
$typeCell->add($type);
            
$typeCell->add($description);            

            
$row->add($idCell);
            
$row->add($imageCell);
            
$row->add($typeCell);
            
$adoptTable->add($row);
        }
        
        
$adoptForm->add($adoptTable);        
        
$adoptSubtitle = new Comment("Adopt");
        
$adoptSubtitle->setHeading(3);
        
$adoptForm->add($adoptSubtitle);
        
$adoptForm->add(new Comment("Adoptable Name: "FALSE));
        
$adoptForm->add(new TextField("name"));
        
$adoptForm->add(new Comment(""));
        
$adoptForm->add(new Button("Create this Adoptable""submit""submit"));
        
$document->add($adoptForm);
    }
}

?>
no idea what im doing wrong... and im have 0 experience at coding... only know how to install mods and make small changes... so no idea how to do the wrapping of if statement for the submit botton...
__________________
Reply With Quote
  #6  
Old 04-17-2015, 10:39 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,039
Kyttias is on a distinguished road
Default

Alright, let's just not display any pets here at all if the user has too many eggs, then? It'd just be teasing them, anyway.

Here's the whole document now:
PHP Code:
<?php

class AdoptView extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;

        
$number 5/* You want users to have no more than THIS ($number) many pets with...*/
        
$level 6/* ...a level less than or equal to THIS ($level) number! */
        
$petsAtLevel $mysidia->db->select("owned_adoptables", array(), "owner = '{$mysidia->user->username}' AND currentlevel <= $level")->rowCount();
        if (
$petsAtLevel $number){ /* If the number of pets at this level is greater than number... */
            
$document->setTitle("Too Many Eggs!");
            
$document->add(new Comment("You've got too many eggs and should wait until you've hatched one."FALSE));
        }
        else { 
/* Else show existing things... */   
        
            
if($mysidia->input->post("submit")){
                
$aid $this->getField("aid")->getValue();
                
$name $this->getField("name")->getValue();
                
$eggImage $this->getField("eggImage")->getValue();
                
$image = new Image($eggImage);
                
$image->setLineBreak(TRUE);    
                
                
$document->setTitle("{$name} adopted successfully");            
                
$document->add($image);
                
$document->addLangvar("Congratulations!  You just adopted {$name}.  You can now manage {$name} on the ");
                
$document->add(new Link("myadopts""Myadopts Page."));
                
$document->add(new Comment(""));
                
$document->add(new Link("myadopts/manage/{$aid}""Click Here to Manage {$name}"));
                
$document->add(new Comment(""));
                
$document->add(new Link("myadopts/bbcode/{$aid}""Click Here to get BBCodes/HTML Codes for {$name}"));
                
$document->add(new Comment(""));
                
$document->addLangvar("Be sure and");
                
$document->add(new Link("levelup/{$aid}""feed "));
                
$document->addLangvar("{$name} with clicks so that they grow!");
                return;
            }
            
            
$document->setTitle($mysidia->lang->title);
            
$document->addLangvar((!$mysidia->user->isloggedin)?$mysidia->lang->guest:$mysidia->lang->member);          
            
$adoptForm = new Form("form""adopt""post");
            
$adoptTitle = new Comment("Available Adoptables");
            
$adoptTitle->setHeading(3);
            
$adoptForm->add($adoptTitle);
            
$adoptTable = new Table("table"""FALSE);
             
            
$adopts $this->getField("adopts");
            for(
$i 0$i $adopts->length(); $i++){
                
$row = new TRow;
                
$idCell = new TCell(new RadioButton("""id"$adopts[$i]->getID()));                
                
$imageCell = new TCell(new Image($adopts[$i]->getEggImage(), $adopts[$i]->getType()));
                
$imageCell->setAlign(new Align("center"));
                    
                
$type = new Comment($adopts[$i]->getType());
                
$type->setBold();
                
$description = new Comment($adopts[$i]->getDescription(), FALSE);
                
$typeCell = new TCell;
                
$typeCell->add($type);
                
$typeCell->add($description);            

                
$row->add($idCell);
                
$row->add($imageCell);
                
$row->add($typeCell);
                
$adoptTable->add($row);
            }
            
            
$adoptForm->add($adoptTable);        
            
$adoptSubtitle = new Comment("Adopt");
            
$adoptSubtitle->setHeading(3);
            
$adoptForm->add($adoptSubtitle);
            
$adoptForm->add(new Comment("Adoptable Name: "FALSE));
            
$adoptForm->add(new TextField("name"));
            
$adoptForm->add(new Comment(""));
            
$adoptForm->add(new Button("Adopt Me""submit""submit"));
            
$document->add($adoptForm);
        }
    }
}
?>
@draugluin - As for the adopt shop, it's not a feature I'm making use of on my site so I wouldn't know how to make modifications there without creating one... If this is a feature to prevent new players from hoarding pets without patience, it's unlikely these new players will have enough funds to even purchase more eggs from a shop. And if they have money, why not let them, anyway? If you still really want this, classes/class_adoptshop.php, the display() function can be changed:

PHP Code:
public function display(){
    
$mysidia Registry::get("mysidia");      
    
$document $mysidia->frame->getDocument();              
    
$document->addLangvar($mysidia->lang->select_adopt);
    if(
$this->gettotal() == 0){
        
$document->addLangvar($mysidia->lang->empty);
        return;
    }     

    
$number 5/* You want users to have no more than THIS ($number) many pets with...*/
    
$level 6/* ...a level less than or equal to THIS ($level) number! */
    
$petsAtLevel $mysidia->db->select("owned_adoptables", array(), "owner = '{$mysidia->user->username}' AND currentlevel <= $level")->rowCount();
    if (
$petsAtLevel $number){ /* If the number of pets at this level is greater than number... */
        
$document->setTitle("Too Many Eggs!");
        
$document->add(new Comment("You've got too many eggs and should wait until you've hatched one."FALSE));
    }
    else { 
/* Else show existing things... */   
      
        
$adoptList = new TableBuilder("shop");
        
$adoptList->setAlign(new Align("center""middle"));
        
$adoptList->buildHeaders("Image""Class""Type""Description""Price""Buy");    
        
$adoptList->setHelper(new ShopTableHelper);      
        
$this->adopts $this->getadopttypes();
      
        foreach(
$this->adopts as $stockadopt){
            
$adopt $this->getadopt($stockadopt->type);
            
$cells = new LinkedList;
            
$cells->add(new TCell($this->getadoptimage($adopt->eggimage)));
            
$cells->add(new TCell($adopt->class));
            
$cells->add(new TCell($adopt->type));
            
$cells->add(new TCell($adopt->description));
            
$cells->add(new TCell($adopt->cost));
            
$cells->add(new TCell($adoptList->getHelper()->getAdoptPurchaseForm($this$adopt)));
            
$adoptList->buildRow($cells);
        }      
        
$document->add($adoptList);        
    }

Try that and let me know how it's working?
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 04-17-2015 at 10:49 AM.
Reply With Quote
  #7  
Old 04-17-2015, 11:01 AM
kristhasirah's Avatar
kristhasirah kristhasirah is offline
Member
 
Join Date: Jan 2010
Location: In middle of the nothingness
Posts: 196
Gender: Female
Credits: 32,650
kristhasirah
Default

Thank you!! Kyttias!!!
__________________
Reply With Quote
  #8  
Old 04-17-2015, 02:03 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,039
Kyttias is on a distinguished road
Default

Yay! Great, I'm glad things worked out.

Though this is completely unrelated, I think you might be able to learn a lot, coding-wise, if you read through this post I made while helping someone else -- I explained a lot of what I've come to understand about the framework (at least v1.3.4) so far here, including some basic explanation of object-oriented stuffs.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #9  
Old 04-18-2015, 02:41 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 482,946
Hall of Famer is on a distinguished road
Default

Quote:
Originally Posted by Kyttias View Post
Yay! Great, I'm glad things worked out.

Though this is completely unrelated, I think you might be able to learn a lot, coding-wise, if you read through this post I made while helping someone else -- I explained a lot of what I've come to understand about the framework (at least v1.3.4) so far here, including some basic explanation of object-oriented stuffs.
I am glad you were able to find out how to use some of the APIs despite very poor to nonexistent documentation so far. I apologize for this, in Mys v1.4.x the documentation will be rich and very helpful. If you have any questions regarding the framework, lemme know and I will be able to answer on AIM when I get a chance.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #10  
Old 04-19-2015, 09:13 AM
draugluin's Avatar
draugluin draugluin is offline
Member
 
Join Date: Oct 2011
Location: germany
Posts: 120
Gender: Unknown/Other
Credits: 12,436
draugluin is on a distinguished road
Default

@ Kyttias

ah great. It works now. Thank you very much for your help
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a Limit adopted eggs for 1.3.2? Infernette Questions and Supports 6 02-08-2013 01:20 PM
Limit Adopted Eggs fadillzzz Mys v1.1.x Mods 17 04-03-2011 06:37 PM
Last adopted? Xius Questions and Supports 2 05-17-2009 03:14 PM
Adopted by certain user levels... densaugeo Questions and Supports 11 04-21-2009 03:33 PM
change the "You just adopted a ..." code output LilPixie Questions and Supports 2 02-14-2009 06:41 PM


All times are GMT -5. The time now is 06:02 PM.

Currently Active Users: 842 (0 members and 842 guests)
Threads: 4,081, Posts: 32,029, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636