1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Timer

Discussion in 'Skript' started by Zabrid, Feb 4, 2020.

Thread Status:
Not open for further replies.
  1. Zabrid

    Supporter

    Joined:
    Mar 2, 2019
    Messages:
    53
    Likes Received:
    1
    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:
    Code (Text):
    1.  
    2. # ################################################
    3. #Functions/Effects
    4.  
    5. #Format money with commas function by AsuDev
    6. function formatNumbers(i: text) :: string:
    7.     return regex replace "(?<=\d)(?=(\d\d\d)+(?!\d))" with "," in {_i}
    8.    
    9. # ################################################
    10. #Meat and potatoes
    11. on join:
    12.     if {bank.balance::%uuid of player%} is not set:
    13.         set {bank.balance::%uuid of player%} to 0
    14.  
    15. command /bank [<text>] [<offline player>]:
    16.     trigger:
    17.         if player has permission "bank.use":
    18.             if arg 1 is not set:
    19.                 open virtual chest inventory with 4 rows with title "&d&lBanker" to player
    20.                 set {_money} to formatNumbers("%{bank.balance::%uuid of player%}%")
    21.                 format gui slot (all integers between 0 and 36) of player with black glass pane named "&7"
    22.                 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:
    23.                     execute player command "bank deposit"
    24.             else if arg 1 is "deposit":
    25.                 if arg 2 is not set:
    26.                     open virtual chest inventory with 3 rows with title "&d&lBanker &8// &dDeposit" to player
    27.                     set {_money} to formatNumbers("%{bank.balance::%uuid of player%}%")
    28.                     set {_moneyHalf} to player's balance / 2
    29.                     set {_money2} to formatNumbers("%{_moneyHalf}%")
    30.                     format gui slot (all integers between 0 and 27) of player with black glass pane named "&7"
    31.                     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:
    32.                         set {_a} to player's balance
    33.                         subtract {_a} from player's balance
    34.                         add {_a} to {bank.balance::%uuid of player%}
    35.                         set {_money} to formatNumbers("%{_a}%")
    36.                         send "&c&l[!] &cAll of your money has been deposited into the bank."
    37.                         send "&c&l-$&c%{_money}%"
    38.                         wait 5 ticks
    39.                         execute player command "bank deposit"
    40.                     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:
    41.                         subtract {_moneyHalf} from player's balance
    42.                         add {_moneyHalf} to {bank.balance::%uuid of player%}
    43.                         send "&c&l[!] &cHalf of your money has been deposited into the bank."
    44.                         send "&c&l-$&c%{_money2}%"
    45.                         wait 5 ticks
    46.                         execute player command "bank deposit"
    47.             else if arg 1 is "balance" or "bal":
    48.             else if arg 1 is "withdraw":
    49.             else if arg 1 is "reset":
    50.                 if arg 2 is set:
    51.                     if arg 2 has played before:
    52.                         delete {bank.balance::%uuid of arg 2%}
    53.                         kick arg 2 due to "&cBank stats have been reset%nl%&7Please Relog"
    54.                         send "&c&l[!] &c%arg 2%'s stats have been reset."
    55.                     else:
    56.                         send "&c&l[!] &cPlayer Not Found."
    57.                 else:
    58.                     send "&c&l[!] &cCorrect Usage: /bank reset <player>"
    If you could please help that would be great <3.

     
  2. Best Answer:
    Post #3 by Zabrid, Feb 4, 2020
  3. PlaySkyHd

    PlaySkyHd New Member

    Joined:
    Oct 20, 2017
    Messages:
    5
    Likes Received:
    0
    You can use:

    every 12 hours
     
  4. Zabrid

    Supporter

    Joined:
    Mar 2, 2019
    Messages:
    53
    Likes Received:
    1
    If you use that, every restart it would reset it and you wouldn't be able to do a live countdown


    also that's double bad because everyone is gonna have timers going at different rates like someone who just deposited money is gonna have a different timer then someone who deposited 17 hours ago
     
    #3 Zabrid, Feb 4, 2020
    Last edited: Feb 4, 2020
Thread Status:
Not open for further replies.

Share This Page

Loading...