#Off Hand

1 messages · Page 1 of 1 (latest)

cyan agate
#

i am reading some old support and fixed it but how the hell do I remove it now.

cyan agate
#

effect

#
function executeBallCheck(p: player):
    if name of {_p}'s offhand item is "&4Iron Ball":
        apply infinite potion of strength of tier 2 without particles whilst hiding icon to {_p}
    else:
        remove potion of strength from {_p}

    if name of {_p}'s offhand item is "&9&lOcean Ball":
        apply infinite potion of water breathing of tier 1 without particles whilst hiding icon to {_p}
    else:
        remove potion of water breathing from {_p}

    if name of {_p}'s offhand item is "&a&lLucky Ball":
        apply infinite potion of luck of tier 2 without particles whilst hiding icon to {_p}
    else:
        remove potion of luck from {_p}

on swap hand items:
    wait 1 tick
    executeBallCheck(event-player)

on inventory slot change:
    if index of event-slot is 40:
        wait 1 tick
        executeBallCheck(player)

on join:
    wait 1 tick
    executeBallCheck(player)

every 2 seconds:
    loop players:
        executeBallCheck(loop-player)
#

it does not remove effect

cyan agate
#

i will try to use command to remove

patent mango
#

okay, because idk

cyan agate
#
function executeBallCheck(p: player):
    if name of {_p}'s offhand item is "&4Iron Ball":
        apply potion of strength of tier 2 without particles whilst hiding icon to {_p} for 3 ticks

    if name of {_p}'s offhand item is "&9&lOcean Ball":
        apply potion of water breathing of tier 1 without particles whilst hiding icon to {_p} for 3 ticks

    if name of {_p}'s offhand item is "&a&lLucky Ball":
        apply potion of luck of tier 2 without particles whilst hiding icon to {_p} for 3 ticks

every 1 tick:
    loop players:
        executeBallCheck(loop-player)

on swap hand items:
    wait 1 tick
    executeBallCheck(event-player)

on inventory slot change:
    if index of event-slot is 40:
        wait 1 tick
        executeBallCheck(player)

on join:
    wait 1 tick
    executeBallCheck(player)
#

this works but can someone optimize this

cyan agate
#

bro

#

this just

#

give effect forever if you put the item in your offhand

dry sail
#

Uhh

#

Because it gives the effect to the person forever?

#

U loop every tick

#

And give the effect to the person

#

For 3 ticks

meager dove
#

what is the point in doing the periodical + all these other events

rain jackal
#

please use on hand item swap: and give/remove the infinite duration potion

cyan agate
#

i did

#

but infinite does not get removed

meager dove
#

because ur not doing anything to remove it

cyan agate
#

it is not in that code

#

i removed it

#

it was not removing it

#

if I used commands, it will spam the thing

#

i rewrote the code

#

and now it works

#

I am sending it here, someone can use it or use for referense

rain jackal
#

what is all this periodical nonsense?

#

all you need is on join: / on hand item swap:, and then apply infinite potion effects. And remove the effects on hand item swap: when they un-equip the item

#

also I really bet you could refactor this to be a lot cleaner. Something like set {_sapling} to type of event-block while type of event-block == {_sapling}: #run while still a sapling not a tree trunk #apply bonemeal

#

hell, there's even a tree effect you could probably work into this

cyan agate
#

i am new to this bro

#

and i su** at varibles

rain jackal
#

oh boy im blind

#

this is AI code too isnt it

#

oh yeah--especially since half the code is commented and half isnt