Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Mys v1.3.x Mods (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=42)
-   -   Mys v1.3.4 Adoptable Shops With Conditions (http://www.mysidiaadoptables.com/forum/showthread.php?t=5023)

Abronsyth 02-17-2016 12:44 PM

And what is the exact file name of the main file for it (the one in the home directory)? If that one is Leopardview.php, then the other should be Leopard.php

And, if possible, please show me your Leopard.php file (in php tags) and your Leopardview.php file.

gunpowdercat 02-17-2016 12:52 PM

Putting the names in lowercase worked, Thanks. You might wanna put in the main post that the thing is a picky eater... lol...

Kyttias 02-17-2016 01:02 PM

PHP is a picky language in general (I'd say all programming languages are case-sensitive). :catfish: But I went ahead and added it to my custom page guide as a general note.

Abronsyth 02-17-2016 01:08 PM

Ah, so that was the problem! I copied the general layout of the other files (which are lowercase) for the sake of organization. It didn't even occur to me that changing the case would present problems since I've never done that, haha.

I'm glad you got it working, though!

gunpowdercat 02-17-2016 03:38 PM

Found a bug. if you do not have enough currency to purchase the adopt; it will tell you you can't, but the adopt still goes into their myadopts.php, and subtract no currency.

Kyttias 02-17-2016 09:13 PM

Aaack, I meant to mention this on the original thread but now I can't even find the if statement I wrote up. This can definitely be easily fixed.

Here's the file with changes:
PHP Code:

<?php

use Resource\Native\Integer;
use 
Resource\Native\String;
use 
Resource\Native\Arrays;
use 
Resource\Native\Null;

class 
NAMEController extends AppController{

    public function 
__construct(){
        
parent::__construct("member");
        
$mysidia Registry::get("mysidia");
        if(
$mysidia->usergroup->getpermission("canadopt") != "yes"){
            throw new 
NoPermissionException("permission");
        }    
    }
    
    public function 
index(){ 
        
$mysidia Registry::get("mysidia");         
        if(
$mysidia->input->post("submit")){ 
            
$this->access "member"
            
$this->handleAccess(); 
            
$id $mysidia->input->post("id"); 
            if(
$mysidia->session->fetch("adopt") != or !$id) throw new InvalidIDException("global_id");             
             
            
$adopt = new Adoptable($id); 
            
$conditions $adopt->getConditions(); 
            if(!
$conditions->checkConditions()) throw new NoPermissionException("condition"); 
             
            
$name = (!$mysidia->input->post("name"))?"Unnamed":$mysidia->input->post("name"); 
            
$alts $adopt->getAltStatus(); 
            
$code $adopt->getCode(); 
            
$gender $adopt->getGender(); 


            
$cost $mysidia->db->select("adoptables", array("cost"), "type='{$adopt->getType()}'")->fetchColumn();
            
$moneyleft $mysidia->user->money $cost;

            if(
$moneyleft >= 0){ 
                
$mysidia->user->changecash(-$cost);
                
$mysidia->db->insert("owned_adoptables", array("aid" => NULL"type" => $adopt->getType(), "name" => $name"owner" => $mysidia->user->username"currentlevel" => 0"totalclicks" => 0"code" => $code,  
                                                                   
"imageurl" => NULL"usealternates" => $alts"tradestatus" => 'notfortrade'"isfrozen" => 'no'"gender" => $gender"offsprings" => 0  )); 
                    
                
$aid $mysidia->db->select("owned_adoptables", array("aid"), "code='{$code}' and owner='{$mysidia->user->username}'")->fetchColumn(); 
                
$this->setField("aid", new Integer($aid)); 
                
$this->setField("name", new String($name));             
                
$this->setField("eggImage", new String($adopt->getEggImage()));  

                 return 
TRUE;           
            }
          else throw new 
InvalidActionException("Sorry, you cannot afford this transaction.");
        }  
        
        
$mysidia->session->assign("adopt"1TRUE);
        
$ids $mysidia->db->select("adoptables", array("id"), "shop='NAME'")->fetchAll(PDO::FETCH_COLUMN);
        
$total = ($ids)?count($ids):0;
        
        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);
    }
}
?>

(*Remember to change the two instances of NAME.)

What I modified specifically:
PHP Code:

$cost $mysidia->db->select("adoptables", array("cost"), "type='{$adopt->getType()}'")->fetchColumn();
$moneyleft $mysidia->user->money $cost;

if(
$moneyleft >= 0){ 
    
$mysidia->user->changecash(-$cost);
    
$mysidia->db->insert("owned_adoptables", array("aid" => NULL"type" => $adopt->getType(), "name" => $name"owner" => $mysidia->user->username"currentlevel" => 0"totalclicks" => 0"code" => $code,  
                                                       
"imageurl" => NULL"usealternates" => $alts"tradestatus" => 'notfortrade'"isfrozen" => 'no'"gender" => $gender"offsprings" => 0  )); 
        
    
$aid $mysidia->db->select("owned_adoptables", array("aid"), "code='{$code}' and owner='{$mysidia->user->username}'")->fetchColumn(); 
    
$this->setField("aid", new Integer($aid)); 
    
$this->setField("name", new String($name));             
    
$this->setField("eggImage", new String($adopt->getEggImage()));  

     return 
TRUE;           
}
else throw new 
InvalidActionException("Sorry, you cannot afford this transaction."); 


Abronsyth 02-17-2016 09:30 PM

Oop, good catch! I've gone ahead and updated the attachment (thank you, Kyttias!)!

gunpowdercat 02-18-2016 07:49 AM

Thanks, Kyttias! a few of my users were being quite the pain with this lol...

Abronsyth 02-18-2016 11:38 AM

I am glad you find the mod useful :)

gwynmil 12-02-2017 04:57 PM

This mod works perfectly, thank you! :D

I have a question though. Is it possible for one breed (adopt type) to be available from multiple shops?

Most of my griffins have randomly generated hex colours and, well, you can imagine how hideous it gets haha. So I'd like to have shops selling preset white/black/brown versions of most breeds, to help players get started in their selective breeding goals. Setting up each shop to generate its own colour scheme is no problem, but I'm stuck on how to actually make the breeds available... ^^' Any ideas?

edit: oh, noticed these lines, 54-57

PHP Code:

        $mysidia->session->assign("adopt"1TRUE);
        
$ids $mysidia->db->select("adoptables", array("id"), "shop='pale'")->fetchAll(PDO::FETCH_COLUMN);
        
$total = ($ids)?count($ids):0

If I'm reading it correctly, it scans the table to pick up breeds with that shop assigned. Would it be a wise idea to manually write an array of desired breed IDs here, instead? Or would it mess something up?


All times are GMT -5. The time now is 02:28 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.