Locking a slot

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

JackyBoy

Member
Feb 4, 2017
104
1
18
21
Hey there, is there a way to lock a slot so that players are unable to move an item from that slot
 
code_language.skript:
[on] (hotbar|held [(item|slot)]|inventory slot) (switch|change):
The event called when a player switches slots by scrolling or pressing the keypads to move inventory items.

code_language.skript:
[on] [player['s]] (tool|item held|held item) chang(e|ing):
Called whenever a player changes his held item by selecting a different slot (e.g. the keys 1-9 or the mouse wheel), not by dropping or replacing the item in the current slot.

I never tried to see if cancel event works :\
 
code_language.skript:
[on] (hotbar|held [(item|slot)]|inventory slot) (switch|change):
The event called when a player switches slots by scrolling or pressing the keypads to move inventory items.

code_language.skript:
[on] [player['s]] (tool|item held|held item) chang(e|ing):
Called whenever a player changes his held item by selecting a different slot (e.g. the keys 1-9 or the mouse wheel), not by dropping or replacing the item in the current slot.

I never tried to see if cancel event works :\
Along with those, also use the inventory click event. You can detect a specific slot and cancel the event
 
Have you looked at the examples in the documentation?
Cancelling an event is very simple:
code_language.skript:
on such and such event:
    cancel event
Thanks but I dont understand this part [on] (hotbar|held [(item|slot)]|inventory slot) (switch|change):
 
Thanks but I dont understand this part [on] (hotbar|held [(item|slot)]|inventory slot) (switch|change):
That's an event for when an item is switched on the hotbar with another item. So if they swapped an item from their hotbar to say, the slot you want to lock in their inventory.
[doublepost=1514993270,1514993137][/doublepost]I can't test atm, but it may look something like this:
code_language.skript:
on hotbar inventory slot switch:
    if event-slot is 15:
        cancel event
Again, can't test but that's the gist of it.
 
Status
Not open for further replies.