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.

Save items in variables

Discussion in 'Skript' started by ChromeShape, Feb 1, 2020.

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

    ChromeShape Member

    Joined:
    Feb 1, 2020
    Messages:
    1
    Likes Received:
    0
    Hello there!
    I need help for this skript problem.

    when I break the one of wheat, I want to save the amount of items to array variables, but I can't do this.
    How can I solve this problem?

    Code (Text):
    1. command /crops:
    2.     trigger:
    3.         wait 1 ticks
    4.         open chest with 3 row named "{@a} %player%" to player
    5.         play sound "BLOCK_NOTE_PLING" to player with volume 1 and pitch 10
    6.         loop 27 times:
    7.             set slot (loop-number)-1 of current inventory of player to {crops.%player%::%loop-number%}
    8.  
    9. on inventory close:
    10.     delete {cropsam.%{_a}%::*}
    11.     if inventory name of current inventory of player contains "crops":
    12.         set {_a} to inventory name of current inventory of player
    13.         replace all "{@a} " with "" in {_a}
    14.         delete {crops.%{_a}%::*}
    15.         loop 27 times:
    16.             add slot (loop-number)-1 of current inventory of player to {crops.%{_a}%::*}
    17.         loop {crops.%{_a}%::*}:
    18.             add item amount of wheat of {crops.%{_a}%::%loop-index%} to {cropsam.%{_a}%::%loop-index%}
    19.  
    20. on break of ripe wheat:
    21.     wait 1 tick
    22.     loop {crops.%player%::*}:
    23.         add item amount of loop-value + 1 to item amount of {crops.%player%::%loop-index%}
    24.         broadcast "%{crops.%player%::%loop-index%}%"
    25.     send player title "" with subtitle "&fYou got &e&lWheat!" for 0.5 seconds
     
    #1 ChromeShape, Feb 1, 2020
    Last edited: Feb 2, 2020
  2. Govindas

    Govindas Active Member

    Joined:
    Feb 5, 2017
    Messages:
    79
    Likes Received:
    5
    you save crops only on inventory close, which does not seem related to getting the crops amount from block breaking, I'd recommend loop dropped item entities around the broken block, check if their Spigot.ticksLived tag is like 0-1 and if it is wheat within the entity

    and your variable format looks weird, I'd recommend {crops::%uuid of player%::*} instead of {crops.%player%::*}
     
Thread Status:
Not open for further replies.

Share This Page

Loading...