Jump to content

Recommended Posts

Posted (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 by Thorham
Posted
  On 12/7/2012 at 5:10 PM, Ghaunadaur said:

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.

Posted
  On 12/9/2012 at 2:49 AM, IsharaMeradin said:
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 :)

  • Recently Browsing   0 members

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