• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Bank Script

Black Eternity

Lord of Eternity
57
Posts
11
Years
  • Age 31
  • Seen Jun 30, 2016
Okay here I am going to show you how to make a banking system for players to store more money than they can carry. :P

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,[COLOR="red"]999999999[/COLOR]].min
    $game_variables[id]=[$game_variables[id],[COLOR="red"]-999999999[/COLOR]].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,[COLOR="Red"]999999999[/COLOR]].min
  $game_variables[id]=[$game_variables[id],[COLOR="Red"]-999999999[/COLOR]].max
end

Also thanks to Maruno for some help completing the script.
 
Last edited:

Elaitenstile

I am legend
1,908
Posts
11
Years
  • Age 24
  • Seen Feb 27, 2015
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!
 

Black Eternity

Lord of Eternity
57
Posts
11
Years
  • Age 31
  • Seen Jun 30, 2016
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.
 

Rango

Show Me The Money Wide Load!
43
Posts
11
Years
Yes! This is just what I've been looking for!
Thank you for this awesome script, it was so easy to implement.
 

Black Eternity

Lord of Eternity
57
Posts
11
Years
  • Age 31
  • Seen Jun 30, 2016
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)
 
Last edited:
1
Posts
7
Years
  • Age 25
  • Seen Dec 11, 2017
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:
 
971
Posts
7
Years
  • Age 21
  • Seen Nov 28, 2022
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:

With all respect, but isn't this thread four years old?

I won't say anything about the content for multiple reasons :P
 
1
Posts
4
Years
  • Age 41
  • Seen Dec 1, 2020
Any chance that someone has an update on this with the new release? I'm trying to implement... but a few lines I think have changed (i.e. can't seem to find the bracketed letter sequence (ie [Nn]|[Cc]...)
Thanks!
 
Last edited:
6
Posts
4
Years
  • Age 25
  • Seen Nov 28, 2023
I'm no coder but I worked for several hours to update this to a working form for v19.1. It's likely not as simple or as efficient as it could be but it works and that's honestly good enough for me.

For the main script, you can keep it as one, although I personally separated the Deposit and Withdraw functions into two different scripts positioned above Main.
Code:
def pbDepositBank
  params=ChooseNumberParams.new
  params.setMaxDigits(9)
  params.setRange(Settings::MINDEPOSIT,$Trainer.money)
  params.setInitialValue($Trainer.money)
  params.setCancelValue(0)
  if $Trainer.money<Settings::MINDEPOSIT
    pbMessage(
      _INTL("\\GSorry you must have at least ${1} to deposit.",Settings::MINDEPOSIT))
  elsif pbGet(14)==Settings::MAXBANK
    pbMessage(
      _INTL("\\GYour Bank Account is full, you can not deposit any more money."))
  elsif $Trainer.money>=Settings::MINDEPOSIT
    qty=pbMessageChooseNumber(
      _INTL("\\GHow much would you like to deposit?"),params)
    maxqty=Settings::MAXBANK-pbGet(14)
      if qty>maxqty
        newqty=Settings::MAXBANK-pbGet(14)
        pbMessage(
          _INTL("\\GYou are only allowed to deposit ${1}.",newqty))
        $game_variables[14]+=newqty
        $Trainer.money=$Trainer.money-newqty
      else
        $game_variables[14]+=qty
        $Trainer.money=$Trainer.money-qty
      end
  end
end

def pbWithdrawBank
  params=ChooseNumberParams.new
  params.setMaxDigits(9)
  params.setRange(1,pbGet(14))
  params.setInitialValue(pbGet(14))
  params.setCancelValue(0)
  maxqty=Settings::MAX_MONEY-$Trainer.money
  if pbGet(14)==0
      pbMessage(
        _INTL("\\GYou do not have any money to withdraw."))
  elsif pbGet(14)>0
    qty=pbMessageChooseNumber(
      _INTL("\\GHow much would you like to withdraw?"),params)
      if qty>maxqty
        newqty=Settings::MAX_MONEY-$Trainer.money
        pbMessage(
          _INTL("\\GWe were only allowed to give you ${1}",newqty))
        $game_variables[14]-=newqty
        $Trainer.money=$Trainer.money+newqty
      else
        $game_variables[14]-=qty
        $Trainer.money=$Trainer.money+qty
      end
  end
end
This next part is slightly edited from before. It goes in Messages after the defDisplayCoinsWindow part.
Code:
def pbDisplayBankWindow(msgwindow,goldwindow)
  bankString = ($Trainer) ? $Trainer.bank.to_s_formatted : "0"
  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
Still add bankwindow=nil but after battlepointswindow=nil.
After that, search for this area:
Code:
when "pt"     # Display battle points window
        battlepointswindow.dispose if battlepointswindow
        battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
And add right after it:
Code:
when "ba"     # Display bank window
        bankwindow.dispose if bankwindow
        bankwindow = pbDisplayBankWindow(msgwindow,goldwindow)
Note: The 'ba' can honestly be any one or two letters you want. I went with 'ba' because of 'bank'.

The letters in brackets part from the original instructions? Yeah, ignore that completely. Not needed.

Next, look for the line that says battlepointswindow.dispose if battlepointswindow.
Under it, add bankwindow.dispose if bankwindow.

And then you can also skip the last part for Messages from the original instructions - the whole pbAdd and pbSub stuff. pbSet, as far as I can tell, doesn't exist anymore and thus pbAdd and pbSub are obsolete as well.
 
Back
Top