Posted July 6, 20169 yr I'm sure I'm doing something silly here, but I'm starting a timer in an NPC's init callback, and when I clone that NPC, it seems like all subsequent copies are having their timer callback invoked immediately. It works fine if I clone the NPC before without enabling the script: when I spawn three, and enable each NPC's script separately, it works how I would expect it to. What am I doing wrong? I assume that cloning is not how I should be doing this, but I don't know how to "save" an npc with scripts turned on. My script: var LIFESPAN = 255; var DEATH_ID = 0; function init(event){ event.npc.say("I live..."); event.npc.getTimers().start(DEATH_ID, LIFESPAN, false); } function timer(event){ if (event.id === DEATH_ID) { event.npc.say("...now I die"); event.npc.despawn(); } } The goal is to have an NPC automatically despawn on a timer after they spawn.
July 18, 20169 yr That is a good question because if you do it separately it dose not seem to be global. But if you clone them it seems to be the same timer?
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.