View Single Post
  #2  
Old 01-10-2016, 02:20 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 132,734
Kyttias is on a distinguished road
Default

You want a species of pet that you can never ever get again, even if you trade it away. I think what you should do is add a flag to the character's account when that particular species is adopted and then check for that flag on the page that offers the pet.

Let's just say the species name is "Kitsu".

In adopt.php, after the adoptable is inserted into the database (shouldn't be hard to find), let's go ahead and check what type it is.

PHP Code:
if ($adopt->getType() == "Kitsu"){
    
$mysidia->db->update("users", array("Kitsu" => "1"), "username='{$mysidia->user->username}'");

This'll update a column called "Kitsu" in the adopts_users table from 0 to 1 for this user. (Of course you should go create such a thing in your database. Let me know if you need help!)

Now, in adoptsview.php, you'll want to find where the table of available adopts is being built. It should look something like this:
PHP Code:
$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);

First we'll run a check to see if a user has ever adopted a "Kitsu". Then, once inside the for loop we're going to force it to skip over any adopt whose type matches the one we're looking for, IF the user already has one of that type. Here's the above with the changes:

PHP Code:
$check $mysidia->db->select("users", array("Kitsu"), "username='{$mysidia->user->username}'")->fetchColumn();
$adopts $this->getField("adopts");
for(
$i 0$i $adopts->length(); $i++){
    if ((
$check 0) && ($adopts[$i]->getType() != "Kitsu")){
        
$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);
    }

Disclaimer: I haven't tested this in slightest. You'll need to make changes if this is going to apply to more than one kind of pet (that's a lot of checking to do) or a pet sold in the shops instead of freely available (that's a whole other monster).
__________________
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; 01-10-2016 at 02:23 PM.
Reply With Quote