Also, is it possible to spawn an item if an npc is in a certain place? I am creating a mod where an npc teleports around morrowind, and am trying to script it to where he teleports after you change cells, and where a note spawns near where he was.
I'm not sure I fully understand what you're trying to achieve. You can spawn an item to an NPC's location by:
1.) Spawning the item to the player's location:
PlaceAtPC, "some_item", 1, 0, 0
2.) Assigning a script to the spawned item that changes its position to that of your NPC:
Begin somescriptshort dooncefloat local_posif ( doonce == 0 ) set local_pos to ( "some_npc"->GetPos, X ) SetPos, X, local_pos set local_pos to ( "some_npc"->GetPos, Y ) SetPos, Y, local_pos set local_pos to ( "some_npc"->GetPos, Z ) SetPos, Z, local_pos set doonce to 1endifEnd
As for checking what cell the player currently is in, you can use http://uesp.net/wiki/Tes3Mod:GetPCCell. Since you need the NPC to be in a loaded cell for its local script to run, it means that he's either in the same cell as the player, or in an adjacent exterior cell. If you need to determine his exterior cell exactly, you can use GetPos checks.