Thorham Posted December 7, 2012 Share Posted December 7, 2012 (edited) Hi, The script below is supposed to loop through a cell's list of NPCs. For each NPC that isn't the player, a second loop is executed. The problem is that the loop is also executed when the NPC is the player. Anyone have any ideas as to why this is happening? event OnLocationChange(Location akOldLoc, Location akNewLoc) area=Game.GetPlayer().GetParentCell() player=Game.GetPlayer() as Actor bla=area.GetNumRefs(43) loopy=0 while loopy < bla npc = area.GetNthRef(loopy, 43) as Actor if (npc!=Game.GetPlayer()) loopx=0 while loopx < 3 Utility.Wait(1) if (npc==Game.GetPlayer()) Debug.Notification("1234567890") endif loopx+=1 endwhile endif loopy+=1 endwhile endevent Edited December 7, 2012 by Thorham Link to comment Share on other sites More sharing options...
Ghaunadaur Posted December 7, 2012 Share Posted December 7, 2012 Hmm, shouldn't the value for the form type filter be set to 43 for NPCs? Link to comment Share on other sites More sharing options...
Thorham Posted December 7, 2012 Author Share Posted December 7, 2012 Hmm, shouldn't the value for the form type filter be set to 43 for NPCs?Yes, I used 43 before, but tried type 62 (character). When I changed it back, I made a typo, and posted the code with the typo. Link to comment Share on other sites More sharing options...
Thorham Posted December 9, 2012 Author Share Posted December 9, 2012 No one has any ideas as to why npc changes in the inner loop while it clearly shouldn't? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 9, 2012 Share Posted December 9, 2012 no clue but off the wall guess... maybe it's catching some player alias references tied to various quests or whatever that are active on the player character. Link to comment Share on other sites More sharing options...
Thorham Posted December 9, 2012 Author Share Posted December 9, 2012 no clue but off the wall guess... maybe it's catching some player alias references tied to various quests or whatever that are active on the player character.Yeah, that's certainly possible, and because the content of a cell isn't static, that reference can change when the script takes to long. However, it doesn't matter anymore! I've come up with a way to change what the player character looks like without having to update other characters. Simply change the nifs of the equipped armor pieces, update the player character, and then change the armors back to the way they were. NPCs are updated when a cell is loaded, but because the armors are restored after the player character is updated, they'll look the way they're supposed to, while the player character doesn't seem to be updated when a cell is loaded, and will therefore still look like what you want them to look like. I have it running right now, and it seems to work like a charm :) No more messing around with cloning armors :) Link to comment Share on other sites More sharing options...
Recommended Posts