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 01-10-2016, 10:47 AM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 49,703
tahbikat is on a distinguished road
Default Having an adoptable available only once?

Basically I want users to be able to adopt a certain critter when they join the site only once and never again. I actually do know this is enabled already with the adoptable conditions section "You want user to have no more than THIS many types of this adopt".

However, if they trade it away, say, to a friend or something, they can adopt another and then just get their old one back, which is what I don't want to happen. :c I'm sure some users will eventually figure this out and the value of this adopt will go down (not to mention it will be highly frowned upon by me).

Anyone have solutions? I could live with I guess if I have to.

I guess in the meantime I'll make them a non tradeable species even though I wanted them to be able to get traded. :L
Reply With Quote
  #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: 88,520
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
  #3  
Old 01-10-2016, 02:41 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 49,703
tahbikat is on a distinguished road
Default

Funny, I actually thought about calling them Kitsu at first. cx

Thank you so much! I'll get this added soon and let you know how it works. And yea, I think I would only need it for the one species, however, I plan on implementing a quest system using the Explore mod with modifications. This bit of code will probably be useful for that too. No doubt I'll probably post here needing help with it though. x.x
Reply With Quote
  #4  
Old 01-11-2016, 01:49 AM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 49,703
tahbikat is on a distinguished road
Default

Hmm, I added the code but when I went to the adopt page, there's just a black line there and no eggs. :I
Reply With Quote
  #5  
Old 01-11-2016, 04:12 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,520
Kyttias is on a distinguished road
Default

Hmmnngh... all the eggs are leaving and not just the one of a specific type? I'll need HoF to actually look at it and think it through. >< I'm probably close.
__________________
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
  #6  
Old 01-11-2016, 05:33 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 49,703
tahbikat is on a distinguished road
Default

Aww it's okay, thank you anyway Kyttias! <3 I don't mind having them non-tradeable for now!
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


All times are GMT -5. The time now is 04:11 PM.

Currently Active Users: 9409 (0 members and 9409 guests)
Threads: 4,080, Posts: 32,024, 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