someoneyouknow Posted November 15, 2016 Share Posted November 15, 2016 I made a script that contains the following state, but I'm having trouble getting it to work. State SCRIPTSTATE Event OnBeginState(string asOldState) ObjectReference[] NPCs = ActiRef.FindAllReferencesOfType(MY_FORM_LIST, 2000.0) NPCs.Kill() EndEvent My goal is to have the activator that this script is attached to run Kill() on all the NPCs listed in MY_FORM_LIST within 2000(Measurement type?) of the activator. I have not however been able to get this to work as of yet and I'm not Papyrus smart enough to figure out why. I've done a lot of searching for information on "FindAllReferencesOfType" but have found only the wiki page and 1 example of actual use on another website. I'm completely new to using form lists too, so together they've put me in a bind. Thanks in advance. :) Link to comment Share on other sites More sharing options...
someoneyouknow Posted November 15, 2016 Author Share Posted November 15, 2016 (edited) On a random side note, I'd just like to say how glad I am this forum exists. So many people have been able to provide information that I haven't been able to find on my own. Not only that, but I've also been able to help others with their questions too while waiting for answers on my own! So thanks to all of you out there that take the time to share your knowledge with us just starting out with Papyrus. It REALLY makes a difference. :smile: Edited November 15, 2016 by someoneyouknow Link to comment Share on other sites More sharing options...
LoneRaptor Posted November 15, 2016 Share Posted November 15, 2016 (edited) Is there a reason you are using states for this instead of the OnActivate event? Edit: also the kill() function needs to be run on an actor not an objectreference. replace your Objectreference[] NPCs with Actor[] NPCs and see if that works if not you might have to do each one separate using a while loop or use a RefCollectionAlias instead and use KillAll(). And add As Actor[] behind FindAllReferencesOfType(MY_FROM_LIST, 2000.0). Edited November 15, 2016 by LoneRaptor Link to comment Share on other sites More sharing options...
someoneyouknow Posted November 15, 2016 Author Share Posted November 15, 2016 (edited) I'm using states because the activator in question doesn't have two states (Like a switch, and I want the event to fire every other time), so I made an on and off state. And thanks! I'll give that a try. Edited November 15, 2016 by someoneyouknow Link to comment Share on other sites More sharing options...
Lisselli Posted November 17, 2016 Share Posted November 17, 2016 (edited) Just for the sake of teaching you a little something about arrays.. Event OnBeginState(String asOldState) ObjectReference[] NPCs = ActiRef.FindAllReferencesOfType(MY_FORM_LIST, 2000.0) Int Index = NPCs.Length While Index Index -= 1 NPCs[Index].Kill() EndWhile EndEvent Edited November 17, 2016 by Lisselli Link to comment Share on other sites More sharing options...
Recommended Posts