Common tasks

Hold an NPC still and stop it from fading out while your mod plays a scene, then hand it back:

void StartScene(string modId, int npcId)
{
    NpcControlFlags flags = NpcControlFlags.Sight | NpcControlFlags.Talk | NpcControlFlags.Fade | NpcControlFlags.Movement;
    if (!NpcControl.Take(modId, npcId, flags)) return;
}

void EndScene(string modId, int npcId)
{
    NpcControl.Release(modId, npcId);
}

Say a line while the NPC is held. Say is on the NPC actions page. It needs the NPC’s body to be switched on, so check the result and try again later if it returned false:

void Speak(int npcId)
{
    if (!NpcActions.Say(npcId, "Wait here.")) return;
}

Find out who holds an NPC, and give back everything your mod holds:

string holder = NpcControl.TakenBy(5);
if (holder != null) Log.Info("NPC 5 is held by " + holder);
int released = NpcControl.ReleaseAll("example.npchold");
Log.Info("Released " + released + " NPCs.");