PDA

View Full Version : [Essentials script] Simple bank system


zingzags
July 18th, 2012, 07:38 PM
In your settings add this
BALANCE=X where "X" is the game variable which holds the data which is used for the bank.
Just call pbDeposit, or pbWithdraw in an event.
Enjoy


class Bank

def pbDeposit
params=ChooseNumberParams.new
params.setRange(1,$Trainer.money)
params.setInitialValue($Trainer.money)
params.setCancelValue(0)
qty=Kernel.pbMessageChooseNumber(_INTL("Teller: How much would you like to deposit?"),params)
newmoney=$Trainer.money-qty
store=$Trainer.money-newmoney
$game_variables[BALANCE]=$game_variables[BALANCE]+store
$Trainer.money=newmoney
end

def pbWithdraw
params=ChooseNumberParams.new
params.setRange(1,$game_variables[BALANCE])
params.setInitialValue($game_variables[BALANCE])
params.setCancelValue(0)
qty=Kernel.pbMessageChooseNumber(_INTL("Teller: How much would you like to withdraw?"),params)
newmoney=$Trainer.money+qty
remove=$game_variables[BALANCE]-qty
$game_variables[BALANCE]=remove
$Trainer.money=newmoney
end

end

class BankScreen
def initialize(scene)
@scene = scene
end
def pbStartScreen
@scene.pbDeposit
end
def pbStartScreen2
@scene.pbWithdraw
end
end

Please use credits

shadowriver
July 18th, 2012, 08:03 PM
Thank you very much for this,this will be very handy indeed.

p.claydon
July 19th, 2012, 01:59 AM
lol looks like a similar script i made for money storage with the players mother


def withdrawmommoney
params=ChooseNumberParams.new
params.setRange(0,$game_variables[30])
params.setInitialValue(1)
params.setCancelValue(0)
qty=Kernel.pbMessageChooseNumber(
_INTL("How much to withdraw."),params
)
if qty>0
$Trainer.money+=qty
$game_variables[30]-=qty
Kernel.pbMessage(_INTL("${1} was added.",qty))
else
Kernel.pbMessage(_INTL("no money was added."))
end
end

def depositmommoney
params=ChooseNumberParams.new
$game_variables[31]=$Trainer.money
params.setRange(0,$game_variables[31])
params.setInitialValue(1)
params.setCancelValue(0)
qty=Kernel.pbMessageChooseNumber(
_INTL("How much to deposit."),params
)
if qty>0
$Trainer.money-=qty
$game_variables[30]+=qty
Kernel.pbMessage(_INTL("${1} was stored.",qty))
else
Kernel.pbMessage(_INTL("no money was stored."))
end
end

def mommoney
Kernel.pbMessage(_INTL("You have ${1}",$game_variables[30]))
withdrawmommoney
depositmommoney
end

zingzags
July 19th, 2012, 07:09 AM
lol looks like a similar script i made for money storage with the players mother

Its the same math really.