View Single Post
  #1  
Old 01-19-2016, 10:01 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 157,532
Abronsyth is on a distinguished road
Default Subtract currency upon adopting

Resolved

Now a mod-- Click!

OK, so I'm trying to essentially copy the files adoptview.php, adopt.php, and lang_adopt.php in order to create more adoption centers such as these because I'm able to individually customize the stores a lot more then.

However I've run into a road block. I don't know how to make it, when using these files, so that when a user "adopts" a cat that has a cost set to it, it subtracts the cost from the user's amount of currency. I can see where it happens in the shop files, but I'm not sure how to convert that over to the adopt files.

I think this is the function I need, but I don't know how to include/implement it in the shopname.php or shopnameview.php files (which are just versions of the adopt.php and adoptview.php files);
PHP Code:
    public function purchase($adopt){
        
$mysidia Registry::get("mysidia");
        if(
$adopt->owner != $mysidia->user->username) Throw new NoPermissionException('Something is very very wrong, please contact an admin asap.');
        else{
            
$cost $adopt->getcost($this->salestax);
            
$moneyleft $mysidia->user->money $cost;
            if(
$moneyleft >= 0){    
                
$purchase $adopt->append($adopt->owner);
                
$mysidia->db->update("users", array("money" => $moneyleft), "username = '{$adopt->owner}'");
                
$status TRUE;
            }            
            else throw new 
InvalidActionException($mysidia->lang->money);
        }
        return 
$status;
    } 
Would anyone be able/willing to help with this?
__________________
My Mods Site (1.3.4, 2020 Mods)

Last edited by Abronsyth; 02-18-2016 at 02:48 PM.
Reply With Quote