#Prevent Item Stealing From Gui

1 messages · Page 1 of 1 (latest)

fiery lily
#

I am trying to check if a player is trying to steal from the following gui but the issue is that the gui is named using arg-1 . How can I prevent stealing?

command /stats <offlineplayer>:
 trigger:
   set {_p} to arg-1
   open chest with 3 rows named "&b%arg-1%'s Stats" to player
   wait 1 tick
   format slot 13 of player with skull of {_p} named "%arg-1%"
   set slot set slots (integers between 0 and 8) and (integers between 19 and 27) to gray stained glass pane named ""


on inventory click:
    if event-inventory = ```
#

Idk what to put in the
if event-inventory =

#

because the gui is named using arg-1

sterile oriole
#

What I would recommend is giving the items in the gui a special nbt tag and then check if the clicked item has the nbt tag

#

For example:

set {_i} to dirt named “e”
set int tag “custom;guiItem” of nbt compound from {_i} to 1
set slot (slots) of gui to {_i}
#

And then you could detect it by checking the tag

on inventory click:
      if int tag “custom;guiItem” of nbt compound from event-item is set:
           broadcast “%player% is stealing gui items!”
#

Indentation is kinda bad cuz I’m on my phone but you get the idea

fiery lily
#

ye

#

hmm

#

I have a better idea

#

I will just make the name of the gui not use %arg-1% (:

sterile oriole
#

Or that

vernal portal
#

one other method:

  1. Set a variable (or metadata) to the gui
  2. Set the slots of the gui associated with the variable
  3. Open the variable to the player
  4. On inventory click, check if the event-inventory is the variable
final mauve
final mauve