kxdace Posted July 7, 2019 Posted July 7, 2019 Hello friends! I am trying to get all the NPC's in the same cell as the player using the following code: ===CODE=== Scriptname wrScriptGetAllActors extends ObjectReference Actor property playerRef auto Event OnActivate (ObjectReference akActionRef) debug.notification("Button Hit") Cell kCell = PlayerRef.GetParentCell() Int iIndex = kCell.GetNumRefs(95) debug.notification("iIndex = " + iIndex) ObjectReference[] objectReferencesList = new ObjectReference[100] while (iIndex) iIndex -= 1 objectReferencesList[iIndex] = kCell.GetNthRef(iIndex, 95) debug.messageBox("Actor: " + iIndex + " " + objectReferencesList[iIndex]) endwhile EndEvent ===CODE=== However "iIndex" never populates no matter how many NPC's I have in the room with me. This script is attached to a DWE button and the propertys are set to Cell: Any Reference: PlayerRef('Player') Please assist.
Guest Posted July 7, 2019 Posted July 7, 2019 19 minutes ago, kxdace said: Hello friends! I am trying to get all the NPC's in the same cell as the player using the following code: ===CODE=== Scriptname wrScriptGetAllActors extends ObjectReference Actor property playerRef auto Event OnActivate (ObjectReference akActionRef) debug.notification("Button Hit") Cell kCell = PlayerRef.GetParentCell() Int iIndex = kCell.GetNumRefs(95) debug.notification("iIndex = " + iIndex) ObjectReference[] objectReferencesList = new ObjectReference[100] while (iIndex) iIndex -= 1 objectReferencesList[iIndex] = kCell.GetNthRef(iIndex, 95) debug.messageBox("Actor: " + iIndex + " " + objectReferencesList[iIndex]) endwhile EndEvent ===CODE=== However "iIndex" never populates no matter how many NPC's I have in the room with me. This script is attached to a DWE button and the propertys are set to Cell: Any Reference: PlayerRef('Player') Please assist. Replace 95 with 62. You are using the wrong FormId for the actors. 62 is "Character" but techically all actors have this. 95 is ActorValueInfo, that is something that cannot be in a cell.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.