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!

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

Help with killing named entities

Discussion in 'Requests' started by Cupcaeke, Jun 16, 2022.

Tags:
  1. Cupcaeke

    Cupcaeke Member

    Joined:
    Jun 16, 2022
    Messages:
    1
    Likes Received:
    0
    Hi there! This is my first post here so apologies if I don't have the rules quite under my belt yet.

    I am making a kit in a 1.8.9 kitpvp server that summons named wolves with a bone, and I wanna make it so the wolves are killed :emoji_slight_smile:<) when the player dies or has their inventory cleared (I have it so selecting another kit also clears the inventory of a player). I have the spawning of the wolves down, but I just can't figure out how to kill them. I have tried a bunch of different things, but to no avail so far. Here is what I currently have:

    Code (Script):

    -on rightclick with a bone:
    - name of player's tool is "&rDog Whistle"
    - spawn a wolf 1 meter above the targeted block
    - tame last spawned wolf to player
    - heal last spawned wolf
    - set the last spawned wolf's name to "&a%player%'s Wolf"
    - spawn a wolf 1 meter above the targeted block
    - tame last spawned wolf to player
    - heal last spawned wolf
    - set the last spawned wolf's name to "&a%player%'s Wolf"
    - spawn a wolf 1 meter above the targeted block
    - tame last spawned wolf to player
    - heal last spawned wolf
    - set the last spawned wolf's name to "&a%player%'s Wolf"

    -on death:
    - if name of a wolf is "&a%player%'s Wolf"
    - kill wolf

    -on command "/cleareverything":
    - if name of a wolf is "&a%player%'s Wolf"
    - kill wolf
     
  2. HyperOmar10

    HyperOmar10 Member

    Joined:
    Jun 18, 2022
    Messages:
    2
    Likes Received:
    0
    You can prob add them to a list when you spawn them and when the player dies kill everything in the list then remove/delete the list
     
  3. Kapo

    Kapo New Member

    Joined:
    Jun 18, 2022
    Messages:
    9
    Likes Received:
    2
    As my predecessor said
    Keep in mind saving entities in lists is not recommended as the variables will be wiped when the server restarts.
    What you could do instead is save an entity's uuid and parse it as an entity type and then work with that.

    add this under your on rightclick event
    Code (Text):
    1. set {_x} to uuid of last spawned wolf parsed as entity
    2. add {_x} to {wolf::%player%::*}

    replace this
    Code (Text):
    1. if name of a wolf is "&a%player%'s Wolf"
    2. kill wolf

    with this

    Code (Text):
    1. on death:
    2.     loop {wolf::%victim%::*}:
    3.         kill loop-value
    You can't use wolf under command or damage related events, use victim (damage receiver or killed entity) and attacker (damage dealer or the killer) for on damage: and on death:.
    Since only players and the console can execute commands, you can't use entities inside command related events either: instead you'll most of the time have to work with loops as shown below.


    Code (Text):
    1. on command "/cleareverything":
    2.     loop {wolf::%player%::*}: #this is the loop we used before
    3.         kill loop-value

    or without the loop

    Code (Text):
    1. on command "/cleareverything":
    2.     loop all wolves:
    3.         if name of loop-entity = "&a%player%'s Wolf":
    4.             kill loop-entity
     

Share This Page

Loading...