The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Script Bank Script

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.

Reply
 
Thread Tools
  #1    
Old April 9th, 2013 (1:07 AM). Edited April 21st, 2013 by Black Eternity.
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
     
    Join Date: Sep 2012
    Age: 24
    Gender: Male
    Posts: 59
    Okay here I am going to show you how to make a banking system for players to store more money than they can carry.

    First create a new script section, let's call this PokemonBank for organizing purposes.
    Add this script:
    Code:
    #This script is for storing the players money in a bank.
    
    def pbDepositBank
      params=ChooseNumberParams.new
      params.setMaxDigits(9)
      params.setRange(MINDEPOSIT,$Trainer.money) #sets min/max deposit from MINDEPOSIT to what the player has on hand
      params.setInitialValue($Trainer.money) #sets the value to what the player has on hand
      params.setCancelValue(0)
      if $Trainer.money<MINDEPOSIT #checks if the player has less money than MINDEPOSIT
        Kernel.pbMessage(
          _INTL("\\G\\XVSorry you must have at least ${1} to deposit.",MINDEPOSIT)) #not enough to deposit
      elsif pbGet(14)==MAXBANK#checks if the bank amount is full
        Kernel.pbMessage(
          _INTL("\\G\\XVYour Bank Account is full, you can not deposit any more money.")) #\\XV shows the bankwindow when picking amount
      elsif $Trainer.money>=MINDEPOSIT#checks if player has more money than MINDEPOSIT
        qty=Kernel.pbMessageChooseNumber(
          _INTL("\\G\\XVHow much would you like to deposit?"),params) #choose deposit amount
        maxqty=MAXBANK-pbGet(14)
          if qty>maxqty
            newqty=MAXBANK-pbGet(14)
            Kernel.pbMessage(
              _INTL("\\G\\XVYou are only allowed to deposit ${1}.",newqty))
            pbAdd(14,newqty)
            $Trainer.money=$Trainer.money-newqty
          else
            pbAdd(14,qty) #adds money to bank
            $Trainer.money=$Trainer.money-qty #subtracts money from player
          end
      end
    end
    
    def pbWithdrawBank
      params=ChooseNumberParams.new
      params.setMaxDigits(9)
      params.setRange(1,pbGet(14)) #sets range from 1 to how much the player has in the bank
      params.setInitialValue(pbGet(14)) #sets value to how much the player has in the bank
      params.setCancelValue(0)
      maxqty=MAXMONEY-$Trainer.money
      if pbGet(14)==0 #checks if you have no money in the bank
          Kernel.pbMessage(
            _INTL("\\G\\XVYou do not have any money to withdraw.")) #no money in bank
      elsif pbGet(14)>0#checks if you have money in the bank
        qty=Kernel.pbMessageChooseNumber(
          _INTL("\\G\\XVHow much would you like to withdraw?"),params) #\\XV shows the bankwindow when picking amount
          if qty>maxqty
            newqty=MAXMONEY-$Trainer.money
            Kernel.pbMessage(
              _INTL("\\G\\XVWe were only allowed to give you ${1}",newqty))
            pbSub(14,newqty)
            $Trainer.money=$Trainer.money+newqty
          else
            pbSub(14,qty) #subtracts money from bank
            $Trainer.money=$Trainer.money+qty #adds money to player
          end
      end
    end
    Next go to Settings
    And define these somewhere:
    Code:
    MAXBANK      = 999999999
    MINDEPOSIT   = 500
    Next go to PokemonMessages
    Around line 1267 is pbDisplayCoinsWindow, after this function, place this code:
    Code:
    def pbDisplayBankWindow(msgwindow,goldwindow)
      bankString=$game_variables[016]
      bankwindow=Window_AdvancedTextPokemon.new(_INTL("Bank:\n<ar>${1}</ar>",bankString))
      bankwindow.setSkin("Graphics/Windowskins/goldskin")
      bankwindow.resizeToFit(bankwindow.text,Graphics.width)
      bankwindow.width=160 if bankwindow.width<=160
      if msgwindow.y==0
        bankwindow.y=(goldwindow) ? goldwindow.y-bankwindow.height : Graphics.height-bankwindow.height
      else
        bankwindow.y=(goldwindow) ? goldwindow.height : 0
      end
      bankwindow.viewport=msgwindow.viewport
      bankwindow.z=msgwindow.z
      return bankwindow
    end
    Now go to line #1329 (coinswindow=nil)
    after it add bankwindow=nil

    Go to line #1498 (should look like)
    Code:
    elsif control=="cn" # Display coins window
              coinwindow.dispose if coinwindow
              coinwindow=pbDisplayCoinsWindow(msgwindow,goldwindow)
    Add this code after it:
    The "xv" is the message code that will be used to open the window, you can change it to whatever you want but must be unique!
    Code:
    elsif control=="xv" #Display bank window
              bankwindow.dispose if bankwindow
              bankwindow=pbDisplayBankWindow(msgwindow,goldwindow)
    Go to line #1384
    Find \\([Gg]|[Cc][Nn]|[Ww][Dd]|[Ww][Mm]|
    and change to \\([Gg]|[Cc][Nn]|[Xx][Vv]|[Ww][Dd]|[Ww][Mm]|
    or whatever letter combination you have chosen, you can use one letter by simply typing [Xx]| but dont forget to change the above code to match it.

    Go to line #1584 and after it add bankwindow.dispose if bankwindow

    Also the last part for PokemonMessages add these two functions after pbSet
    Code:
    # Adds to the value of a variable.
    def pbAdd(id,value)
      if id && id>=0
        $game_variables[id]=$game_variables[id]+value if $game_variables
        $game_map.need_refresh = true if $game_map
      end
    end
    
    # Subtracts from the value of a variable.
    def pbSub(id,value)
      if id && id>=0
        $game_variables[id]=$game_variables[id]-value if $game_variables
        $game_map.need_refresh = true if $game_map
      end
    end
    That should be it.
    To use these functions in an event simply call pbDepositBank and pbWithdrawBank
    View the attached screenshot to see how my event is setup.

    Some things to change for debug purposes (If you allow MAXBANK to be 999999999)
    Change to this code in PokemonDebug:
    Code:
    def pbDebugSetVariable(id,diff)
      pbPlayCursorSE()
      $game_variables[id]=0 if $game_variables[id]==nil
      if $game_variables[id].is_a?(Numeric)
        $game_variables[id]=[$game_variables[id]+diff,999999999].min
        $game_variables[id]=[$game_variables[id],-999999999].max
      end
    end
    
    def pbDebugVariableScreen(id)
      value=0
      if $game_variables[id].is_a?(Numeric)
        value=$game_variables[id]
      end
      params=ChooseNumberParams.new
      params.setDefaultValue(value)
      params.setMaxDigits(9)
      params.setNegativesAllowed(true)
      value=Kernel.pbMessageChooseNumber(_INTL("Set variable {1}.",id),params)
      $game_variables[id]=[value,999999999].min
      $game_variables[id]=[$game_variables[id],-999999999].max
    end
    Also thanks to Maruno for some help completing the script.
    Attached Thumbnails
    BankEvent.jpg‎  
    Reply With Quote

    Relevant Advertising!

      #2    
    Old April 9th, 2013 (1:30 AM).
    Elaitenstile's Avatar
    Elaitenstile Elaitenstile is offline
    I am legend
       
      Join Date: Feb 2013
      Posts: 1,909
      Very neat tutorial, and easy to follow (even for new learners like me).

      Along with the attachment, I've understood how to implement this (though I haven't tested it yet).

      I think this will really help me out in implementing more uses of money, since the regular Pokémon games don't have that great uses of money.

      Thanks for the script!
      __________________
      ~
      Reply With Quote
        #3    
      Old April 11th, 2013 (4:14 PM).
      Black Eternity's Avatar
      Black Eternity Black Eternity is offline
      Lord of Eternity
         
        Join Date: Sep 2012
        Age: 24
        Gender: Male
        Posts: 59
        Quote:
        Originally Posted by ★Hoenn★ View Post
        Very neat tutorial, and easy to follow (even for new learners like me).

        Along with the attachment, I've understood how to implement this (though I haven't tested it yet).

        I think this will really help me out in implementing more uses of money, since the regular Pokémon games don't have that great uses of money.

        Thanks for the script!
        Thank you for the feedback.... if you have any issues please let me know and I will try to resolve them as best as I can.
        Reply With Quote
          #4    
        Old April 11th, 2013 (4:21 PM).
        Rango's Avatar
        Rango Rango is offline
        Show Me The Money Wide Load!
           
          Join Date: Apr 2013
          Location: Australia
          Age: 22
          Gender: Male
          Nature: Naive
          Posts: 44
          Yes! This is just what I've been looking for!
          Thank you for this awesome script, it was so easy to implement.
          __________________
          Reply With Quote
            #5    
          Old April 14th, 2013 (12:22 PM). Edited April 22nd, 2013 by Black Eternity.
          Black Eternity's Avatar
          Black Eternity Black Eternity is offline
          Lord of Eternity
             
            Join Date: Sep 2012
            Age: 24
            Gender: Male
            Posts: 59
            I have updated the PokemonBank with a version that has more checks.

            Features added:
            Checks if the player deposits more than MAXBANK, if they do, subtracts the difference.
            Checks if the player withdraws more than MAXMONEY, if they do, subtracts the difference.

            For example: (in my case both MAXMONEY and MAXBANK are 999999999)
            Player has $999997999 in the bank, and $3000 on hand. if they try to deposit all $3000, only $2000 will be allowed, and leaves $1000 on hand.
            Same for withdrawing.

            EDIT 4/22/13: Updated the script a little, changed a couple things around, and used new method for variables. (pbAdd and pbSub functions)
            Attached Thumbnails
            BankScreenies.jpg‎  
            Reply With Quote
              #6    
            Old February 13th, 2017 (10:57 AM).
            Andrea87Sky Andrea87Sky is offline
               
              Join Date: Jan 2017
              Gender: Male
              Posts: 1
              I made a little space for the whole system of money, not to be confused, I suggest you also put it at the top to keep it too low and then a break to take the script.

              =D ;)

              Here for you:

              Spoiler:
              #===============================================================================
              # * The amount of Money the player starts the game with.
              # * The maximum amount of Money the player can have.
              # * The maximum number of Coins the player can have.
              # * The maximum amount of Battle Points the player can have.
              # * The maximum amount of Money the player can deposit.
              # * The minimum amount of Money the player can deposit.
              #===============================================================================
              INITIALMONEY = 3000
              MAXMONEY = 999999
              MAXCOINS = 999999
              MAXBPOINTS = 999999
              MAXBANK = 999999999
              MINDEPOSIT = 1
              Reply With Quote
                #7    
              Old February 13th, 2017 (12:03 PM).
              M3rein's Avatar
              M3rein M3rein is offline
              Bored
                 
                Join Date: Nov 2016
                Location: The Netherlands
                Gender: Male
                Nature: Bashful
                Posts: 265
                Quote:
                Originally Posted by Andrea87Sky View Post
                I made a little space for the whole system of money, not to be confused, I suggest you also put it at the top to keep it too low and then a break to take the script.

                =D

                Here for you:

                Spoiler:
                #===============================================================================
                # * The amount of Money the player starts the game with.
                # * The maximum amount of Money the player can have.
                # * The maximum number of Coins the player can have.
                # * The maximum amount of Battle Points the player can have.
                # * The maximum amount of Money the player can deposit.
                # * The minimum amount of Money the player can deposit.
                #===============================================================================
                INITIALMONEY = 3000
                MAXMONEY = 999999
                MAXCOINS = 999999
                MAXBPOINTS = 999999
                MAXBANK = 999999999
                MINDEPOSIT = 1
                With all respect, but isn't this thread four years old?

                I won't say anything about the content for multiple reasons
                __________________
                C# and RGSS are main bae, but you're okay as well.
                Reply With Quote
                Reply
                Quick Reply

                Sponsored Links
                Thread Tools

                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 -8. The time now is 10:59 PM.