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.

Delete NPCs by name?

Discussion in 'Skript' started by YourMCAdmin, Mar 26, 2017.

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

    YourMCAdmin Member

    Joined:
    Jan 31, 2017
    Messages:
    18
    Likes Received:
    0
    Skript Version:2.2-dev23
    Skript Author:Bensku
    Minecraft Version:1.11.2


    Other plugins used:
    Skellett
    Citizens
    (all up to date)
    ---
    I have spawned in an NPC with the following code:
    Code (Skript):
    1.  
    2. set {_npc} to a npc with name "%player%'s NPC" and entity type "WITCH"
    3. spawn npc {_npc} at {_npcSpawnLoc}
    4.  
    NPC spawns fine and dandy.
    I cannot for the life of me figure out how to remove the NPC without using Citizens' commands directly. I don't want to despawn the NPC, but I want to completely delete/remove it. There isn't much information on this in the docs or the forums here. And the docs aren't quite up to date for Skellett and Citizens. I had to figure out some of the stuff by searching the forums here.

    I have tried:
    Code (Skript):
    1.  
    2. command /bye:
    3.     trigger:
    4.         set {_npc} to a npc with name "%player%'s NPC" and entity type "WITCH"
    5.         remove npc {_npc}
    6.  
    It doesn't throw any errors. But this doesn't do anything except for create another NPC with an identical name.

    All I see in the docs is:
    "(despawn|remove) (npc|citizen) %npc% [with [despawn] reason %-despawnreason%]"
    Adding a despawn reason throws a "Can't understand this condition/effect" error. Unless the despawn reason must be something specific? But still, I don't want to despawn, I want to delete.


    Any ideas? I hope you folks may be able to help! Possibly @LimeGlass may be able to weigh in?

    Thanks!!! :emoji_grinning:


    Have you tried searching the docs? Yes
    Have you tried searching the forums? Yes
    What other methods have you tried to fix it? Crying into my pillow. As well as trying to use SkRayFall in conjunction with skellett
     
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Code (Skript):
    1. (delete|unregister) (npc|citizen) %npc%
    All of Skellett's syntax are generated in a file called Syntax.yml found at plugins/Skellett/Syntax.yml which contains every registered syntax. That is enabled.

    You can also delete all npc's too if you need
    Code (Skript):
    1. (delete|unregister|remove) (the|all) [of] [the] (npcs|citizens)
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Thanks for the reply :emoji_slight_smile:
    Unless I'm doing something wrong, I can't get it to delete.

    Code (Skript):
    1. command /hi:
    2.     trigger:
    3.         set {_npc} to a npc with name "%player%'s NPC" and entity type "WITCH"
    4.         spawn npc {_npc} at player
    5.  
    6. command /bye:
    7.     trigger:
    8.         set {_npc} to a npc with name "%player%'s NPC" and entity type "WITCH"
    9.         send "test 1"
    10.         unregister citizen {_npc}
    11.         send "test 2"
    Both of my test messages fire. No errors. But the NPC still exists. Hrmmm... Am I doing something wrong?
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    I will test it out. You can also get the entity from the disgusie

    Code (Skript):
    1. [skellett] [[Libs]Disguises] [the] entity of disguise %disguise%
    2.  
    3. [skellett] [[Libs]Disguises] %disguise%'s disgusie entity
    And clear the entity like you would with any other entity.
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Thank you LimeGlass. Let me know what you find out. I could probably just use LibsDisguise and a mob no AI if I have to. But using Citizens would be easier :emoji_slight_smile:
    --- Double Post Merged, Apr 3, 2017, Original Post Date: Mar 28, 2017 ---
    I'm curious as to if you tested the NPC thing yet?

    Another issue I'm having (a work around for the Citizens thing):
    I have the latest Skellet, Skript, and LibsDisguise installed. I tried using Skellet's disguise syntaxes, and I can't get anything to work.

    I've tried using:
    Code (Skript):
    1. [skellett] [[Libs]Disguises] [set] Disguise [of] next [spawned] (as|to) %disguise%
    2. Examples:
    3. skellett LibsDisguises set Disguise of next spawned to witch
    4. skellett LibsDisguises set Disguise of next spawned to "witch"
    5.  
    ..and get "Can't understand this condition/effect" errors on every reload. I have made sure LibsDisguise hook is enabled in the config. Would you be able to provide an example on how this is supposed to be used?

    Also, I'm totally confused about how to use:
    Code (Skript):
    1. [skellett] [[Libs]Disguises] %disguise%'s disgusie entity
    (and there is a misspelling there of disguise :emoji_wink:)

    Unfortunately googling all of the old Bukkit and SKUnity threads no longer exist, so years of Skript help threads seems to be flushed away :emoji_frowning:

    I appreciate the help!
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    This syntax is not a thing. I have no clue where you got this syntax. A really old version? Or you need to delete and let your syntax regenerate? idk

    But the syntax is
    Code (Skript):
    1. [skellett] [[Libs]Disguises] [set] Disguise [of] next [spawned] [entity] (as|to) %disguise%
    This will disguise the next entity to spawn. Example:

    Code (Skript):
    1. set {_d} to a new disguise of type "ZOMBIE"
    2. set disguise of next spawned to {_d}
    This is used to get the actual entity of the disguise. So you can use entity syntax to modify the physical disguise if you want.

    Code (Skript):
    1. set {_entity} to entity of disguise {_d}
    2. set health of {_entity} to 100
    3. equip {_entity} with diamond armour
     
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Thank you! This worked. (just had to remove the word "of")

    Code (Skript):
    1. set {_d} to a new disguise type "ZOMBIE"
    2. set disguise of next spawned to {_d}
    It's a good workaround for the NPC thing not working. However, if you can figure out a way to delete single NPC's by name (which was my original problem), that would work so much better for what I'm working on. NPCs just have so many more options to play with.
    For now, I'll spawn in a mob with no-AI and disguise it to make it feel like an NPC instead.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...