As mentioned it really depends on the conditions you use to trigger the event. The most common being a journal update. Others could be a local state from script to script, or even a global. But a simplified form would be using the journal, with the following script attached to the NPC. If it's not on the NPC (say another object or a global script), the disable and setDelete need to have the reference target fixed.
Note: setDelete is a Tribunal or later function, and has been know to crash the game when not used by the calling object.
Begin MyDisableShort DoneFloat Timeif ( MenuMode == 1 ) ; I use this out of habit with a timer returnendifif ( done == 1 ) returnendifif ( GetJournalIndex, my_journal >= XX ) ;xx = your journal index if ( GetCellChanged == 1 ) ; player leaves cell disable endif Set Time to ( Time + GetSecondsPassed ) if ( Time > 3 ) setDelete 1 ;completely removes reference set time to 0 set done to 1 endifendifend
If you wanted to have the NPC vanish before the player leaves the cell, then you can add an effect (a mock divine/almsivi or recall so to speak), then try this;
Begin MyDisableShort DoneFloat Timeif ( MenuMode == 1 ) ; wait until dialogue has ended returnendifif ( done == 1 ) returnendifif ( GetJournalIndex, my_journal >= XX ) ;xx = your journal index cast, "almsivi intervention", player ;of course make sure NPC has spell and is able to cast it disable Set Time to ( Time + GetSecondsPassed ) if ( Time > 3 ) setDelete 1 set Time to 0 set done to 1 endifendif
These are untested, and it's been some time since I've scripted something like this, so there may be a more efficient method.