Item in 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 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.

Aberforth

Member
Jun 14, 2019
40
2
8
Canada
Hello,

I'm trying to test for an item with a specific name in a specific slot.

Code:
if slot 4 of {_p} is item with name "%{_t}%":

It's a function where the player is stored in {_p} and the name of the item is stored in {_t}. However, when reloading, I get: you cannot use clicked item expression in any event but an inventory click.

I don't think I used clicked item? Is there any other way? Help?
 
Give us the whole code...
Are you sure the error is related to this specific line that you have given us?
I think it can look like:
Code:
set {_item} to slot 4 of current inventory of {_p}
if name of {_item} contains "%{_t}%":
    #do your stuff
 
My code is very complicated and full of variables, so I doubt it will help.

In short: I want to place an item with a specific name in slot 5 of player, but only if the item in slot 4 has a different name.

So I have:

Code:
set {_item} to slot 4 of current inventory of {_p}
            if name of {_item} contains "%{_t}%":
                send action bar "&7%{_t}% is already in Quick Slot 1" to {_p}
            else:
                execute console command "/replaceitem entity %{_p}% slot.hotbar.5 %{_mcid}% %{_dataid}% {display:{Name:""%{_t}%""},Unbreakable:1,HideFlags:4}"
                send action bar "&7%{_t}% is now in Quick Slot 2" to {_p} 
                stop

Where {_p} is the player, {_t} is the name of the item, {_mcid} is the ID of the item, {_dataid} is the amount and data ID of the item.
I used the code that you gave me. Now it doesn't show errors, but it still does not work = it lets me place the item in slot 5 even though I already have an item with the same name in slot 4.
 
Status
Not open for further replies.