Hey so I am currently making a vault addon skript that makes vault a little more interesting, it's going to have a bank where you can gain interest and many other features but here is where my issue arises
So I need the bank to automatically every 12 hours add %5 to the player's balance but there are some more details. If the player deposits any money into the bank it will reset this timer so they will have to wait 12 hours before getting the 5% interest.
Current Code:
If you could please help that would be great <3.
So I need the bank to automatically every 12 hours add %5 to the player's balance but there are some more details. If the player deposits any money into the bank it will reset this timer so they will have to wait 12 hours before getting the 5% interest.
Current Code:
Code:
# ################################################
#Functions/Effects
#Format money with commas function by AsuDev
function formatNumbers(i: text) :: string:
return regex replace "(?<=\d)(?=(\d\d\d)+(?!\d))" with "," in {_i}
# ################################################
#Meat and potatoes
on join:
if {bank.balance::%uuid of player%} is not set:
set {bank.balance::%uuid of player%} to 0
command /bank [<text>] [<offline player>]:
trigger:
if player has permission "bank.use":
if arg 1 is not set:
open virtual chest inventory with 4 rows with title "&d&lBanker" to player
set {_money} to formatNumbers("%{bank.balance::%uuid of player%}%")
format gui slot (all integers between 0 and 36) of player with black glass pane named "&7"
format gui slot 11 of player with chest named "&d&lDeposit Money" with lore "&7Current Balance: &d%{_money}%||&7||&7Store money in the back to||&7keep it safe while you go out||&7on adventures!||&7||&7You will earn &d%%5 &7interest every &d12h&7.||&7||&7Until Interest: &d(until interest)||&7||&dClick to make a deposit" to run:
execute player command "bank deposit"
else if arg 1 is "deposit":
if arg 2 is not set:
open virtual chest inventory with 3 rows with title "&d&lBanker &8// &dDeposit" to player
set {_money} to formatNumbers("%{bank.balance::%uuid of player%}%")
set {_moneyHalf} to player's balance / 2
set {_money2} to formatNumbers("%{_moneyHalf}%")
format gui slot (all integers between 0 and 27) of player with black glass pane named "&7"
format gui slot 11 of player with 64 chest named "&dDeposit Entire Balance" with lore "&8Bank Deposit||&7||&7Current Balance: &d%{_money}%||&7Amount to deposit: &d%player's balance%||&7||&7Note:||&7When you deposit any amount of money||&7Your until interest will go back to &d12h||&7||&dClick to deposit money!" to run:
set {_a} to player's balance
subtract {_a} from player's balance
add {_a} to {bank.balance::%uuid of player%}
set {_money} to formatNumbers("%{_a}%")
send "&c&l[!] &cAll of your money has been deposited into the bank."
send "&c&l-$&c%{_money}%"
wait 5 ticks
execute player command "bank deposit"
format gui slot 13 of player with 32 chest named "&dDeposit Half Balance" with lore "&8Bank Deposit||&7||&7Current Balance: &d%{_money}%||&7Amount to deposit: &d$%{_money2}%||&7||&7Note:||&7When you deposit any amount of money||&7Your until interest will go back to &d12h||&7||&dClick to deposit money!" to run:
subtract {_moneyHalf} from player's balance
add {_moneyHalf} to {bank.balance::%uuid of player%}
send "&c&l[!] &cHalf of your money has been deposited into the bank."
send "&c&l-$&c%{_money2}%"
wait 5 ticks
execute player command "bank deposit"
else if arg 1 is "balance" or "bal":
else if arg 1 is "withdraw":
else if arg 1 is "reset":
if arg 2 is set:
if arg 2 has played before:
delete {bank.balance::%uuid of arg 2%}
kick arg 2 due to "&cBank stats have been reset%nl%&7Please Relog"
send "&c&l[!] &c%arg 2%'s stats have been reset."
else:
send "&c&l[!] &cPlayer Not Found."
else:
send "&c&l[!] &cCorrect Usage: /bank reset <player>"