How do i check if a player's inventory contains a named item like a diamond named "Test".
i want there to happen somthing if the player has the item and another if he doesn't
i search in google and found this but it didn't work when i added named "Test"
set {_inv} to player's inventory if {_inv} doesn't contains diamonds: message "&c» &7You do not have any &bDiamonds&7!" stop if {_inv} contains diamonds: set {_diamonds} to amount of diamonds in {_inv}
#Player's inventory contians a named item
1 messages · Page 1 of 1 (latest)
if player has diamond named "among us":```
so instead i should just write
if player has diamond named "test":
how do i check if he doesn't have a diamond
if player does not have a diamond named "test"
That doesn't work it always do the command as if i have the diamond even thought i don't
if player doesn't have 1 diamond:
send "&c» &7You do not have any &bDiamonds&7!"
else:
set {_diamonds} to amount of diamonds in player's inventory
send "&a» &7You have %{_diamonds}% diamonds!"```
you could try setting the item you are looking for before checking for it
set {_diamondwithname} to diamond named "Test"
if player has 1 {_diamondwithname}:
oh i see
if player has 1 diamond:
set {_diamonds} to amount of diamonds in player's inventory
send "&a» &7You have %{_diamonds}% diamonds!"
else:
send "&c» &7You do not have any &bDiamonds&7!"```
This works but not if i add a named
Uuuh I know what could cause the issue
I think when renaming items on the anvil or by using a rename plugin it adds &r before the name
so you'd have to check for diamonds first, then check all of these separately if the name contains the string you are looking for
no this doesn't seem to fix it i tried it
if player has 1 diamond named "&rtest":
what seems to be the issue
What mc version are you on?
1.19.2
im trying to check if the player has a named item in there inventory
I've got something that works on 1.16, let me get it real quick, maybe it still works on later versions
And player has diamond named "&rtest" does not work?
no
it doesnt say a mistake but nothing happends
I'm guessing it's because there's an invisible extra in the name. Like color codes etc.
There might not even be a &r in the name
i tried that too
That wasn't my point
ooh
it matches color codes exactly
Could you send a screenshot of the item's name?
You might have '&f' instead of '&r' accidentally
yeah that might be a &r&n (I think it's n) in front
That doesn't have any color codes at all
i know
That's probably diamond named "test"
i tried that
test
Well there's almost definitely the issue with the name here so...
give yourself diamond named "&9TEST" using effect command and then debug
That worked i guess it just didn't work if it was renamed normally
That shouldn't be the case tho... I just tried the same thing myself, and when renaming in an anvil, it would just not have color codes at all
Weird
do you have a plugin for making colored names i anvils?
You can just make a command for renaming items with color. It's actually fairly easy
i could