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.

Crates not workig

Discussion in 'Skript' started by AverageGamer590, Jul 17, 2021.

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

    AverageGamer590 New Member

    Joined:
    Jun 27, 2021
    Messages:
    6
    Likes Received:
    0
    Nothing is saving, when I set something it doesn't save.
    Code (Text):
    1. function registerCrate(id:number, name:string, l:location, key:item, items:object, chances:object):
    2.   clear {crates::%{_id}%::*}
    3.   set {crates::%{_id}%} to {_id}
    4.   set {crates::%{_id}%::name} to {_name}
    5.   set {crates::%{_id}%::location} to {_location}
    6.   set {crates::%{_id}%::key} to {_key}
    7.   set {crates::%{_id}%::items} to {_items}
    8.   set {crates::%{_id}%::chances} to {_chances}
    9.   set {crates::locations} to 1
    10.   add {_l} to {crates::locations::*}
    11.  
    12.  
    13. function useKey(p:player, l:location, key:item):
    14.   loop {crates::*}:
    15.     if {crates::%loop-index%::key} = {_key}:
    16.       set {_id} to loop-index-1
    17.       set {_chancenum} to 0
    18.       set {_random} to random integer between 1 and 100
    19.       loop {crates::%{_id}%::items::*}:
    20.         add index loop-value-2 of {crates::%{_id}%::chance} to {_chancenum}
    21.         if {_random} < {_chancenum}:
    22.           give {crates::%{_id}%::items} to {_p}
    23.        
    24.       send "%{_items}%" to {_p}
    25.       # set {_random} to random integer in between 1 and the length of {_items::*}
    26.       give random element out of {_items::*} to {_p}
    27.  
    28. function targetblock(p:player) :: location:
    29.     return location of target block of {_p}
    30.  
    31. on right click:
    32.   if {crates::locations::*} contains targetblock(player):
    33.     cancel event
    34.     useKey(player, targetblock(player), player's tool)
    35.  
    36. on right click:
    37.   if {ccLocation::%uuid of player%} is set:
    38.     if player has permission "crate.create":
    39.       cancel event
    40.       send "&aBlock selected" to player
    41.       clear {ccLocation::%uuid of player%}
    42.       set {createData::%uuid of player%::location} to targetblock(player)
    43.       set {_gui} to a new chest inventory with 1 row named "&6Create Crate"
    44.       set slot 4 of {_gui} to grass named "&6Click me to set a block"
    45.       set slot 2 of {_gui} to oak sign named "&6Click to change name"
    46.       if {crateData::%uuid of player%::name} is set:
    47.         set slot 2 of {_gui} to oak sign named "%{crateData::%uuid of player%::name}%"
    48.       set slot 6 of {_gui} to bedrock named "&6Click to set key"
    49.       if {createData::%uuid of player%::key} is set:
    50.         set slot 6 of {_gui} to {createData::%uuid of player%::key}
    51.       set slot 8 of {_gui} to lime glass pane named "&aClick to confirm"
    52.       open {_gui} to the player
    53.   if {ccItem::%uuid of player%} is set:
    54.     if player has permission "crate.create":
    55.       cancel event
    56.       send "&aKey selected" to player
    57.       clear {ccItem::%uuid of player%}
    58.       set {createData::%uuid of player%::key} to player's held item
    59.       set {_gui} to a new chest inventory with 1 row named "&6Create Crate"
    60.       set slot 4 of {_gui} to grass named "&6Click me to set a block"
    61.       set slot 2 of {_gui} to oak sign named "&6Click to change name"
    62.       if {crateData::%uuid of player%::name} is set:
    63.         set slot 2 of {_gui} to oak sign named "%{crateData::%uuid of player%::name}%"
    64.       set slot 6 of {_gui} to bedrock named "&6Click to set key"
    65.       if {createData::%uuid of player%::key} is set:
    66.         set slot 6 of {_gui} to {createData::%uuid of player%::key}
    67.       set slot 8 of {_gui} to lime glass pane named "&aClick to confirm"
    68.       open {_gui} to the player
    69.      
    70.  
    71. on chat:
    72.   if {ccName::%uuid of player%} is set:
    73.     if player has permission "crate.create":
    74.       cancel event
    75.       clear {ccName::%uuid of player%}
    76.       set {createData::%uuid of player%::name} to message
    77.       send "&aName set to %{crateData::%uuid of player%::*}% " to player
    78.       set {_gui} to a new chest inventory with 1 row named "&6Create Crate"
    79.       set slot 4 of {_gui} to grass named "&6Click me to set a block"
    80.       set slot 2 of {_gui} to oak sign named "&6Click to change name"
    81.       if {crateData::%uuid of player%::name} is set:
    82.         set slot 2 of {_gui} to oak sign named "%{crateData::%uuid of player%::name}%"
    83.       set slot 6 of {_gui} to bedrock named "&6Click to set key"
    84.       if {createData::%uuid of player%::key} is set:
    85.         set slot 6 of {_gui} to {createData::%uuid of player%::key}
    86.       set slot 8 of {_gui} to lime glass pane named "&aClick to confirm"
    87.       open {_gui} to the player
    88.      
    89. command /crate create:
    90.   permission: crate.create
    91.   trigger:
    92.     clear {crateData::%uuid of player%::*}
    93.     set {createData::%uuid of player%} to 1
    94.     set {_gui} to a new chest inventory with 1 row named "&6Create Crate"
    95.     set slot 4 of {_gui} to grass named "&6Click me to set a block"
    96.     set slot 2 of {_gui} to oak sign named "&6Click to change name"
    97.     if {crateData::%uuid of player%::name} is set:
    98.       set slot 2 of {_gui} to oak sign named "%{crateData::%uuid of player%::name}%"
    99.     set slot 6 of {_gui} to bedrock named "&6Click to set key"
    100.     if {createData::%uuid of player%::key} is set:
    101.       set slot 6 of {_gui} to {createData::%uuid of player%::key}
    102.     set slot 8 of {_gui} to lime glass pane named "&aClick to confirm"
    103.     open {_gui} to the player
    104.  
    105. on inventory click:
    106.   if name of event-inventory is "&6Create Crate":
    107.     cancel event
    108.     if event-inventory != player's inventory:
    109.       if name of event-slot is "&6Click me to set a block":
    110.         set {ccLocation::%uuid of player%} to 1
    111.         close player's inventory
    112.         send "&6Right click a block to select it"
    113.       if name of event-slot is "&6Click to change name":
    114.         set {ccName::%uuid of player%} to 1
    115.         close player's inventory
    116.         send "&6Type the name of the crate"
    117.       if event-slot is 6:
    118.         set {ccItem::%uuid of player%} to 1
    119.         close player's inventory
    120.         send "&6Right click while holding an item to select it"
    121.       if name of event-slot is "&aClick to confirm":
    122.         close player's inventory
    123.         send "&aCrate registered with id %{crateData::%uuid of player%::*}%"
    124.         registerCrate((length of {crates::*} ? 1), ({crateData::%uuid of player%::name}), ({crateData::%uuid of player%::location}), ({crateData::%uuid of player%::key}),(air), (air))
    --- Double Post Merged, Jul 17, 2021, Original Post Date: Jul 17, 2021 ---
    The thing that isn't saving is {createData::%uuid of player%::*}. When you use /crate create and change the name it will say <none>
     
Thread Status:
Not open for further replies.

Share This Page

Loading...