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.

MetaData issues...

Discussion in 'Skript' started by 4IDp8, Dec 17, 2020.

Tags:
Thread Status:
Not open for further replies.
  1. 4IDp8

    4IDp8 Member

    Joined:
    Dec 15, 2020
    Messages:
    12
    Likes Received:
    0
    I am new to skript, but i wanted to add custom enchants to my server,

    The only problem is that my code dont work, here it is:


    on skript load:
    register a new custom enchantment with id name "Speed"
    set {_speedenchant} to "Speed" parsed as custom enchantment
    set max level of {_speedenchant} to 2
    set rarity of {_speedenchant} to 2
    set accepted items for {_speedenchant} to "boots"
    set lore name of {_speedenchant} to "Gives you speed!"

    on armor equip:
    if lore of item contains "speed":
    set metadata value "custom-enchantment-speed" of player to 1

    while metadata value "custom-enchantment-speed" of player is 1:
    every second:
    broadcast s
     
  2. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    You don't have to assign custom metadata to players. You can just check if their boots are your custom enchanted boots:
    Code (Text):
    1. on armor equip:
    2.     while lore of boots of player contains "speed":
    3.         broadcast "s"
    4.         wait 1 seconds
     
    • Like Like x 1
  3. 4IDp8

    4IDp8 Member

    Joined:
    Dec 15, 2020
    Messages:
    12
    Likes Received:
    0
    #3 4IDp8, Dec 17, 2020
    Last edited: Dec 17, 2020
  4. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    If you are trying to solve some problem, you have to first think of how it could be implemented.

    For example:
    I want boots which will create random colored wool trail behind me as I walk...
    1. I need to create walk event handler.
    2. I need to check block under me (don't want it to create trail in air or water...).
    3. I need to replace that block with random colored wool.

    Since your problem is fairly simple (Minecraft has already implement speed logic), you just have to apply speed effect when player equip boots and as soon as player take the boots off you have to remove the effect.

    This is your implementation:
    Code (Text):
    1. on armor equip:
    2.     if lore of boots of player contains "speed":
    3.         apply speed 2 to the player for 100000 seconds
    4.        
    5. sharpsk on armor unequip:
    6.     if lore of boots of player does not contain "speed":
    7.         remove speed from player
    Note: Take it as a pseudo code, I didn't tested it.
     
  5. 4IDp8

    4IDp8 Member

    Joined:
    Dec 15, 2020
    Messages:
    12
    Likes Received:
    0
    I ment, how do i apply the speed enchant to boots, and how to i make it appear in an enchantment table?

    The code dont work btw, i get no speed when i put my boots on (The capitalation is right)
     
  6. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    Add this line to your init section:
    Code (Text):
    1. set enabled for {_speedenchant} to true
    You probably need some other condition there. Use this syntax:
    Code (Text):
    1. %itemtype% has custom enchantment %custom enchantment%
    If you won't get it to work, then try some debugging.
     
  7. 4IDp8

    4IDp8 Member

    Joined:
    Dec 15, 2020
    Messages:
    12
    Likes Received:
    0
  8. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    It's syntax, not actual code.
     
  9. 4IDp8

    4IDp8 Member

    Joined:
    Dec 15, 2020
    Messages:
    12
    Likes Received:
    0
    Sorry, i am bad at programming, what does that mean?
     
Thread Status:
Not open for further replies.

Share This Page

Loading...