1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved On death of wolf, message owner.

Discussion in 'Skript' started by Zach R, Mar 10, 2022.

Thread Status:
Not open for further replies.
  1. Zach R

    Zach R New Member

    Joined:
    Mar 10, 2022
    Messages:
    7
    Likes Received:
    1
    Hey everyone,
    For context, I am trying to make an item that summon's a wolf. Once the wolf dies the item can be used again.

    However I am running into issues, when the wolf dies I need to be able to remove a tag from its owner, or message the owner, or if you have any answers how I can relate the wolf back to the player on death I suspect I can take it from there!

    Code (Text):
    1. on rightclick holding a emerald:
    2.     if name of event-item is "&eGrowling Egg":
    3.         if {wolf.%player%} is true:
    4.             send "&cWolf has already been summoned."
    5.         if {wolf.%player%} is not set:
    6.             set {wolf.%player%} to true
    7.             spawn a wolf at player
    8.             #tame the last spawned entity to the player
    9.             ##^requires SkQuery, so ignore for now.
    10.  
    11.  
    12. on death of wolf:
    13.     #clear {wolf.%player%} from victim's owner
    14.     ##this line doesn't exist. Ideas?
     
  2. MrNygus

    MrNygus Active Member

    Joined:
    Jan 28, 2017
    Messages:
    116
    Likes Received:
    2
    Try this, don't tested:
    Code (Text):
    1.  
    2. on rightclick holding a emerald:
    3.     if name of event-item is "&eGrowling Egg":
    4.         if {wolf.%player%} is true:
    5.             send "&cWolf has already been summoned."
    6.         if {wolf.%player%} is not set:
    7.             set {wolf.%player%} to true
    8.             spawn a wolf at player
    9.             set {_ent} to last spawned entity #need SkBee
    10.             add "{custom:{owner:""%player%""}}" to nbt of {_ent} #need SkBee
    11.  
    12. on death of wolf:
    13.     set {_nbt} to nbt compound of event-entity #need SkBee
    14.     set {_p} to tag "custom;owner" of {_nbt} #need SkBee
    15.     if {_p} is not null:
    16.         set {wolf.%{_p} %} to false
    17.         send "You can spawn a wolf again!" to {_p}
    18.  
    19.  
     
  3. Zach R

    Zach R New Member

    Joined:
    Mar 10, 2022
    Messages:
    7
    Likes Received:
    1
    Awesome! It works perfectly!
    Thank you so much for your response and the time you put into helping me out!
    For anyone else, I made one slight adjustment, as the "if {-p} is not null" wasn't working.
    Code (Text):
    1. on rightclick holding a emerald:
    2.     if name of event-item is "&eGrowling Egg":
    3.         if {wolf.%player%} is true:
    4.             send "&cWolf has already been summoned."
    5.         if {wolf.%player%} is not set:
    6.             set {wolf.%player%} to true
    7.             spawn a wolf at player
    8.             set {_ent} to last spawned entity #need SkBee
    9.             add "{custom:{owner:""%player%""}}" to nbt of {_ent} #need SkBee
    10.  
    11. on death of wolf:
    12.     set {_nbt} to nbt compound of event-entity #need SkBee
    13.     set {_p} to tag "custom;owner" of {_nbt} #need SkBee
    14.     if {_p} is not clear:
    15.         clear {wolf.%{_p} %}
    16.         send "You can spawn a wolf again!" to {_p}
     
    • Like Like x 1
  4. ryanrox333

    ryanrox333 Member

    Joined:
    Jul 6, 2019
    Messages:
    17
    Likes Received:
    0
    Hey, while this may be weird, it is better to put your variables into a :: instead of . since it's more efficient.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...