#Offhand slot

1 messages · Page 1 of 1 (latest)

elder sandal
#

what slot number is the offhand slot, like im trying to do:

on inventory click:
  if event-slot is offhand slot:
    do something
#

I just need help with the offhand slot part

sacred canopy
#

offhand slot is slot 45 of the player's inventory

#

try if event-slot = 45?

#

sorry, 40

on inventory click:
    if index of event-slot = 40:

@elder sandal

#

event-slot itself is just the item IN the slot, not the slot itself

elder sandal
#

yeah ik

#

alr that worked

#

but

#

its not what i wanted

#

lets say i got a stick in my hotbar

#

then opened my inventory

#

then clicked on the stick and dragged it to the offhand slot then clicked there

#

how do i detect that the player clicked on the offhand slot

#

@sacred canopy

sacred canopy
#

the same code should work with that though? if you want to check if the player puts an item in the offhand through the inventory, itll call a check to the original slot it was in AND when you put it in the offhand slot

#

ofc itll only fire when put IN the slot, since thats when the event-slot is the offhand

elder sandal
sacred canopy
#
on inventory click:
    if index of event-slot = 40:
        send "you put it in the offhand."

this'll also trigger when theyre not holding anything, keep that in mind

#

i just shut down my server so i can't actively test this snippet, but this should also check if the player is holding any item while clicking the off hand slot:

on inventory click:
    if all:
      index of event-slot = 40
      cursor slot of player is not air
    then:
        send "you put it in the offhand."

https://skripthub.net/docs/?id=982

elder sandal
#

would it also fine if i was on a chest

#

or another thing

sacred canopy
#

well, if you open any inventory that is not your own, typically you wont have access to your offhand slot

elder sandal
#
on inventory click:
    if all:
        index of event-slot is 40
        cursor slot of player is not air
    then:
        if event-item is stick:
            broadcast "yes"
#

this is the problem

#

i have a stick on my hotbar

#

clicked it

#

and draged to the offhand slot

#

then clicked the offhand slot

#

after that

#

it does'nt broadcast "yes"

sacred canopy
#

do cursor slot instead of event-item since event-item IS the item currently in the slot, whilst cursor slot is the item youre dragging over there

elder sandal
#
on inventory click:
    if all:
        index of event-slot is 40
        cursor slot of player is not air
    then:
        if cursor slot is stick:
            broadcast "yes"
#

so like this?

sacred canopy
#

that should work

elder sandal
sacred canopy
#

maybe try (cursor slot of player)?

elder sandal
#

of player

#

yeah

#

nice

#

thanks man