Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Subtract currency upon adopting (http://www.mysidiaadoptables.com/forum/showthread.php?t=4988)

Abronsyth 02-13-2016 04:59 PM

Nope, still refuses to work (though that tip does make sense, thank you!)

PHP Code:

<?php

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

class 
MaoController 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(); 
            
$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"lastbred" => 0"originalowner" => $mysidia->user->username"birthday" => date("F jS, Y")  )); 
            
$cost $mysidia->db->select("adoptables", array("cost"), "type='{$adopt->getType()}'")->fetchColumn();
            
$mysidia->user->changecash(-$cost);               
            
$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;
        }  
        
        
$mysidia->session->assign("adopt"1TRUE);
        
$ids $mysidia->db->select("adoptables", array("id"), "shop='Mao Cats'")->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);
    }
}
?>

Don't know what I'm doing wrong at this point @_@

Kyttias 02-13-2016 05:22 PM

Very odd... I mean... they do get the pet, right, it just doesn't take out money?

Abronsyth 02-16-2016 09:50 AM

Yep, the pet is added to the account just fine, but it doesn't subtract any currency.

Kyttias 02-16-2016 11:41 AM

Okay, get this: If you delete the line that inserts the pet into the database in mao.php, it still gets added. Something tells me it's still using the original adopt.php to do it's work. This is because it's still sending the form data to it!

In view/maoview.php find:
PHP Code:

$adoptForm = new Form("form""adopt""post"); 

And change it to:
PHP Code:

$adoptForm = new Form("form""mao""post"); 

The currency is then going down, but you have to go to another page to see that.
http://orig13.deviantart.net/90be/f/...as-d9rzrmn.gif

(Still using this:)
PHP Code:

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


Abronsyth 02-16-2016 12:44 PM

-throws hands into the air and starts dancing-

Yes! Brilliant! It's working now! Thank you so, so much, Kyttias! You've saved Catisserie's entire economy, haha! I figured it had something to do with the form, but I was looking at the submit action, and not that part.

Thank you so much! Seriously, please let me know if there's ever anything at all I can help you with because you've done so much to help!


All times are GMT -5. The time now is 12:56 PM.

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