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 12-29-2015, 11:31 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 150,072
Abronsyth is on a distinguished road
Default Adopt Conditions Not Working

Resolved

Apparently the moreless condition is not working for adoptables on my website. For several adoptables I have the limit set to 1 or 2, and yet users are able to adopt 10+ with no issue (and looking through old threads I see this has been an issue for a while now).

Note; this is only happening for Promo and shop adoptables, the condition is working just fine for free adoptables not sold in shops. Looking through the files I believe this is because only adopt.php has the code that tells it to check the conditions before making the adoptable available. Shops and promocodes do not have this code, so they don't bother checking, which results in users being able to get as many of pets sold in shops and through promocodes as they like.

Does anyone know how to fix this? It's kind of really messed up the values of pets on my website. I'm going to be playing with it a bit and see if I can get it to work, so if I find it before someone else does then I will post it.

---

Here are the two snippets I found in adopt.php;
PHP Code:
            $adopt = new Adoptable($id);                
            
$conditions $adopt->getConditions();
            if(!
$conditions->checkConditions()) throw new NoPermissionException("condition"); 
and
PHP Code:
        if($total == 0$adopts = new Null;
        else{        
            
$adopts = new Arrays($total);
            
$available 0;
            
            foreach(
$ids as $id){
                
$adopt = new Adoptable($id);
                
$conditions $adopt->getConditions();    
                  if(
$conditions->checkConditions()) $adopts[$available++] = $adopt;    
            }
            
            if(
$available == 0$adopts = new Null;
            else 
$adopts->setSize($available);            
        }        
        if(
$adopts instanceof Null) throw new InvalidActionException("adopt_none");
        
$this->setField("adopts"$adopts);
    } 
So now I just need to figure out what to do with these, and where to put something like them in files that deal with promocode adopts and shop adopts.

----

Now looking at the file .../classes/class_adoptshop.php I think that the conditions snippet should be included in the display function (which I've snipped to show below), so that the code can check conditions, and if the user HAS met the moreless limit, then the adoptable is no longer displayed in the shop at all. I'm still not sure about this (as you all likely know I'm very uneducated with PHP), but I'm hoping that my speculations aren't too off.
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;
        }     
      
        
$adoptList = new TableBuilder("shop");
        
$adoptList->setAlign(new Align("center""middle"));
        
$adoptList->buildHeaders("Image""Breed""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);        
    } 
__________________
My Mods Site (1.3.4, 2020 Mods)

Last edited by Abronsyth; 02-18-2016 at 02:49 PM.
Reply With Quote
  #2  
Old 12-29-2015, 01:32 PM
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: 576,077
Hall of Famer is on a distinguished road
Default

Well I understand what you are saying, but this is in fact an intended behavior, not an issue. The adoptable condition is for adoption, which means it only applies when you 'adopt' a pet. If you obtain it through other means such as promocode, shop or breeding, the limit is bypassed, since you are not actually 'adopting' a pet. There is a reason why I initially did not make the adoptable shop in Mys v1.3.0 and v1.3.1(it only appeared after v1.3.2), since it leads to conflicts and confusion about adoptable conditions.

Of course, there is a way to alter this behavior if you want to, and it wont be difficult to achieve.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #3  
Old 12-29-2015, 05:10 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 150,072
Abronsyth is on a distinguished road
Default

Oh, alright. Do you know how I'd be able to achieve it so that conditions are not bypassed?

Thank you,
Abronsyth

Is there at least a simplistic way to change it so that the availability feature for promocodes is per user, and not how many times in total the promocode can be redeemed (so if I set it to "1" then each user can only redeem it once)?
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #4  
Old 01-07-2016, 05:38 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 150,072
Abronsyth is on a distinguished road
Default

If anyone here is able to do this I'm very willing to pay, it's very necessary that I can have these features (limited number of each adopt available in stores that can be purchased, and making it so the admin can determine the number of times each individual can redeem a specific promocode) for some of my site activities (riddles and seasonal specials) to work.
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #5  
Old 01-07-2016, 08:11 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 125,742
Kyttias is on a distinguished road
Default

The only way I can think of is to have a separate table in the database that will hold information about whether a user has ever activated a code before. It'd have users as rows (obviously), but must have all the promo codes as columns. Every time you make a new limited promocode you'd have to add another column to that table. The checks would be as simple as 'has the user activated this code more than 0 times?' - and any limit could work, if you wanted to limit some things to other amounts.

The users would be automatically be added to the table only after the first time they adopt a limited pet, so you needn't add any manually. Here's vaguely where my thoughts lead me.

Create a table in the database (can run this SQL) -
Code:
CREATE TABLE IF NOT EXISTS `adopts_limitedpromos` (
  `pcid` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(30) NOT NULL,
  `examplecode1` int(11) NOT NULL DEFAULT '0',
  `examplecode2` int(11) NOT NULL DEFAULT '0',
  `examplecode3` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`pcid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
And you can use it like this -
PHP Code:
    
/* You'll want this code to run whenever a limited promocode is trying to be claimed: */
    // You will need to get these variables yourself, perhaps with a function?
    
$promocode;
    
$username;
    
    
// Example here using MySQLi instead of what's native to Mysidia.
    
include("../../inc/config.php");  
    
$db = new mysqli(DBHOSTDBUSERDBPASSDBNAME);

    
// Check the number of times a user has used a promocode.
    
$sql mysqli_query("SELECT {$promocode} FROM `adopts_limitedpromos` WHERE `username` = '{$username}'"); 
    
$result mysqli_fetch_object($sql);

    
// If the number of times the user has used this code is less than 1, procede!
    
if ($result->$promocode 1){    
        
// Updates the database for this user to increase the number of times this promocode has been claimed by one.
        
mysqli_query($db,"UPDATE `adopts_limitedpromos` SET `{$promocode}` = {$promocode} + 1 WHERE `username` = '{$username}'");
        
        if (
mysqli_affected_rows($db) < 1){
        
// If the update function did not fire, the user doesn't have a row in the table yet. This'll create one.
            
mysqli_query($db,"INSERT INTO `adopts_limitedpromos` SET `username` = '{$username}', `{$promocode}` = '1'");
        }
        
        
mysqli_close($db);
    } 
Not sure how well you follow me. This is the best way I can think of? Actually implementing it in parts of the site might require more help.
__________________
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
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 08:58 AM.

Currently Active Users: 4378 (0 members and 4378 guests)
Threads: 4,081, Posts: 32,032, 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 - 2025, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636