Trade problem

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

    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.

Raigna

Member
Oct 2, 2017
17
0
0
36
addons installed
Skrayfall
skquery

----
Hi

ive been trying to make a shop where players can trade in custom items for rewards, everything works so far except this line of text in the script,

code_language.skript:
command /mysteriumsword:
    trigger:
        if player has 1 player head named "&b&lM&3&lysterium" in inventory:
            remove 1 player head named "&b&lM&3&lysterium" from player's inventory
            make player execute command "/mm i get Mysterium_Sword"
        else:
            message "&3Sorry you dont have enough"
            stop

the problem im having is that the item im using to trade with is a players head and it also wont recognise the item with lore, if i remove the lore and change the item to a nether star for example it works perfectly

here is a picture of the lore

thanks in advance for any help
2017-11-16_02.19.18.png
 
Try this

code_language.skript:
command /mysteriumsword:
    trigger:
        if name of player's held item contain "&b&lM&3&lysterium":
            remove player's held item from player
            make player execute command "/mm i get Mysterium_Sword"
        else:
            message "&3Sorry you dont have enough"
            stop
 
thanks but im not sure if this is exactly what im looking for, would this not only work on the item in your hand? I want to locate and remove it from anywhere in your inventory, the script is part of a larger script that im using as a gui shop

I'll try it anyways and i appreciate the time you took to help me
:emoji_slight_smile:
 
This is an issue with how Skript handles item comparisons. When you are checking if they have "1 player head named <name>", the plugin checks for that very specifically: a plain player with that name. It can't have any other NBT data or else the statement will fail. Annoying, I know.

Instead, change your code to loop over the items in their inventory, and then check both of those things separately:
code_language.skript:
loop items in player's inventory:
    loop-item is a player head
    loop-item's name is <name>
    <do stuff>
 
Status
Not open for further replies.