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.

on armor equip/unequip bug

Discussion in 'Skript' started by kamilleon, Apr 24, 2020.

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

    kamilleon Member

    Joined:
    Nov 18, 2017
    Messages:
    48
    Likes Received:
    0
    I'm trying to make something similar to hypixel's armor system on skyblock, but in skript it's a little buggy.

    When I try to equip and unequip the armor too fast (I mean like 3-4 cps is enough) It starts to add the value to the player's hp and defense continuously.

    Code (Text):
    1.  
    2. on armor equip:
    3.     if "%lore of event-item%" contains "Védelem" or "Élet":
    4.         set {_lore::*} to lore of event-item
    5.         loop {_lore::*}:
    6.             if {_lore::%loop-index%} contains "Védelem":
    7.                 set {_védeleml} to {_lore::%loop-index%}
    8.                 set {_védelemsl::*} to {_védeleml} split at " "
    9.                 set {_védelemy::*} to {_védelemsl::2} split at "+"
    10.                 set {_finalv} to {_védelemy::2}
    11.                 add {_finalv} parsed as integer to {defense::%player%}
    12.                 send "%{defense::%player%}% v"
    13.             if {_lore::%loop-index%} contains "Élet":
    14.                 set {_életl} to {_lore::%loop-index%}
    15.                 set {_életsl::*} to {_életl} split at " "
    16.                 set {_élety::*} to {_életsl::2} split at "+"
    17.                 set {_finalv} to {_élety::2}
    18.                 add {_finalv} parsed as integer to {élet::%player%}
    19.                 send "%{élet::%player%}% h"
    20.                 set maximum health of player to {élet::%player%}/2
    21.  
    22.  
    23.  
    24. on armor unequip:
    25.     if "%lore of event-item%" contains "Védelem" or "Élet":
    26.         set {_lore::*} to lore of event-item
    27.         loop {_lore::*}:
    28.             if {_lore::%loop-index%} contains "Védelem":
    29.                 set {_védeleml} to {_lore::%loop-index%}
    30.                 set {_védelemsl::*} to {_védeleml} split at " "
    31.                 set {_védelemy::*} to {_védelemsl::2} split at "+"
    32.                 set {_finalv} to {_védelemy::2}
    33.                 subtract {_finalv} parsed as integer from {defense::%player%}
    34.                 send "%{defense::%player%}% v"
    35.             if {_lore::%loop-index%} contains "Élet":
    36.                 set {_életl} to {_lore::%loop-index%}
    37.                 set {_életsl::*} to {_életl} split at " "
    38.                 set {_élety::*} to {_életsl::2} split at "+"
    39.                 set {_finalv} to {_élety::2}
    40.                 subtract {_finalv} parsed as integer from {élet::%player%}
    41.                 send "%{élet::%player%}% h"
    42.                 set maximum health of player to {élet::%player%}/2


     
  2. Best Answer:
    Post #3 by kamilleon, Apr 25, 2020
  3. IDuckz_

    IDuckz_ Active Member

    Joined:
    Jul 25, 2019
    Messages:
    106
    Likes Received:
    2
    You can add a wait 1 second or wait 10 ticks or something.
     
  4. kamilleon

    kamilleon Member

    Joined:
    Nov 18, 2017
    Messages:
    48
    Likes Received:
    0
    already tried that, didn't work
    --- Double Post Merged, Apr 25, 2020, Original Post Date: Apr 25, 2020 ---
    got it working with this:


    Code (Text):
    1. on armor equip:
    2.     if event-item is any helmet:
    3.         set {_slot} to 100
    4.     if event-item is any chestplate:
    5.         set {_slot} to 101
    6.     if event-item is any leggings:
    7.         set {_slot} to 102
    8.     if event-item is any boots:
    9.         set {_slot} to 103
    10.     if {found.%{_slot}%::%player%} isn't true:
    11.         if "%lore of event-item%" contains "Védelem" or "Élet":
    12.             set {_lore::*} to lore of event-item
    13.             loop {_lore::*}:
    14.                 if {_lore::%loop-index%} contains "Védelem":
    15.                     set {_védeleml} to {_lore::%loop-index%}
    16.                     set {_védelemsl::*} to {_védeleml} split at " "
    17.                     set {_védelemy::*} to {_védelemsl::2} split at "+"
    18.                     set {_finalv} to {_védelemy::2}
    19.                     add {_finalv} parsed as integer to {defense::%player%}
    20.                 if {_lore::%loop-index%} contains "Élet":
    21.                     set {_életl} to {_lore::%loop-index%}
    22.                     set {_életsl::*} to {_életl} split at " "
    23.                     set {_élety::*} to {_életsl::2} split at "+"
    24.                     set {_finalv} to {_élety::2}
    25.                     add {_finalv} parsed as integer to {élet::%player%}
    26.                     set maximum health of player to ({élet::%player%}/2)+{path.prestige::%player%}
    27.             set {found.%{_slot}%::%player%} to true
    28.  
    29. on armor unequip:
    30.     if event-item is any helmet:
    31.         set {_slot} to 100
    32.     if event-item is any chestplate:
    33.         set {_slot} to 101
    34.     if event-item is any leggings:
    35.         set {_slot} to 102
    36.     if event-item is any boots:
    37.         set {_slot} to 103
    38.     if {found.%{_slot}%::%player%} isn't false:
    39.         if "%lore of event-item%" contains "Védelem" or "Élet":
    40.             set {_lore::*} to lore of event-item
    41.             loop {_lore::*}:
    42.                 if {_lore::%loop-index%} contains "Védelem":
    43.                     set {_védeleml} to {_lore::%loop-index%}
    44.                     set {_védelemsl::*} to {_védeleml} split at " "
    45.                     set {_védelemy::*} to {_védelemsl::2} split at "+"
    46.                     set {_finalv} to {_védelemy::2}
    47.                     subtract {_finalv} parsed as integer from {defense::%player%}
    48.                 if {_lore::%loop-index%} contains "Élet":
    49.                     set {_életl} to {_lore::%loop-index%}
    50.                     set {_életsl::*} to {_életl} split at " "
    51.                     set {_élety::*} to {_életsl::2} split at "+"
    52.                     set {_finalv} to {_élety::2}
    53.                     subtract {_finalv} parsed as integer from {élet::%player%}
    54.                     set maximum health of player to ({élet::%player%}/2)+{path.prestige::%player%}
    55.             set {found.%{_slot}%::%player%} to false
     
Thread Status:
Not open for further replies.

Share This Page

Loading...