Best way to remove a item from the player's inventory?

Post » Tue Jun 19, 2012 4:04 am

What i used to do is add a script to the player itself to use OnItemAdded, however this doesn't work anymore on my newer saved game and I don't know why.

Are there any alternatives to removing an item from the players inventory when it is added?

This is what i was doing initially but now the script won't run anymore.

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)	   AddInventoryEventFilter(WieldableLanternListDummy)	   If(akBaseItem == LanternLousyDummy)			  Game.GetPlayer().RemoveItem(akItemReference, 1)			  Game.GetPlayer().AddItem(WieldableLanternLousy, 1 )	   endifendEvent
User avatar
Tamara Dost
 
Posts: 3445
Joined: Mon Mar 12, 2007 12:20 pm

Post » Mon Jun 18, 2012 9:32 pm

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)	AddInventoryEventFilter(WieldableLanternListDummy)	If akNewContainer == Game.GetPlayer()		akNewContainer.RemoveItem(Self, 1. True)		akNewContainer.AddItem(WieldableLanternLousy, 1, True)	EndIfEndEvent
User avatar
Joe Alvarado
 
Posts: 3467
Joined: Sat Nov 24, 2007 11:13 pm

Post » Mon Jun 18, 2012 9:48 pm

Looks good to me, one small question though, what should I attach that script to for it to run?


EDIT: Alright yeah, I added this to the dummy object that is to be removed when it goes into the player's inventory and it seems to work, thanks =]
User avatar
Tiffany Carter
 
Posts: 3454
Joined: Wed Jul 19, 2006 4:05 am


Return to V - Skyrim