[Q] Script made by Bethesda not working?

Post » Thu Jun 21, 2012 11:05 pm

Hi,

I'm trying to make a chest that only accepts potions.
Here is the code that I'm using:
Spoiler
ScriptName A_1_WhiterunBreezehome_PcScript extends ObjectReferenceFormList Property AcceptedItemFLST AutoMessage Property ERRORmsgPC_BreezeHome autoEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)	If akSourceContainer == Game.GetPlayer()		If !AcceptedItemFLST.HasForm(akBaseItem)	   	   Game.GetPlayer().AddItem(akBaseItem, aiItemCount, false)	   	   RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)	   	   Debug.Trace("Invalid Item added to POTION CHEST --")	   	   ERRORmsgPC_BreezeHome.Show()		EndIf	EndifEndEvent

The problem is that it does also not accept the items I have created in my FormList (AcceptedItemFLST) and it gives you back your item as twice as much as you had put it in. So if you put in 2 bottles of healing, it will give you back 4 bottles of healing.

This script is origionally made by Bethesda on the Creation Kit's website http://www.creationkit.com/Complete_Example_Scripts, it is almost at the bottom.
I hope someone can help me with this.

Thanks in advance.
User avatar
Alyna
 
Posts: 3412
Joined: Wed Aug 30, 2006 4:54 am

Post » Thu Jun 21, 2012 3:18 pm

Scripts on that page are not necessarily made by Bethesda. They are contributed by community members.

In this case, these two lines...

Game.GetPlayer().AddItem(akBaseItem, aiItemCount, false)
RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)

...are doing the same thing, which is why you're getting double the items back. You seem to have added the line "Game.GetPlayer().AddItem(akBaseItem, aiItemCount, false)" as that does not appear on the wiki's script, but it is unnecessary.

Make sure you have correctly setup your formlist property (e.g., that you have clicked the "Properties" button and set the value in the drop-down list to the formlist you created).
User avatar
Neliel Kudoh
 
Posts: 3348
Joined: Thu Oct 26, 2006 2:39 am

Post » Thu Jun 21, 2012 9:19 pm

The script is not made by Bethesda, but from other users...

Anyway, you're getting back twice the items because you went and added a line for "AddItem". Get rid of it. Also, check to make sure you actually linked the formlist property to your formlist.

EDIT: ninja'd :ninja:
User avatar
xxLindsAffec
 
Posts: 3604
Joined: Sun Jan 14, 2007 10:39 pm

Post » Thu Jun 21, 2012 8:41 pm

When I remove the line Game.GetPlayer().AddItem(akBaseItem, aiItemCount, false) I get back nothing.
User avatar
Rach B
 
Posts: 3419
Joined: Thu Mar 08, 2007 11:30 am

Post » Thu Jun 21, 2012 9:31 pm

Did you actually check your inventory to make sure that nothing was added? There won't be a message on the upper left telling you anything.
User avatar
Lance Vannortwick
 
Posts: 3479
Joined: Thu Sep 27, 2007 5:30 pm

Post » Thu Jun 21, 2012 7:47 pm

Ofcourse I checked -.- How else would I know it? Ugh..
User avatar
Liv Brown
 
Posts: 3358
Joined: Wed Jan 31, 2007 11:44 pm

Post » Thu Jun 21, 2012 6:42 pm

Oh never mind this all, it was me (another script) making it bug. It is fixed now and completely working :D
User avatar
sarah simon-rogaume
 
Posts: 3383
Joined: Thu Mar 15, 2007 4:41 am


Return to V - Skyrim