Solved How to give an item with custom id/attribute to the player

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

Samuelpc180

New Member
Mar 11, 2022
9
1
3
15
Basically, I want to give an item to the player with like an id "gen" and later on when the player right-clicks with that item, it checks if it has the id "gen" and if it does it will do stuff but if it doesn't, it will just ignore it.

Code:
command /gen:
    trigger:
        give wooden axe with id "gen" to player

on right click with wooden axe:
    if player's tool's id is "gen":
        cancel event
        # do stuff
 
I made 3 options, don't tested:
Code:
command /gen:
    trigger:
        set {_item} to 1 wooden axe named "Name" with lore "Description"   #1 and 2
        give {_item} to player
        #3
        set {_item2} to 1 wooden axe
        add "{custom:{owner:""%player%""}}" to nbt of {_item2}    #need SkBee

on right click with wooden axe:
    if player's tool's name is "Name":  #1
        cancel event
    if player's tool's lore is "Description":  #2
        cancel event
        # do stuff
    #3
    set {_nbt} to nbt compound of player's tool's #need SkBee
    set {_p} to tag "custom;owner" of {_nbt} #need SkBee   
    if {_p} is "%player%": 
        cancel event
        # do stuff
 
  • Like
Reactions: Samuelpc180
I made 3 options, don't tested:
Code:
command /gen:
    trigger:
        set {_item} to 1 wooden axe named "Name" with lore "Description"   #1 and 2
        give {_item} to player
        #3
        set {_item2} to 1 wooden axe
        add "{custom:{owner:""%player%""}}" to nbt of {_item2}    #need SkBee

on right click with wooden axe:
    if player's tool's name is "Name":  #1
        cancel event
    if player's tool's lore is "Description":  #2
        cancel event
        # do stuff
    #3
    set {_nbt} to nbt compound of player's tool's #need SkBee
    set {_p} to tag "custom;owner" of {_nbt} #need SkBee  
    if {_p} is "%player%":
        cancel event
        # do stuff
It worked when I replaced the "custom;owner" with "tag;custom;owner", thanks!
 
  • Like
Reactions: MrNygus
Status
Not open for further replies.