Jump to content

Script - Get all NPC in room failing (Solved)


kxdace

Recommended Posts

Posted

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.

 

Posted
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.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...