A function added by MWSE.
xFirstNPC returns a reference to one of the NPCs or Creatures in the players cell or 0 if there are none. The reference is simply the one on the top of a list of all NPCs and Creatures in the cell and you can use the xNextRef function to find the rest.
In v0.9.4a this function is bugged: it may not return all references in exterior cells, and it returns deleted references. These bugs are fixed in the MWSE update released by Merzasphor.
SyntaxEdit
reference (long): xFirstNPC
ExampleEdit
long NPCref short findNPC if ( CellChanged == 1 ) set findNPC to 1 endif ifx ( findNPC ) ifx ( npcref ) setx npcref to xNextRef npcref else setx npcref to xFirstNPC endif if ( npcref == 0 ) ; reached end of list set findNPC to 0 Return endif setx temp to npcref->xRefType if ( temp != 1598246990 ) ; not NPC set temp to 0 endif if ( temp ) npcref->additem gold_001 1 endif endif