Jump to content

Strange script problem.


Thorham

Recommended Posts

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
Link to comment
Share on other sites

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

  • Recently Browsing   0 members

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