Black Eternity
Lord of Eternity
- 57
- Posts
- 12
- Years
- 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:
Next go to Settings
And define these somewhere:
Next go to PokemonMessages
Around line 1267 is pbDisplayCoinsWindow, after this function, place this code:
Now go to line #1329 (coinswindow=nil)
after it add bankwindow=nil
Go to line #1498 (should look like)
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!
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
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:
Also thanks to Maruno for some help completing the script.
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)
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
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: