Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.3.x Mods

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-10-2016, 01:02 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 65,284
Dinocanid is on a distinguished road
Default Bank Mod

-Before we start--
If you have a fresh install of the mysidia script or you have unmodified files, you may download the attachments at the bottom. (You still must follow step 0) If you would rather install it manually, follow the instructions below.

-Step 0-
Go to phpMyAdmin, adopts_users, and create a new column with this info:
Code:
Name: bank
Type: int
Length/Values: 11
Default: As defined 0
check the null box
-Step 1-
Create a new page for your bank from scratch. If you don't know how to make pages from scratch go here. Do not create a new page from the admincp.
Create a file named bank.php in your root folder and add the following contents:
PHP Code:
<?php

class BankController extends AppController{

    public function 
__construct(){
        
parent::__construct("member");    
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
    }
}
?>
Next, make a new file called bankview.php in your view folder with the following contents:
PHP Code:
 <?php
class BankView extends View{

    public function 
index(){
      
        
$mysidia Registry::get("mysidia");
        
$document $this->document;        
        
$document->setTitle("The Bank");  
        
$balance $mysidia->user->getbank();
        
$cash $mysidia->user->getcash();
        
        if (
$balance <= 0){
        
$document->add(new Comment("<h2>Current Balance: $0</h2>"));
        }
        else 
$document->add(new Comment("<h2>Current Balance: $ {$balance}</h2>"FALSE));
        
$document->add(new paragraph);

if(
$mysidia->input->post("deposit")){
$amount $mysidia->input->post("amount");
$balance $mysidia->db->select("users", array("bank"))->fetchColumn();
if(
$amount $cash){$document->add(new Comment("You don't have that much to deposit!")); return TRUE;}
$mysidia->user->changecash(-$amount);
$mysidia->user->changebank(+$amount);
$document->add(new Comment("<h2>You deposited $ {$amount} into your bank account</h2>"FALSE));
$document->add(new Comment("<br><a href='{$path}bank'>Return to Bank</a>  "FALSE));
return 
TRUE;}

$depositForm = new FormBuilder("depositForm""""post");
$depositForm->buildComment("Amount: "FALSE)
  ->
buildTextField("amount"FALSE)
  ->
buildButton("Deposit""deposit""submit");
        
$document->add($depositForm);
        
        
        
        
     if(
$mysidia->input->post("withdraw")){
$amount $mysidia->input->post("amount");
$balance $mysidia->db->select("users", array("bank"))->fetchColumn();
if(
$amount $balance){$document->add(new Comment("You don't have that much to withdraw!")); return TRUE;}
else{
$mysidia->user->changecash(+$amount);
$mysidia->user->changebank(-$amount);}
$document->add(new Comment("<h2>You withdrew $ {$amount} from your bank account</h2>"FALSE));
$document->add(new Comment("<br><a href='{$path}bank'>Return to Bank</a>  "FALSE));
return 
TRUE;}  

 
$withdrawForm = new FormBuilder("withdrawForm""""post");
$withdrawForm->buildComment("Amount: "FALSE)
  ->
buildTextField("amount"FALSE)
  ->
buildButton("Withdraw""withdraw""submit");
        
$document->add($withdrawForm);
    }
}
?>
-Step 2-
Now go to class_member.php and add this with the other public items:
PHP Code:
public $bank
Afterwards, add this with the rest of the functions:
PHP Code:
  public function changebank($amount){     
      
$mysidia Registry::get("mysidia");
      if(!
is_numeric($amount)) throw new Exception('Cannot change user money by a non-numeric value!');
      
      
$this->bank += $amount;    
      if(
$this->bank >= 0){ 
         
$mysidia->db->update("users", array("bank" => $this->bank), "username = '{$this->username}'");
         return 
TRUE;              
      }
      
///else throw new InvalidActionException("It seems that {$this->username} cannot afford this transaction.");
  

(The else function is commented out for now so the user avoids any errors. I'll clean it up when I find a way)

Next, go to class_user.php and add this with the other public things:
PHP Code:
public $bank
And this with the other functions:
PHP Code:
      public function getbank(){
     return 
$this->bank;

-End-
That should be it. Now users are able to add and withdraw from a bank account that holds their currency.

-Attachment-
The bank.php file goes in your root/public_html folder while bankview.php goes in your view folder. Please do not use the attachments if you have heavily modified files as it can cause errors! Follow the manual tutorial instead.
Attached Files
File Type: zip 1.3.4 Mysidia Bank Mod.zip (4.9 KB, 9 views)
__________________

Last edited by Dinocanid; 12-10-2016 at 09:53 PM.
Reply With Quote
 


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:53 AM.

Currently Active Users: 9680 (0 members and 9680 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