Citizens NPC

Discussion in 'Skript' started by Ghost_LoneWalker, Jan 25, 2020.

  1. Hey! I use Citizens to generate an NPC that will detect players when they log into the server and disappear after five seconds. But if my server crashes during this time, the NPC will stay in the server. Is there any way to solve it? (I can't delete Citizens' folder because I have other NPCs)
  2. Try deleting the world
    • Funny Funny x 1
  3. remove all temporary citizens on server startup, save their id to variable when you spawn one and on skript load: get npcs & variables deleted
  4. Citizens' IDs are random, and I cannot delete them using commands unless I change to a fixed ID. My NPC detection is placed on the Hub server and I cannot delete all the citizens because I have some other things that need to be citizens.
  5. Citizens data is stored in the Citizens folder.
  6. as far as I know, same citizen will always have the same ID unless you delete it, also they aren't random, check saves.yml yourself, you do not need to use commands, there are addons / api for it.
  7. My plan is to regenerate the NPC every time a new player logs in, which will invalidate the original ID.
  8. you need to save the id to variable every time you do that, why you don't understand xD
    pseudo code:

    on spawn of the citizen:
    set {somecitizen::%citizen id%} to true

    on delete of citizen:
    delete {somecitizen::%citizen id%}

    on skript load:
    loop {somecitizen::*}:
    if citizen with id loop-index parsed as a number exists
    delete citizen with id loop-index parsed as a number
    delete {somecitizen::*}
  9. thx!!!!!!!!