on armor equip/unequip bug

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

kamilleon

Member
Nov 18, 2017
48
0
6
24
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:
on armor equip:
    if "%lore of event-item%" contains "Védelem" or "Élet":
        set {_lore::*} to lore of event-item
        loop {_lore::*}:
            if {_lore::%loop-index%} contains "Védelem":
                set {_védeleml} to {_lore::%loop-index%}
                set {_védelemsl::*} to {_védeleml} split at " "
                set {_védelemy::*} to {_védelemsl::2} split at "+"
                set {_finalv} to {_védelemy::2}
                add {_finalv} parsed as integer to {defense::%player%}
                send "%{defense::%player%}% v"
            if {_lore::%loop-index%} contains "Élet":
                set {_életl} to {_lore::%loop-index%}
                set {_életsl::*} to {_életl} split at " "
                set {_élety::*} to {_életsl::2} split at "+"
                set {_finalv} to {_élety::2}
                add {_finalv} parsed as integer to {élet::%player%}
                send "%{élet::%player%}% h"
                set maximum health of player to {élet::%player%}/2



on armor unequip:
    if "%lore of event-item%" contains "Védelem" or "Élet":
        set {_lore::*} to lore of event-item
        loop {_lore::*}:
            if {_lore::%loop-index%} contains "Védelem":
                set {_védeleml} to {_lore::%loop-index%}
                set {_védelemsl::*} to {_védeleml} split at " "
                set {_védelemy::*} to {_védelemsl::2} split at "+"
                set {_finalv} to {_védelemy::2}
                subtract {_finalv} parsed as integer from {defense::%player%}
                send "%{defense::%player%}% v"
            if {_lore::%loop-index%} contains "Élet":
                set {_életl} to {_lore::%loop-index%}
                set {_életsl::*} to {_életl} split at " "
                set {_élety::*} to {_életsl::2} split at "+"
                set {_finalv} to {_élety::2}
                subtract {_finalv} parsed as integer from {élet::%player%}
                send "%{élet::%player%}% h"
                set maximum health of player to {élet::%player%}/2
 
You can add a wait 1 second or wait 10 ticks or something.
already tried that, didn't work
[doublepost=1587838103,1587808867][/doublepost]
already tried that, didn't work

got it working with this:


Code:
on armor equip:
    if event-item is any helmet:
        set {_slot} to 100
    if event-item is any chestplate:
        set {_slot} to 101
    if event-item is any leggings:
        set {_slot} to 102
    if event-item is any boots:
        set {_slot} to 103
    if {found.%{_slot}%::%player%} isn't true:
        if "%lore of event-item%" contains "Védelem" or "Élet":
            set {_lore::*} to lore of event-item
            loop {_lore::*}:
                if {_lore::%loop-index%} contains "Védelem":
                    set {_védeleml} to {_lore::%loop-index%}
                    set {_védelemsl::*} to {_védeleml} split at " "
                    set {_védelemy::*} to {_védelemsl::2} split at "+"
                    set {_finalv} to {_védelemy::2}
                    add {_finalv} parsed as integer to {defense::%player%}
                if {_lore::%loop-index%} contains "Élet":
                    set {_életl} to {_lore::%loop-index%}
                    set {_életsl::*} to {_életl} split at " "
                    set {_élety::*} to {_életsl::2} split at "+"
                    set {_finalv} to {_élety::2}
                    add {_finalv} parsed as integer to {élet::%player%}
                    set maximum health of player to ({élet::%player%}/2)+{path.prestige::%player%}
            set {found.%{_slot}%::%player%} to true

on armor unequip:
    if event-item is any helmet:
        set {_slot} to 100
    if event-item is any chestplate:
        set {_slot} to 101
    if event-item is any leggings:
        set {_slot} to 102
    if event-item is any boots:
        set {_slot} to 103
    if {found.%{_slot}%::%player%} isn't false:
        if "%lore of event-item%" contains "Védelem" or "Élet":
            set {_lore::*} to lore of event-item
            loop {_lore::*}:
                if {_lore::%loop-index%} contains "Védelem":
                    set {_védeleml} to {_lore::%loop-index%}
                    set {_védelemsl::*} to {_védeleml} split at " "
                    set {_védelemy::*} to {_védelemsl::2} split at "+"
                    set {_finalv} to {_védelemy::2}
                    subtract {_finalv} parsed as integer from {defense::%player%}
                if {_lore::%loop-index%} contains "Élet":
                    set {_életl} to {_lore::%loop-index%}
                    set {_életsl::*} to {_életl} split at " "
                    set {_élety::*} to {_életsl::2} split at "+"
                    set {_finalv} to {_élety::2}
                    subtract {_finalv} parsed as integer from {élet::%player%}
                    set maximum health of player to ({élet::%player%}/2)+{path.prestige::%player%}
            set {found.%{_slot}%::%player%} to false
 
Status
Not open for further replies.