Solved On death of wolf, message owner.

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

Zach R

New Member
Mar 10, 2022
7
1
3
25
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:
on rightclick holding a emerald:
    if name of event-item is "&eGrowling Egg":
        if {wolf.%player%} is true:
            send "&cWolf has already been summoned."
        if {wolf.%player%} is not set:
            set {wolf.%player%} to true
            spawn a wolf at player
            #tame the last spawned entity to the player
            ##^requires SkQuery, so ignore for now.


on death of wolf:
    #clear {wolf.%player%} from victim's owner
    ##this line doesn't exist. Ideas?
 
Try this, don't tested:
Code:
on rightclick holding a emerald:
    if name of event-item is "&eGrowling Egg":
        if {wolf.%player%} is true:
            send "&cWolf has already been summoned."
        if {wolf.%player%} is not set:
            set {wolf.%player%} to true
            spawn a wolf at player
            set {_ent} to last spawned entity #need SkBee
            add "{custom:{owner:""%player%""}}" to nbt of {_ent} #need SkBee

on death of wolf:
    set {_nbt} to nbt compound of event-entity #need SkBee
    set {_p} to tag "custom;owner" of {_nbt} #need SkBee
    if {_p} is not null:
        set {wolf.%{_p} %} to false
        send "You can spawn a wolf again!" to {_p}
 
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:
on rightclick holding a emerald:
    if name of event-item is "&eGrowling Egg":
        if {wolf.%player%} is true:
            send "&cWolf has already been summoned."
        if {wolf.%player%} is not set:
            set {wolf.%player%} to true
            spawn a wolf at player
            set {_ent} to last spawned entity #need SkBee
            add "{custom:{owner:""%player%""}}" to nbt of {_ent} #need SkBee
 
on death of wolf:
    set {_nbt} to nbt compound of event-entity #need SkBee
    set {_p} to tag "custom;owner" of {_nbt} #need SkBee
    if {_p} is not clear:
        clear {wolf.%{_p} %}
        send "You can spawn a wolf again!" to {_p}
 
  • Like
Reactions: MrNygus
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:
on rightclick holding a emerald:
    if name of event-item is "&eGrowling Egg":
        if {wolf.%player%} is true:
            send "&cWolf has already been summoned."
        if {wolf.%player%} is not set:
            set {wolf.%player%} to true
            spawn a wolf at player
            set {_ent} to last spawned entity #need SkBee
            add "{custom:{owner:""%player%""}}" to nbt of {_ent} #need SkBee
 
on death of wolf:
    set {_nbt} to nbt compound of event-entity #need SkBee
    set {_p} to tag "custom;owner" of {_nbt} #need SkBee
    if {_p} is not clear:
        clear {wolf.%{_p} %}
        send "You can spawn a wolf again!" to {_p}
Hey, while this may be weird, it is better to put your variables into a :: instead of . since it's more efficient.
 
Status
Not open for further replies.