Solved Unable to cancel a player's inventory click event.

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

_PAPER_PLANE_

Member
Jan 21, 2022
42
0
6
I created a vanilla GUI with cancel event, but players can still place items from their inventory into the GUI and can't retrieve them anymore. I recall that in previous versions, it would cancel both the GUI and the player's inventory together. Is there a solution to this now?
skript 2.7.1
 
Sending the code would be very helpful!

Code:
on inventory click:
  name of event-inventory is "lmao"
  cancel event
  if event-inventory is not player's inventory:
    if clicked slot is 8:
      send "You clicked on slot 8!"
 
  • Like
Reactions: Luke_Sky_Walker
Sending the code would be very helpful!

Code:
on inventory click:
  name of event-inventory is "lmao"
  cancel event
  if event-inventory is not player's inventory:
    if clicked slot is 8:
      send "You clicked on slot 8!"
Players can still place their items in the GUI as long as they use any code, including your code, even when using a cancellation event.
 
I created a vanilla GUI with cancel event, but players can still place items from their inventory into the GUI and can't retrieve them anymore. I recall that in previous versions, it would cancel both the GUI and the player's inventory together. Is there a solution to this now?
skript 2.7.1
I had the same issue with a GUI of mine. The easiest way you can fix this is having the slot occupied by an existing item with a cancel event attached to it. That way even if a player tries to shift click, it won’t work since the slot is occupied. You could also try something more complicated and check if the slot that a player could shift click isn’t air and cancel event when it’s changed (Ie: If an empty slot isn’t air, cancel the event).
 
I had the same issue with a GUI of mine. The easiest way you can fix this is having the slot occupied by an existing item with a cancel event attached to it. That way even if a player tries to shift click, it won’t work since the slot is occupied. You could also try something more complicated and check if the slot that a player could shift click isn’t air and cancel event when it’s changed (Ie: If an empty slot isn’t air, cancel the event).
I never had this issue. It might just be a bug with the current Skript version.
 
I've noticed that when using
Code:
metadata tag "GUI" of player
the cancel event for the player's inventory doesn't work. However, if you use
Code:
name of event-inventory is "GUI"
it can effectively prevent clicking on player inventory items.