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.

Deleted an entity

Discussion in 'Skript' started by Goetheus, Feb 22, 2017.

Thread Status:
Not open for further replies.
  1. Goetheus

    Goetheus Guest

    Hi guys!

    I would like to delete (and not kill) an entity.
    Before updates, I used this, i.e. :

    Code (Skript):
    1. set {_entity} to target entity
    2. delete entity from {_entity}
    Now, this syntaxe don't work. How can I proceed?

    I noticed that syntaxe works :
    Code (Skript):
    1. delete loop-entity
    But not these :
    Code (Skript):
    1. delete targeted entity
    2. delete target entity
    3. delete target
    Thank you for help!
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    You could try teleporting the entity into the void and then killing it
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    You should change your name from TheBukor to TheButcher :emoji_grinning:

    If I don't find any other solution... Why not.
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    What's the difference for you ?
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Deleting an entity makes it disappear immediately.

    Killing an entity makes it drop the items, perform the death animation and play cloud particles effect when the animation is done.
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    When you kill an entity, there are animation, sounds and drop items.
    When you delete an entity, it disappear instantly without animation, sounds or drop.

    EDIT : Oops, too slow ^^'
    --- Double Post Merged, Feb 22, 2017, Original Post Date: Feb 22, 2017 ---
    Hi guys!

    I noticed that "kill target entity" = "delete target entity" O_o

    I'm in 1.11.2 with Umbaska, Skellett, SkStuff, SharpSk, SkRayFall, MundoSk, SkQuery, skUtilities, and TuSke.
    Before, it was different, and today "delete target entity" generate an error in console...

    So ! For now, I would like to know how to really kill an entity (with animation, drops...).

    Thank you!

    EDIT 2 or 3, I don't know :
    When you write this:
    Code (Skript):
    1. set {_entity} to target
    2. Kill {_entity}
    The entity is killed (animation + drop).

    The problem is, if you write this:
    Code (Skript):
    1. set {_entity} to target
    2. delete {_entity}
    Nothing happen...

    Help me :'(
     
    #6 ShaneBee, Feb 22, 2017
    Last edited by a moderator: Feb 22, 2017
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    I'm not sure that this is the best solution but I went ahead and came up with a ghetto fix I suppose, it does require SkStuff for nbt but I see you have it, I haven't tested it but I have a variation of this on my server so I'm pretty sure it works as I only changed a few things, also I did get a little confused as to what it is you want after reading the rest of your posts but assuming you still want what you wrote in the original post the following should be a solution

    Code (Skript):
    1. function despawnentity(e: entity):
    2.   add "{NoDrops:1}" to nbt of {_e}
    3.   teleport {_e} 1000 blocks above {_e}
    4.   wait 1 tick
    5.   kill {_e}
    6. On death:
    7.   if tag "NoDrops" of nbt of victim is 1:
    8.     clear drops
    EDIT:
    I've tested it using the following code and it works like a charm:
    Code (Skript):
    1. on right click on entity:
    2.   despawnentity(clicked entity)
    Edit 2:
    Oh gawd, something is wrong, after some more testing I found out the drops are not being cleared, this must be something to do with the nbt aspect of the code, looking into it...
    Edit 3:
    Okay I think the problem is that you can't add custom nbt to an entity, I know SkStuff has something to add custom nbt to an item so I just figured it would work on an entity too but I guess not, the reason the variation of code I use on my server works is because I'm not adding custom nbt to the entity instead I add "{CustomNameVisible:1}" to nbt of entity which is a real nbt tag, what that tag does is so that an animal's name will show above its head regardless of whether you're looking at it or not, here is the updated code with that tag
    Code (Skript):
    1.  
    2. function despawnentity(e: entity):
    3.   teleport {_e} 1000 blocks above {_e}
    4.   add "{CustomNameVisible:1}" to nbt of {_e}
    5.   wait 1 tick
    6.   kill {_e}
    7. On death:
    8.   if tag "CustomNameVisible" of nbt of victim is 1:
    9.     clear drops
     
    #7 ShaneBee, Feb 23, 2017
    Last edited by a moderator: Feb 23, 2017
    • Informative Informative x 1
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Interesting workaround! Thank you!

    Was so simply before the update with two lines...
    Why they change it?! :'(
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Nothing was changed in Skript.

    The "entity from %variable%" thing was from Umbaska 2

    It is intended for the following code to not delete the entity itself:
    Code (Skript):
    1.  
    2. on something:
    3.   set {_entity} to event-entity
    4.   delete {_entity}
    5.  
    Skript will delete the variable, not the entity that is contained in the variable.
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    We speak about this code:
    Code (Skript):
    1. set {_entity} to event-entity
    2. delete entity from {_entity}
    Which worked before 1.11 update.
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Yeah like TheBukor said "delete entity from {_entity}" was from umbaska 2, umbaska 3 probably doesn't have it
     
    • Like Like x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...