Solved Potion effects

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

Blobbyguy

Member
Feb 2, 2017
25
0
0
Bloblandia
I need a way to apply a potion effect while a player is wearing/holding an item.
The issue I am having is the effect in skript stacks the time so if a player has 1 second left on their potion, and then you apply potion effect for 1 second. It actually applies for two seconds. This means if the player wears the item for a long time, this leftover time builds up.

Essentially what I'm looking for is a way to "Update" the time left on the potion every second. E.g.
Set duration of potion effect on player to 1 second.

I tried using the /effect command but it seems very inefficient to me to be using it every second on however many players are wearing an item.
 
There is no code to give? The total code right now is
Every 1 second:
Player is wearing helmet
Apply potion effect for 2 second

But it's just stacking up instead of applying for 2 second
(Total potion time = remaining time + 2 second)
I want it to be total potion time = 2 second
 
It's not exact though, that's my issue. In doing that it either still stacks up the slightest bit every 2 seconds or the potion effect wears off for a millisecond causing a blinking effect.
 
this would be 100000000000000x easier with an on armor equip event. something like this should work:
code_language.skript:
every second:
    loop all players:
        if loop-player is wearing a helmet:
            if {wearing_helmet::%loop-player%} is false:
                set {wearing_helment::%loop-player%} to true
                apply swiftness to loop-player for 9999 days
        else:
            if {wearing_helmet::%loop-player%} is true:
                set {wearing_helmet::%loop-player%} to false
                remove swiftness from the loop-player
 
The problem with on armor equip events is there's so many events to cover. There's armor breaking, unequiping, equiping, and there's other commands I have that modify the users armour.
 
The problem with on armor equip events is there's so many events to cover. There's armor breaking, unequiping, equiping, and there's other commands I have that modify the users armour.
You could use the packet event that is sent whenever someone's armour/held item changes, but that would only work if someone could see that player. Alternatively, if you use the set slot packet (in the armor slots) and armor equip event both combined should cover any possibilities, or something like
code_language.skript:
on armor equip:
  if event-item is iron chesplate:
    apply speed to player for 9999 days
    while player's chesplate is iron chestplate:
      wait 1 tick
    remove speed from player
 
  • Like
Reactions: Blobbyguy
Status
Not open for further replies.