Inventory Slot Canceling

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

BrownMee

Active Member
Apr 16, 2018
126
6
18
I wanna make that some slot in inventory cannot be used. It's like custom inventory.
Custom max inventories.

How do i do it?
 
You could use TuSKe and do it like this:

code_language.skript:
open virtual chest inventory named "test" with 3 rows to player

format gui slot 10 of player with 5 of stone to do nothing

# or the other way around, for more complex stuff

create a gui with virtual chest inventory named "test" with 3 rows:

  format next gui with 3 of stone named "test" to do nothing
open last gui to player

# Learn more about this system here:  https://github.com/Tuke-Nuke/TuSKe/wiki/GUI-Manager

Or with vanilla Skript (bensku's fork), in this way:
code_language.skript:
open chest inventory named "test" with 3 rows to player

set slot 3 of current inventory to 3 of stone named "test"

on inventory click:

  if display name of event-inventory is "test":
    cancel event
 
So I wanna make something like this:

On pickup any item
The item won't goes to slot 14-16
Because it's a restricted slot
Player can only store their stuff from slot 0-13
Others are locked
[doublepost=1524471353,1524420020][/doublepost]Help?
[doublepost=1524556226][/doublepost]This is really important can anyone actually help me?
 
You'd need a more advanced solution for this where you handle pickup events yourself since there isn't any way to actually lock slots. The basic logic would be something like:

1. Listen for pickup events and loop through the slots in the user's inventory by number.
2. Store all of the "unlocked" slot numbers that are available (don't contain an item) in a list.
3. Cancel the pickup event. If the size of the unlocked available slot list is 0, do nothing (there are no valid slots so they shouldn't pick up the item). Otherwise, fill the first available slot number (first element in the list) with the items from the dropped item, and delete the dropped item.
 
You'd need a more advanced solution for this where you handle pickup events yourself since there isn't any way to actually lock slots. The basic logic would be something like:

1. Listen for pickup events and loop through the slots in the user's inventory by number.
2. Store all of the "unlocked" slot numbers that are available (don't contain an item) in a list.
3. Cancel the pickup event. If the size of the unlocked available slot list is 0, do nothing (there are no valid slots so they shouldn't pick up the item). Otherwise, fill the first available slot number (first element in the list) with the items from the dropped item, and delete the dropped item.

Ah finally someone gives me some actual good solution for it. Thanks!
 
Status
Not open for further replies.