Jump to content

[Custom Npcs 1.8.9] starting timer on init?


Recommended Posts

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");


The goal is to have an NPC automatically despawn on a timer after they spawn.

Link to comment
Share on other sites

  • 2 weeks later...

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.