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 Help with ATM System

Discussion in 'Skript' started by Djavan, Jul 24, 2019.

Tags:
Thread Status:
Not open for further replies.
  1. Djavan

    Djavan Member

    Joined:
    Jul 19, 2019
    Messages:
    16
    Likes Received:
    0
    Hey y'all,
    I made a ATM system and I want it to refresh it every time you add a amount of money.
    Can someone help me with this please?
    I use Skript and SkQuery.

    Information below


    Skript Version: Skript 2.2-dev36
    Minecraft Version: 1.12.2
    ---
    Code (Text):
    1. command /deposit:
    2.     trigger:
    3.         open chest with 3 rows named "&cDeposit" to player
    4.         wait 2 ticks
    5.         format slot 13 of player with 1 paper named "&cAccept" with lore "&8%{num_of_clicks::%player%}% ||" to close then run [make player execute "acceptatm"]
    6.         set slot 9 of current inventory of player to 1 green glass named "&2+100$"
    7.         set slot 10 of current inventory of player to 1 green glass named "&2+10$"
    8.         set slot 11 of current inventory of player to 1 green glass named "&2+1$"
    9.         set slot 15 of current inventory of player to 1 green glass named "&4-1$"
    10.         set slot 16 of current inventory of player to 1 green glass named "&4-10$"
    11.         set slot 17 of current inventory of player to 1 green glass named "&4-100$"
    12.        
    13. on inventory click:
    14.     if inventory name of current inventory of player is "&cDeposit":
    15.         if name of clicked item is "&2+1$":
    16.             add 1 to {num_of_clicks::%player%}
    17.             cancel event
    18.            
    19. on inventory click:
    20.     if inventory name of current inventory of player is "&cDeposit":
    21.         if name of clicked item is "&2+10$":
    22.             add 10 to {num_of_clicks::%player%}
    23.             cancel event
    24.            
    25. on inventory click:
    26.     if inventory name of current inventory of player is "&cDeposit":
    27.         if name of clicked item is "&2+100$":
    28.             add 100 to {num_of_clicks::%player%}
    29.             cancel event
    30.            
    31. on inventory click:
    32.     if inventory name of current inventory of player is "&cDeposit":
    33.         if name of clicked item is "&4-1$":
    34.             if {num_of_clicks::%player%} is greater than or equal to 1:
    35.                 remove 1 from {num_of_clicks::%player%}
    36.                 cancel event
    37.         else if {num_of_clicks::%player%} is smaller than 1:
    38.             set {num_of_clicks::%player%} to 0
    39.             cancel event
    40.            
    41. on inventory click:
    42.     if inventory name of current inventory of player is "&cDeposit":
    43.         if name of clicked item is "&4-10$":
    44.             if {num_of_clicks::%player%} is greater than or equal to 10:
    45.                 remove 10 from {num_of_clicks::%player%}
    46.                 cancel event
    47.         else if {num_of_clicks::%player%} is smaller than 10:
    48.             set {num_of_clicks::%player%} to 0
    49.             cancel event
    50.            
    51. on inventory click:
    52.     if inventory name of current inventory of player is "&cDeposit":
    53.         if name of clicked item is "&4-100$":
    54.             if {num_of_clicks::%player%} is greater than or equal to 100:
    55.                 remove 100 from {num_of_clicks::%player%}
    56.                 cancel event
    57.         else if {num_of_clicks::%player%} is smaller than 100:
    58.             set {num_of_clicks::%player%} to 0
    59.             cancel event
    --- Double Post Merged, Jul 24, 2019, Original Post Date: Jul 24, 2019 ---
    Can someone help?
    Please? :emoji_eyes:
     
  2. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    314
    Likes Received:
    21
    so as i am not going to read that whole amount of code, i'm just going to limit myself to write a pseudo version of what you need to do.

    Code (Text):
    1. set {_old_money::%player%} to current player's balance
    2.  
    3. # then check every 3 seconds or so
    4. every 3 seconds:
    5.     loop all players:
    6.         if {_old_money::%loop-player%} != current player's balance:
    7.             update_your_thing( )
    edit:
    just got my eyes for 1 second on your code and noticed you have multiple on inventory events, why... you can do that whole thing on 1 event
     
  3. Djavan

    Djavan Member

    Joined:
    Jul 19, 2019
    Messages:
    16
    Likes Received:
    0
    What do you mean with update__your_thing?

    --- Double Post Merged, Jul 25, 2019, Original Post Date: Jul 25, 2019 ---
    I fixed the problem with a simple,
    Code (Text):
    1. add 1 to {deposit_num_of_clicks::%player%}
    2.             close player's inventory
    3.             wait 1 tick
    4.             make player execute command "/deposit"
    Thanks for the help!

     
Thread Status:
Not open for further replies.

Share This Page

Loading...