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!

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

Chest password

Discussion in 'Requests' started by David, Oct 24, 2018.

  1. David

    David Member

    Jan 31, 2017
    Likes Received:
    as I do for when I open a chest I have to put a 3 digit password, but through the gui menu, the example is in this video:
  2. TPGamesNL

    Supporter Addon Developer Dev Programme

    Jan 20, 2018
    Likes Received:
    Is this good?
    Code (Skript):
    1. options:
    2.     pin-code-length: 4
    3.     override-permission: admin
    5. on right click on chest:
    6.     cancel event
    7.     open virtual chest inventory with 5 rows named "&aChest lock" to player
    8.     loop 9 times:
    9.         make gui slot (loop-number + 3 + (round((loop-number +1)/ 3) * 6)) of player with loop-number of gray concrete named "&e%loop-number%" to run function enterPassNumber(player, loop-number)
    10.     make gui slot 23 of player with red concrete named "&eReset password" to run function resetPassNumbers(player)
    11.     if player has permission "{@override-permission}":
    12.         make gui slot 25 of player with yellow concrete named "&eForce open (Admin only)" to run function forceOpen(player, event-block)
    13.     while name of player's current inventory contains "&aChest lock":
    14.         if size of {enteredpass::%player%::*} >= {@pin-code-length}:
    15.             set {_pass::*} to {enteredpass::%player%::*}
    16.             exit loop
    17.         wait 1 tick
    18.     delete {enteredpass::%player%::*}
    19.     {_pass::*} is set
    20.     set {_inp} to join {_pass::*} with ""
    21.     remove gui slot 23 of player
    22.     remove gui slot 25 of player
    23.     if {_inp} is {chestpassword::%location of event-block%}:
    24.         play sound "UI_BUTTON_CLICK" at location of player for player
    25.         make gui slot 24 of player with chest named "&eOpen chest" to run function openPassChest(player, event-block)
    26.         make gui slot 25 of player with name tag named "&eDelete password" to close then run function deletePassChest(event-block)
    27.     else if {chestpassword::%location of event-block%} is not set:
    28.         make gui slot 24 of player with green concrete named "&eConfirm pass" to close then run function setChestPass(player, event-block, {_inp})
    29.     else:
    30.         play sound "BLOCK_ANVIL_LAND" with volume .5 at location of player for player
    31.         close inventory of player
    33. function enterPassNumber(p: player, n: integer):
    34.     add {_n} to {enteredpass::%{_p}%::*}
    36. function resetPassNumbers(p: player):
    37.     delete {enteredpass::%{_p}%::*}
    39. function openPassChest(p: player, b: block):
    40.     open block at {_b} to {_p}
    42. function setChestPass(p: player, b: block, pass: text):
    43.     set {_loc} to location of {_b}
    44.     set {chestpassword::%{_loc}%} to {_pass}
    45.     play sound "entity_experience_orb_pickup" at {_p} for {_p}
    47. function deletePassChest(b: block):
    48.     set {_loc} to location of {_b}
    49.     delete {chestpassword::%{_loc}%}
    51. function forceOpen(p: player, b: block):
    52.     set {_loc} to location of {_b}
    53.     set {_l::*} to split {chestpassword::%{_loc}%} at ""
    54.     set {_i} to size of {_l::*}
    55.     delete {_l::%{_i}%}
    56.     set {enteredpass::%{_p}%::*} to {_l::*}
    58. on break:
    59.     set {_loc} to location of event-block
    60.     delete {chestpassword::%{_loc}%}

Share This Page