Set inventory slot deletes current selected item

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

    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.

blab2bruh

Member
Oct 25, 2022
2
0
1
Skript Version: Skript 2.6-alpha1
Skript Author: blab2bruh
Minecraft Version: 1.17.1

Hi, I was making a skript that should block player's inventory except some slots. It works well, but when i try to pick an item from inventory, that item disappears.

Full Code:
Code:
every 0.1 second in "world":
    loop all players:
        if loop-player does not have permission "op.op":
            baninv(loop-player, 4, 9)
function baninv(player: player, slots: number, upslots: number):
#hotbar slots
    loop 9 times:
        if {_slots} < loop-value:
            if slot loop-value -1 of {_player} != air or barrier:
                drop slot loop-value -1 of {_player} at {_player}
            set slot loop-value -1 of {_player} to 1 of barrier named "&cClosed"
#inentory slots
    loop 27 times:
        if {_upslots} < loop-value:
            if slot loop-value +8 of {_player} != air or barrier:
                drop slot loop-value +8 of {_player} at {_player}
            set slot loop-value +8 of {_player} to 1 of barrier named "&cClosed"
Console Errors: no

Addons using (including versions):
Skirt 2.0.0, SkQuery 4.1.5, SkBee 1.15.0, SkJade 1.4.2, Skream 2.1

Troubleshooting: This skript works as intended, but when I pick item from inventory, it vanishes completely

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? None
 
Skript Version: Skript 2.6-alpha1
Skript Author: blab2bruh
Minecraft Version: 1.17.1

Hi, I was making a skript that should block player's inventory except some slots. It works well, but when i try to pick an item from inventory, that item disappears.

Full Code:
Code:
every 0.1 second in "world":
    loop all players:
        if loop-player does not have permission "op.op":
            baninv(loop-player, 4, 9)
function baninv(player: player, slots: number, upslots: number):
#hotbar slots
    loop 9 times:
        if {_slots} < loop-value:
            if slot loop-value -1 of {_player} != air or barrier:
                drop slot loop-value -1 of {_player} at {_player}
            set slot loop-value -1 of {_player} to 1 of barrier named "&cClosed"
#inentory slots
    loop 27 times:
        if {_upslots} < loop-value:
            if slot loop-value +8 of {_player} != air or barrier:
                drop slot loop-value +8 of {_player} at {_player}
            set slot loop-value +8 of {_player} to 1 of barrier named "&cClosed"
Console Errors: no

Addons using (including versions):
Skirt 2.0.0, SkQuery 4.1.5, SkBee 1.15.0, SkJade 1.4.2, Skream 2.1

Troubleshooting: This skript works as intended, but when I pick item from inventory, it vanishes completely

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? None
I don't really understand what's going on, but if i had to guess it might be because you're updating the player's inventory every 0.1 seconds so it resets the item that is 'picked' try to decrease the timer and check idk tbh
 
I don't really understand what's going on, but if i had to guess it might be because you're updating the player's inventory every 0.1 seconds so it resets the item that is 'picked' try to decrease the timer and check idk tbh
i don't understand what's going too, but function baninv() deletes cursor slot independent from every 0.1 sec trigger
 
Code:
on inventory click:
    if player doesn't have permission "op.op":
        if name of event-item is "&cClosed":
            cancel event
add this, regarding your issue contact me on discord after the 16th if you didn't find a solution yet, I tested out the skript and it worked perfeclty for me, it might be another skript messing with the items

disc: Knovius#3553
 
Status
Not open for further replies.