Script making game crash :(

Post » Fri May 04, 2012 12:08 pm

does anyone know why when calling additem and equip item on an actor in the same block crashes freezes the game?
is there a way around it?

scn StaticHoloGeneratorCompanionScriptref rContainerBegin GameModeset rContainer to GetContainerif rContainer.IsActor && rContainer != player  rContainer.equipItem StaticHoloGeneratorCompanion 0 1  rContainer.addItem StaticHoloFieldBlueCompantion 1 1  rContainer.equipItem StaticHoloFieldBlueCompanion 1 1endIfEnd
User avatar
Lizzie
 
Posts: 3476
Joined: Sun Nov 19, 2006 5:51 am

Post » Fri May 04, 2012 11:08 am

What is this script attached to an NPC? Since there is no kind of control variable this script would loop endlessly every frame. Don't think the add equip is the problem here, but that's easy to fix using a control variable.
scn StaticHoloGeneratorCompanionScriptref rContainershort doneBegin GameModeif done == 1  rContainer.equipItem StaticHoloFieldBlueCompanion 1 1  set done to 2endifif done == 0set rContainer to GetContainerif rContainer.IsActor && rContainer != player  rContainer.equipItem StaticHoloGeneratorCompanion 0 1  rContainer.addItem StaticHoloFieldBlueCompantion 1 1  set done to 1 ;next frame he will equip as its higher in the scriptendIfendifEnd

Edit: BTW the TES wiki has some info indicating that getcontainer can return 0 for a few frames when the game is loaded, and that would cause a crash as you are calling reference functions on null. Anytime I use a reference function I'll try to make sure to add a check like if Rvar == 0 return, or start your code with if rvar != 0.
User avatar
Harry-James Payne
 
Posts: 3464
Joined: Wed May 09, 2007 6:58 am

Post » Fri May 04, 2012 5:30 am

omg true i forgot to make it stop
>< this is actually attatched to a armor item
if its in a container script will not run as it is not an actor if i giv it to my companion
it will run
also another problem is rContainer != player doesn't seem to want to work
my player will equip the item as well....

also if i change
rContainer.equipItem StaticHoloGeneratorCompanion 0 1

to

rContainer.equipItem StaticHoloGeneratorCompanion 1 1

i can still "unequip" take the item from companion inventory
does the no unequip flag not work for npcs?
User avatar
saharen beauty
 
Posts: 3456
Joined: Wed Nov 22, 2006 12:54 am

Post » Fri May 04, 2012 8:12 am

You probably need to use playerRef in this instance, player.SomeFunction works ok but used to compare it probably thinks you are using the base player.

No unequip works on NPCs just fine, can't say for sure why it's not sticking for you. There's some talk on the TES page that says NPCs who are not loaded when this item is added may ignore the flag and equip the item they want instead.
User avatar
Annika Marziniak
 
Posts: 3416
Joined: Wed Apr 18, 2007 6:22 am

Post » Fri May 04, 2012 2:04 am

playerRef doesnt work either
i tried

ref rPlayerset rPlayer to playerRefif rContainer.IsActor && rContainer != rPlayer

didn't work either but doesnt really matter

the rContainer.equipItem StaticHoloGeneratorCompanion 1 1 is kind of working
when ever it has the unequipable flag it will ctd if i try to take it from npc inventory...
the problem is i SHOULDN'T be able to take it in the first place...weird
User avatar
Horse gal smithe
 
Posts: 3302
Joined: Wed Jul 05, 2006 9:23 pm

Post » Fri May 04, 2012 11:00 am

I would suggest that you make sure rContainer is valid (non zero) before calling any functions on it.


scn StaticHoloGeneratorCompanionScriptref rContainershort doneBegin GameModeif done == 1    if (rContainer)      rContainer.equipItem StaticHoloFieldBlueCompanion 1 1      set done to 2    endifendifif done == 0    set rContainer to GetContainer    if (rContainer)        if rContainer.IsActor && rContainer != player          rContainer.equipItem StaticHoloGeneratorCompanion 0 1          rContainer.addItem StaticHoloFieldBlueCompantion 1 1          set done to 1 ;next frame he will equip as its higher in the script        endIf    endifendifEnd
User avatar
Mandy Muir
 
Posts: 3307
Joined: Wed Jan 24, 2007 4:38 pm


Return to Fallout 3