This script gives you a fully functional bank for your server. No 3rd party bank plugin required.
Create your NPC, and assign the 'banker' assignment to him/her, and it takes care of itself after hat.
/npc assignment --set banker
Features Include:
- Let's people without a bank account know twice per Minecraft day that the bank exists.
- Gives players a $1000 sign-up bonus for opening an account (configurable)
- Players earn .1% interest per day if logged in, or .01% interest if not logged in (configurable)
- When the player logs on, it tells them how much interest they have earned while logged off
- Autosaves when interest is applied
Required:
- An economy plugin for withdrawals and deposits
- Vault plugin (economy plugin must be supported by Vault)
@author bryanschmidty
@version 1.0.1
@created 6 Feb 2014
@last-updated 7 Feb 2014
# Schmidty Trust Bank# Denizen 0.9.4-SNAPSHOT (build 1442)# Citizens 2.0.11 (build 1071)## This script gives you a fully functional bank for your server. No 3rd party bank plugin required.## Create your NPC, and assign the 'banker' assignment to him/her, and it takes care of itself after that.# /npc assignment --set banker## Features Include:# - Let's people without a bank account know twice per Minecraft day that the bank exists.# - Gives players a $1000 sign-up bonus for opening an account (configurable)# - Players earn .1% interest per day if logged in, or .01% interest if not logged in (configurable)# - When the player logs on, it tells them how much interest they have earned while logged off# - Autosaves when interest is applied## Required:# - An economy plugin for withdrawals and deposits# - Vault plugin (economy plugin must be supported by Vault)## @author bryanschmidty# @version 1.0.1# @created 6 Feb 2014# @last-updated 7 Feb 2014# world script - applies interest once daily and lets people know about the bank
bank_world:
type: world
events:
on 6:00 in world:
- ^run "global_announce"
- ^run "apply_money_interest"
on 18:00 in world:
- ^run "global_announce"
on player join:
- ^run "bank_interest_announce"# Format used for when the NPC talks to a player
banker_format:
type: format
format: <aqua><npc.name><gray><&co> <white><text>
# assignment script
banker:
type: assignment
# You can change these here, or set them in-game with# /npc constant --set signup_bonus --value 2000
default constants:
# amount of money the player is given when they open a bank account
signup_bonus: 1000# amount of interest the player is awarded daily when offline
daily_interest: 0.0001# amount of interest the player is awarded daily when online
daily_interest_online: 0.001
actions:
on assignment:
- trigger name:proximity toggle:true radius:2
- trigger name:click toggle:true
# The banker holds a diamond.... just because
- equip i@diamond
interact scripts:
- 10 bankerscript
bankerscript:
type: interact
steps:
# Welcome to bank
1:
proximity trigger:
entry:
script:
- ^run "welcome_task"
exit:
script:
- narrate format:banker_format "<white>Thank you for coming! Have a nice day!"
- trigger name:chat toggle:false
click trigger:
script:
- if <player.flag[hasBankAccount]> == true {
- ^run "manage_account_task"}
else {
- narrate format:banker_format "<white>It looks like you don<&sq>t have an account. Would you like to open one?"
- narrate "<white>1<gray>) <blue>Yes<gray>, let<&sq>s open an account"
- narrate "<white>2<gray>) <blue>No<gray>, not today"
- trigger name:chat toggle:true
- ^zap step:2"s@bankerscript"}# opening an account
2:
chat trigger:
'open_account':
trigger: '/REGEX:(1|Yes)/'
script:
- narrate format:banker_format "<white>okay. here<&sq>s your <yellow>$<npc.constant[signup_bonus]> <white> for opening an account"
- narrate "<aqua>Your bank account has been opened and now has <yellow>$<npc.constant[signup_bonus]><aqua> in it"
- ^flag player hasBankAccount:true
- ^flag player bankbalance:<npc.constant[signup_bonus]>
- announce "<blue><player.name><aqua> just opened a bank account. Come open yours today if you haven<&sq>t already!"
- trigger name:chat toggle:false
- ^run "manage_account_task"
'deny_account':
trigger: '/REGEX:(2|No)/'
script:
- narrate format:banker_format "okay. not opening sccount"
- trigger name:chat toggle:false
- ^zap step:1
proximity trigger:
exit:
script:
- narrate "<red>Skoinks <gray>looks sad"
- narrate format:banker_format "<white>I<&sq>ll take that as a no."
- trigger name:chat toggle:false
- ^zap step:1# managing your account
3:
chat trigger:
'deposit_money':
trigger: '/REGEX:(1|deposit)/'
script:
- ^run "deposit_money_task"
'withdraw_money':
trigger: '/REGEX:(2|withdraw)/'
script:
- ^run "withdraw_money_task"
'check_balance':
trigger: '/REGEX:(3|balance)/'
script:
- narrate "<white>Your account balance is <yellow>$<yellow><player.flag[bankbalance]>"
- ^zap step:1
'admin_check_ledger':
trigger: '/4/'
script:
- ^run "admin_check_ledger_task"
proximity trigger:
exit:
script:
- narrate format:banker_format "<white>Okay Goodbye!"
- trigger name:chat toggle:false
- ^zap step:1# depositing money
4:
chat trigger:
'deposit_money_amount':
trigger: '/REGEX:^\d+.(\d){1,2}$/'
script:
- narrate format:banker_format "<white>Okay.... one moment"
- wait 3
- narrate "<gray>depositing <yellow>$<player.chat_history><gray>..."
- ^if '<player.money>' >= <player.chat_history>
narrate format:banker_format "<white>There is now <yellow>$<proc:deposit_procedure><white> in your account"
else narrate format:banker_format "<white>You don<&sq>t have <yellow>$<player.chat_history><white> to deposit!"
- trigger name:chat toggle:false
- ^zap step:1
'deposit_money_all':
trigger: '/all/'
script:
- trigger name:chat toggle:false
- narrate "depositing all money"
- flag player 'bankbalance:+:<player.money>'
- ^execute as_op 'eco take <player.name> <player.money>'
- ^zap step:1
proximity trigger:
exit:
script:
- narrate format:banker_format "<white>Okay Goodbye!"
- trigger name:chat toggle:false
- ^zap step:1# withdrawing money
5:
chat trigger:
'withdraw_money_amount':
trigger: '/REGEX:^\d+.(\d){1,2}$/'
script:
- narrate format:banker_format "<white>Okay... one moment"
- wait 3
- ^if '<player.flag[bankbalance]>' >= <player.chat_history>
narrate format:banker_format "<white>There is now <yellow>$<proc:withdraw_procedure><white> in your account"
else narrate format:banker_format "<white>You don<&sq>t have <yellow>$<player.chat_history><white> in your bank to withdraw!"
- trigger name:chat toggle:false
- ^zap step:1
'withdraw_money_all':
trigger: '/all/'
script:
- trigger name:chat toggle:false
- narrate "withdrawing all money"
- ^execute as_op 'eco give <player.name> <player.flag[bankbalance]>'
- flag player 'bankbalance:0'
- ^zap step:1
proximity trigger:
exit:
script:
- narrate format:banker_format "<white>Okay Goodbye!"
- trigger name:chat toggle:false
- ^zap step:1# closing account
6:
chat trigger:
'close_account':
trigger: '/REGEX:(y|yes)/'
script:
- trigger name:chat toggle:false
- narrate "<red>Skoinks <gray>looks sad"
- ^execute as_op 'eco give <player.name> <player.flag[bankbalance]>'
- flag player 'bankbalance:0'
- flag player 'hasBankAccount:false'
- narrate format:banker_format "<white>Your account has been closed."
- ^zap step:1
'dont_close_account':
trigger: '/REGEX:(n|no)/'
script:
- trigger name:chat toggle:false
- narrate format:banker_format "<white>Oh good! You had me worried there for a minute!"
- ^zap step:1
proximity trigger:
exit:
script:
- narrate format:banker_format "<white>Okay Goodbye!"
- trigger name:chat toggle:false
- ^zap step:1# Welcomes the player to the bank. Will invite them to open account if they don't have one
welcome_task:
type: task
speed: 1t
script:
- narrate format:banker_format "<white>Welcome <aqua><player.name> <white>to the bank!"
- if <player.flag[hasBankAccount]> != true narrate format:banker_format "<white>Open a bank account today and get <yellow>$<npc.constant[signup_bonus]><white>!"
- ^zap step:1"s@bankerscript"
manage_account_task:
type: task
speed: 1t
script:
- trigger name:chat toggle:true
- narrate format:banker_format "<white>What would you like to do?"
- narrate "<white>1<gray>) <blue>Deposit <gray> money"
- narrate "<white>2<gray>) <blue>Withdray <gray> money"
- narrate "<white>3<gray>) <gray>Check your <blue>balance"
- ^if <player.in_group[admin]> || <player.in_group[owner]> || <player.is_op> {
- narrate "<gold> --- Admin Menu ---"
- narrate "<white>4<gray>) <white>Check Ledger"}
- ^zap step:3"s@bankerscript"
admin_check_ledger_task:
type: task
speed: 1t
script:
- ^if <player.in_group[admin]> || <player.in_group[owner]> || <player.is_op> {
- narrate "<gold> --- Ledger ---"
- flag global total_balance:0
- foreach <server.list_players> {
- define player %value%
- ^if <%player%.flag[hasBankAccount]> == true {
- narrate "<aqua><%player%.name> <white>has <yellow>$<%player%.flag[bankbalance]>"
- flag global total_balance:+:<%player%.flag[bankbalance]>}}
- narrate "<gold> --- Total Balance<&co> <yellow>$<global.flag[total_balance]>"}
- ^zap step:1"s@bankerscript"
deposit_money_task:
type: task
speed: 1t
script:
- narrate format:banker_format "<white>How much money would you like to deposit?"
- narrate "<gray>You have <yellow>$<player.money><gray>."
- narrate "<gray>Type amount to deposit or type <blue>all<gray> to deposit all"
- ^zap step:4"s@bankerscript"
deposit_procedure:
type: procedure
script:
- define to_deposit '<player.chat_history>'
- flag player 'bankbalance:+:%to_deposit%'
- ^execute as_op 'eco take <player.name> %to_deposit%'
- determine "<flag.p:bankbalance>"
withdraw_money_task:
type: task
speed: 1t
script:
- narrate format:banker_format "<white>How much would you like to withdraw?"
- narrate "<gray>Your account balance is <yellow>$<yellow><player.flag[bankbalance]>"
- narrate "<gray>Type amount to withdray or type <blue>all<gray> to withdraw all"
- ^zap step:5"s@bankerscript"
withdraw_procedure:
type: procedure
script:
- define to_withdraw '<player.chat_history>'
- flag player 'bankbalance:-:%to_withdraw%'
- ^execute as_op 'eco give <player.name> %to_withdraw%'
- determine "<flag.p:bankbalance>"
global_announce:
type: task
script:
- foreach <server.get_npcs_assigned[banker]> {
- define signup_bonus '<%value%.constant[signup_bonus]>'}
- foreach <server.list_online_players> {
- ^if <%value%.flag[hasBankAccount]> != true {
- narrate "<aqua>The bank is now open!" targets:%value%
- narrate "<aqua>Come open your account today and get a bonus <yellow>$%signup_bonus%<aqua>!" targets:%value%}}# applies the interest to each player's account
apply_money_interest:
type: task
script:
- foreach <server.get_npcs_assigned[banker]> {
- define interest '<%value%.constant[daily_interest]>'
- define interest_online '<%value%.constant[daily_interest_online]>'}
- foreach <server.list_players> {
- define player %value%
- ^if <%player%.flag[hasBankAccount]> == true {
- flag %player% player_interest:<%player%.flag[bankbalance]>
- ^if <%player%.is_online> {
- flag %player% player_interest:*:%interest_online%} else {
- flag %player% player_interest:*:%interest%}
- flag %player% player_interest:*:100
- flag %player% player_interest:<%player%.flag[player_interest].asint>
- flag %player% player_interest:/:100
- flag %player% player_overall_interest:+:<%player%.flag[player_interest]>
- flag %player% player_overall_interest:*:100
- flag %player% player_overall_interest:<%player%.flag[player_overall_interest].asint>
- flag %player% player_overall_interest:/:100
- flag %player% player_sincelogin_interest:+:<%player%.flag[player_interest]>
- flag %player% player_sincelogin_interest:*:100
- flag %player% player_sincelogin_interest:<%player%.flag[player_sincelogin_interest].asint>
- flag %player% player_sincelogin_interest:/:100
- flag %player% bankbalance:+:<%player%.flag[player_interest]>
- flag %player% bankbalance:*:100
- flag %player% bankbalance:<%player%.flag[bankbalance].asint>
- flag %player% bankbalance:/:100
- ^if <%player%.is_online> {
- narrate "<aqua>Bank<white><&co> you received <green>$<%player%.flag[player_interest]><white> in interest, and now have <yellow>$<%player%.flag[bankbalance]><white> total." targets:%player%
- flag %player% player_sincelogin_interest:0}}}
- execute as_server 'denizen save'
- execute as_server 'citizens save'
# tells the player the interest they have earned since the last time they logged in
bank_interest_announce:
type: task
speed: 1t
script:
- ^if <player.flag[hasBankAccount]> == true {
- wait 2
- ^if <player.flag[player_sincelogin_interest]> > 0{
- narrate '<aqua>Bank<white><&co> You have earned <yellow>$<player.flag[player_sincelogin_interest]><white> since you last logged on.'
- narrate '<aqua>Bank<white><&co> You have earned <yellow>$<player.flag[player_overall_interest]><white> overall.'
- flag player player_sincelogin_interest:0}}