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 our 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.

Trying to make a crates skript

Discussion in 'Skript' started by DavidZar, Aug 4, 2019.

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

    DavidZar Member

    Joined:
    Aug 4, 2019
    Messages:
    2
    Likes Received:
    0
    So I'm trying to make a skript for crates, and I wanted to make it so you can list all the crates that exist. I also wanted to list items inside crates. I'm not sure how to do this at all though... or if there is an easy way to make anything I already made. I just need help!
    Code (Text):
    1. options:
    2.     prefix: &7[&dZarCrates&7]&f #What comes before everything
    3.     permission: zarcrates.
    4.  
    5. command /crates [<text>] [<text>] [<text>]:
    6.     aliases: /crate, /zarcrates, /zcrates, /zcrate, /zarcrate, /zarcrates:crate
    7.     permission: {@permission}*
    8.     trigger:
    9.         if arg 1 is not "create" or "make" or "delete" or "remove" or "item" or "give" or "list":
    10.             send ""
    11.             send "{@prefix} &bZarCrates&f usage:"
    12.             send ""
    13.             send "{@prefix} Creating and deleting crates:"
    14.             send "{@prefix} /crate (create/make) <crate_name> &7||&f Create crates"
    15.             send "{@prefix} /crate (delete/remove) <crate_name> &7||&f Delete crates"
    16.             send ""
    17.             send "{@prefix} Adding and removing items:"
    18.             send "{@prefix} /crate item (add/remove) <crate_name> &7||&f Remove/add the item you are holding to the crate"
    19.             send ""
    20.             send "{@prefix} Using crates:"
    21.             send "{@prefix} /crate give <crate_name> <player> &7||&f Give players crates"
    22.             send "{@prefix} /crate list &7||&f List all crates"
    23.             send ""
    24.         if arg 1 is "create" or "make":
    25.             if arg 2 is not set:
    26.                 send "{@prefix} /crate (create/make) <crate_name>"
    27.             if arg 2 is set:
    28.                 if {crates.%arg-2%} = 1:
    29.                     send "{@prefix} Crate &b%arg-2%&f already exists!"
    30.                 else:
    31.                     set {crates.%arg-2%} to 1
    32.                     send "{@prefix} Crate &b%arg-2%&f has been created!"
    33.         if arg 1 is "delete" or "remove":
    34.             if arg 2 is not set:
    35.                 send "{@prefix} /crate (delete/remove) <crate_name>"
    36.             if arg 2 is set:
    37.                 if {crates.%arg-2%} = 1:
    38.                     delete {crates.%arg-2%}
    39.                     delete {crates.%arg-2%.item1}
    40.                     delete {crates.%arg-2%.item2}
    41.                     delete {crates.%arg-2%.item3}
    42.                     delete {crates.%arg-2%.item4}
    43.                     delete {crates.%arg-2%.item5}
    44.                     delete {crates.%arg-2%.item6}
    45.                     delete {crates.%arg-2%.item7}
    46.                     send "{@prefix} Crate &b%arg-2%&f has been deleted!"
    47.                 else:
    48.                     send "{@prefix} Crate &b%arg-2%&f does not exist!"
    49.         if arg 1 is "item":
    50.             if arg 2 is "add":
    51.                 if arg 3 is set:
    52.                     if {crates.%arg-3%} = 1:
    53.                         if {crates.%arg-3%.item1} is not set:
    54.                             set {crates.%arg-3%.item1} to player's held item
    55.                             send "{@prefix} %{crates.%arg-3%.item1}% added!"
    56.                         else:
    57.                             if {crates.%arg-3%.item2} is not set:
    58.                                 set {crates.%arg-3%.item2} to player's held item
    59.                                 send "{@prefix} %{crates.%arg-3%.item2}% added!"
    60.                             else:
    61.                                 if {crates.%arg-3%.item3} is not set:
    62.                                     set {crates.%arg-3%.item3} to player's held item
    63.                                     send "{@prefix} %{crates.%arg-3%.item3}% added!"
    64.                                 else:
    65.                                     if {crates.%arg-3%.item4} is not set:
    66.                                         set {crates.%arg-3%.item4} to player's held item
    67.                                         send "{@prefix} %{crates.%arg-3%.item4}% added!"
    68.                                     else:
    69.                                         if {crates.%arg-3%.item5} is not set:
    70.                                             set {crates.%arg-3%.item5} to player's held item
    71.                                             send "{@prefix} %{crates.%arg-3%.item5}% added!"
    72.                                         else:
    73.                                             if {crates.%arg-3%.item6} is not set:
    74.                                                 set {crates.%arg-3%.item6} to player's held item
    75.                                                 send "{@prefix} %{crates.%arg-3%.item6}% added!"
    76.                                             else:
    77.                                                 if {crates.%arg-3%.item7} is not set:
    78.                                                     set {crates.%arg-3%.item7} to player's held item
    79.                                                     send "{@prefix} %{crates.%arg-3%.item7}% added!"
    80.                                                 else:
    81.                                                     send "{@prefix} Max items in a crate is 7"
    82.                     else:
    83.                         send "{@prefix} Crate &b%arg-3%&f does not exist!"
    84.                 if arg 3 is not set:
    85.                     send "{@prefix} /crate item add <crate_name>"
    86.             if arg 2 is "remove":
    87.                 if arg 3 is set:
    88.                     if {crates.%arg-3%} = 1:
    89.                         if {crates.%arg-3%.item7} is set:
    90.                             send "{@prefix} %{crates.%arg-3%.item7}% removed!"
    91.                             delete {crates.%arg-3%.item7}
    92.                         else:
    93.                             if {crates.%arg-3%.item6} is set:
    94.                                 send "{@prefix} %{crates.%arg-3%.item6}% removed!"
    95.                                 delete {crates.%arg-3%.item6}
    96.                             else:
    97.                                 if {crates.%arg-3%.item5} is set:
    98.                                     send "{@prefix} %{crates.%arg-3%.item5}% removed!"
    99.                                     delete {crates.%arg-3%.item5}
    100.                                 else:
    101.                                     if {crates.%arg-3%.item4} is set:
    102.                                         send "{@prefix} %{crates.%arg-3%.item4}% removed!"
    103.                                         delete {crates.%arg-3%.item4}
    104.                                     else:
    105.                                         if {crates.%arg-3%.item3} is set:
    106.                                             send "{@prefix} %{crates.%arg-3%.item3}% removed!"
    107.                                             delete {crates.%arg-3%.item3}
    108.                                         else:
    109.                                             if {crates.%arg-3%.item2} is set:
    110.                                                 send "{@prefix} %{crates.%arg-3%.item2}% removed!"
    111.                                                 delete {crates.%arg-3%.item2}
    112.                                             else:
    113.                                                 if {crates.%arg-3%.item1} is set:
    114.                                                     send "{@prefix} %{crates.%arg-3%.item1}% removed!"
    115.                                                     delete {crates.%arg-3%.item1}
    116.                                                 else:
    117.                                                     send "{@prefix} There are no items to remove!"
    118.                     else:
    119.                         send "{@prefix} Crate &b%arg-3%&f does not exist!"
    120.                 if arg 3 is not set:
    121.                     send "{@prefix} /crate item remove <crate_name>"
    122.             if arg 2 is not set:
    123.                 send "{@prefix} /crate item (add/remove) <crate_name>"
    124.         if arg 1 is "give":
    125.             if arg 2 is set:
    126.                 if {crates.%arg-2%} = 1:
    127.                     give player 1 of pink shulker box named "{@prefix} %arg-2% crate" with lore "&brightclick&f to open!"
    128.                 else:
    129.                     send "{@prefix} Crate &b%arg-2%&f does not exist!"
    130.             else:
    131.                 send "{@prefix} /crate give <crate_name>"
    132.         if arg 1 is "list":
    133.             if arg 2 is set:
    134.                 send "{@prefix} /crate list"
    135.             if arg 2 is not set:
    136.                 open chest with 3 rows named "{@prefix} Crate list!" to player
    137.                 wait 1 tick
    138.                 make gui slot 0 of player with pink stained glass pane named "{@prefix}"
    139.                 make gui slot 1 of player with pink stained glass pane named "{@prefix}"
    140.                 make gui slot 2 of player with pink stained glass pane named "{@prefix}"
    141.                 make gui slot 3 of player with pink stained glass pane named "{@prefix}"
    142.                 make gui slot 4 of player with pink stained glass pane named "{@prefix}"
    143.                 make gui slot 5 of player with pink stained glass pane named "{@prefix}"
    144.                 make gui slot 6 of player with pink stained glass pane named "{@prefix}"
    145.                 make gui slot 7 of player with pink stained glass pane named "{@prefix}"
    146.                 make gui slot 8 of player with pink stained glass pane named "{@prefix}"
    147.                 make gui slot 9 of player with pink stained glass pane named "{@prefix}"
    148.                 make gui slot 10 of player with pink shulker box named "{@prefix} %arg-2% crate" to run [give player 1 of pink shulker box named "{@prefix} %arg-2% crate" with lore "&brightclick&f to open!"]
    --- Double Post Merged, Aug 4, 2019, Original Post Date: Aug 4, 2019 ---
    Oh right 1 more thing, I can get any addons I may need, and I already have a few to make this work 100%, I can make crates and delete them, add items and stuff, just don't know how to move on from here!
     
  2. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    307
    Likes Received:
    20
  3. DavidZar

    DavidZar Member

    Joined:
    Aug 4, 2019
    Messages:
    2
    Likes Received:
    0
    I actually figured it out a few minutes ago, and was about to post this here. I need help with another thing now, for some reason items aren't being removed from the crates when I delete and remake the crate, or when I do "/crates item remove test"

    Hope you can help. (by the way, you were right about the loops thing, just it didn't help cause I had already figured it out before you had a chance to tell me

    Here's updated code:


    Code (Text):
    1. options:
    2.     prefix: &7[&dZarCrates&7]&f #What comes before everything
    3.     permission: zarcrates. #What comes before every permissions
    4.  
    5. command /crates [<text>] [<text>] [<text>]:
    6.     aliases: /crate, /zarcrates, /zcrates, /zcrate, /zarcrate, /zarcrates:crate
    7.     permission: {@permission}*
    8.     trigger:
    9.         if arg 1 is not "create" or "make" or "delete" or "remove" or "item" or "give" or "list":
    10.             send ""
    11.             send "{@prefix} &bCrates&f usage:"
    12.             send ""
    13.             send "{@prefix} Creating and deleting crates:"
    14.             send "{@prefix} /crate (create/make) <crate_name> &7||&f Create crates"
    15.             send "{@prefix} /crate (delete/remove) <crate_name> &7||&f Delete crates"
    16.             send ""
    17.             send "{@prefix} Adding and removing items:"
    18.             send "{@prefix} /crate item (add/remove) <crate_name> &7||&f Remove/add the item you are holding to the crate"
    19.             send ""
    20.             send "{@prefix} Using crates:"
    21.             send "{@prefix} /crate give <crate_name> <player> &7||&f Give players crates"
    22.             send "{@prefix} /crate list (<item>/none) (<crate_name>/none) &7||&f List all crates/items inside"
    23.             send ""
    24.         if arg 1 is "create" or "make":
    25.             if arg 2 is not set:
    26.                 send "{@prefix} /crate (create/make) <crate_name>"
    27.             if arg 2 is set:
    28.                 if {crates.%arg-2%} = 1:
    29.                     send "{@prefix} Crate &b%arg-2%&f already exists!"
    30.                 else:
    31.                     set {crates.%arg-2%} to 1
    32.                     add arg 2 to {crate.list::*}
    33.                     send "{@prefix} Crate &b%arg-2%&f has been created!"
    34.         if arg 1 is "delete" or "remove":
    35.             if arg 2 is not set:
    36.                 send "{@prefix} /crate (delete/remove) <crate_name>"
    37.             if arg 2 is set:
    38.                 if {crates.%arg-2%} = 1:
    39.                     delete {crate.%arg-2%.list::*}
    40.                     delete {crates.%arg-2%}
    41.                     delete {crates.%arg-2%.item1}
    42.                     delete {crates.%arg-2%.item2}
    43.                     delete {crates.%arg-2%.item3}
    44.                     delete {crates.%arg-2%.item4}
    45.                     delete {crates.%arg-2%.item5}
    46.                     delete {crates.%arg-2%.item6}
    47.                     delete {crates.%arg-2%.item7}
    48.                     remove "%arg-2%" from {crate.list::*}
    49.                     remove "%arg-2%" from {crate.list::*}
    50.                     send "{@prefix} Crate &b%arg-2%&f has been deleted!"
    51.                 else:
    52.                     send "{@prefix} Crate &b%arg-2%&f does not exist!"
    53.         if arg 1 is "item":
    54.             if arg 2 is "add":
    55.                 if arg 3 is set:
    56.                     if {crates.%arg-3%} = 1:
    57.                         if {crates.%arg-3%.item1} is not set:
    58.                             set {crates.%arg-3%.item1} to player's held item
    59.                             add player's held item to {crate.%arg-3%.listitem::*}
    60.                             send "{@prefix} %{crates.%arg-3%.item1}% added!"
    61.                         else:
    62.                             if {crates.%arg-3%.item2} is not set:
    63.                                 set {crates.%arg-3%.item2} to player's held item
    64.                                 add player's held item to {crate.%arg-3%.listitem::*}
    65.                                 send "{@prefix} %{crates.%arg-3%.item2}% added!"
    66.                             else:
    67.                                 if {crates.%arg-3%.item3} is not set:
    68.                                     set {crates.%arg-3%.item3} to player's held item
    69.                                     add player's held item to {crate.%arg-3%.listitem::*}
    70.                                     send "{@prefix} %{crates.%arg-3%.item3}% added!"
    71.                                 else:
    72.                                     if {crates.%arg-3%.item4} is not set:
    73.                                         set {crates.%arg-3%.item4} to player's held item
    74.                                         add player's held item to {crate.%arg-3%.listitem::*}
    75.                                         send "{@prefix} %{crates.%arg-3%.item4}% added!"
    76.                                     else:
    77.                                         if {crates.%arg-3%.item5} is not set:
    78.                                             set {crates.%arg-3%.item5} to player's held item
    79.                                             add player's held item to {crate.%arg-3%.listitem::*}
    80.                                             send "{@prefix} %{crates.%arg-3%.item5}% added!"
    81.                                         else:
    82.                                             if {crates.%arg-3%.item6} is not set:
    83.                                                 set {crates.%arg-3%.item6} to player's held item
    84.                                                 add player's held item to {crate.%arg-3%.listitem::*}
    85.                                                 send "{@prefix} %{crates.%arg-3%.item6}% added!"
    86.                                             else:
    87.                                                 if {crates.%arg-3%.item7} is not set:
    88.                                                     set {crates.%arg-3%.item7} to player's held item
    89.                                                     add player's held item to {crate.%arg-3%.listitem::*}
    90.                                                     send "{@prefix} %{crates.%arg-3%.item7}% added!"
    91.                                                 else:
    92.                                                     send "{@prefix} Max items in a crate is 7"
    93.                     else:
    94.                         send "{@prefix} Crate &b%arg-3%&f does not exist!"
    95.                 if arg 3 is not set:
    96.                     send "{@prefix} /crate item add <crate_name>"
    97.             if arg 2 is "remove":
    98.                 if arg 3 is set:
    99.                     if {crates.%arg-3%} = 1:
    100.                         if {crates.%arg-3%.item7} is set:
    101.                             send "{@prefix} %{crates.%arg-3%.item7}% removed!"
    102.                             remove "{crates.%arg-3%.item7}" from {crate.%arg-3%.list::*}
    103.                             delete {crates.%arg-3%.item7}
    104.                         else:
    105.                             if {crates.%arg-3%.item6} is set:
    106.                                 send "{@prefix} %{crates.%arg-3%.item6}% removed!"
    107.                                 remove "{crates.%arg-3%.item6}" from {crate.%arg-3%.list::*}
    108.                                 delete {crates.%arg-3%.item6}
    109.                             else:
    110.                                 if {crates.%arg-3%.item5} is set:
    111.                                     send "{@prefix} %{crates.%arg-3%.item5}% removed!"
    112.                                     remove "{crates.%arg-3%.item5}" from {crate.%arg-3%.list::*}
    113.                                     delete {crates.%arg-3%.item5}
    114.                                 else:
    115.                                     if {crates.%arg-3%.item4} is set:
    116.                                         send "{@prefix} %{crates.%arg-3%.item4}% removed!"
    117.                                         remove "{crates.%arg-3%.item4}" from {crate.%arg-3%.list::*}
    118.                                         delete {crates.%arg-3%.item4}
    119.                                     else:
    120.                                         if {crates.%arg-3%.item3} is set:
    121.                                             send "{@prefix} %{crates.%arg-3%.item3}% removed!"
    122.                                             remove "{crates.%arg-3%.item3}" from {crate.%arg-3%.list::*}
    123.                                             delete {crates.%arg-3%.item3}
    124.                                         else:
    125.                                             if {crates.%arg-3%.item2} is set:
    126.                                                 send "{@prefix} %{crates.%arg-3%.item2}% removed!"
    127.                                                 remove "{crates.%arg-3%.item2}" from {crate.%arg-3%.list::*}
    128.                                                 delete {crates.%arg-3%.item2}
    129.                                             else:
    130.                                                 if {crates.%arg-3%.item1} is set:
    131.                                                     send "{@prefix} %{crates.%arg-3%.item1}% removed!"
    132.                                                     remove "{crates.%arg-3%.item1}" from {crate.%arg-3%.list::*}
    133.                                                     delete {crates.%arg-3%.item1}
    134.                                                 else:
    135.                                                     send "{@prefix} There are no items to remove!"
    136.                     else:
    137.                         send "{@prefix} Crate &b%arg-3%&f does not exist!"
    138.                 if arg 3 is not set:
    139.                     send "{@prefix} /crate item remove <crate_name>"
    140.             if arg 2 is not set:
    141.                 send "{@prefix} /crate item (add/remove) <crate_name>"
    142.         if arg 1 is "give":
    143.             if arg 2 is set:
    144.                 if {crates.%arg-2%} = 1:
    145.                     give player 1 of pink shulker box named "{@prefix} %arg-2% crate" with lore "&brightclick&f to open!"
    146.                 else:
    147.                     send "{@prefix} Crate &b%arg-2%&f does not exist!"
    148.             else:
    149.                 send "{@prefix} /crate give <crate_name>"
    150.         if arg 1 is "list":
    151.             if arg 2 is "item":
    152.                 if {crates.%arg-3%} = 1:
    153.                     send ""
    154.                     loop {crate.%arg-3%.listitem::*}:
    155.                         send "{@prefix} %loop-value% "
    156.                     send ""
    157.                 else:
    158.                     send "{@prefix} Crate &b%arg-3%&f does not exist!"
    159.             else if arg 2 is not set:
    160.                 send ""
    161.                 loop {crate.list::*}:
    162.                     send "{@prefix} %loop-value%"
    163.                 send ""
    164.             else:
    165.                 send "{@prefix} /crate list (<item>/none) (<crate_name>/none)"
     
  4. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    307
    Likes Received:
    20
    No idea on that and I don't wanna spend my whole days looking at your 100 lines of code, also else if can be used in the same line that whole ton of code gave me eye cancer, anyways next time just post the relevant parts of the code just a tip
     
Thread Status:
Not open for further replies.
Loading...