Jump to content

[Scripting] AddItem doesn't work


M3rvin

Recommended Posts

I started working on a little project for Skyrim and at first, it all went well. But then I started to fail at using the simple AddItem(...) function:

 

My script is applied to an activator that is used to open a container placed outside the area the player can reach (somewhat like a merchant's container). Before opening the container, the items from a formlist should be added to it, so that the player can take them or add others to the container. There's some other code involved with the container, but this stuff works flawless.

 

So here's my code:

Scriptname SOM_ActivateIgnoreListUpdate extends ObjectReference  

Import Game
Import Utility
Import Debug

FormList Property AlcoholicDrinksList auto


Event OnActivate(ObjectReference rActor)
Actor Player = GetPlayer()
ObjectReference rContainer = Self.GetLinkedRef()

if rActor == Player
	Notification("Opening the Container")
	Wait(5)
	rContainer.AddItem(AlcoholicDrinksList)
	rContainer.Activate(Player)
endif

EndEvent

 

The container that should be opened and manipulated is a linked ref of the activator. I'm using AlcoholicDrinksList as a dummy to ensure that I don't try to add the items of an empty formlist (in case by other code didn't work).

 

I added the Notification and Wait commands after reading the official wiki article on additem (Don't call this function immediately when a game is started/loaded as it does not seem to work. You can have the game Wait a second before doing it which should correct this problem.) I did notice a strange thing related to them: Directly after activating the Activator the Notification pops up and after 5 seconds it appears again.

 

 

Does anyone know what I'm doing wrong?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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