Jump to content

[LE] Need help with Scripting


Jarrek2002

Recommended Posts

Hello, I just can't seem to get a script working using the OnItemAdded event.

 

What I'm trying to do:

- For every Iron Arrow that the player picks up, an object is added into his inventory

 

Mod set up:

- Created misc item titled "arrowitem"

- Created formlist titled "arrowform", that contains an iron arrow

- Created Quest that starts enabled

- Created the player as the reference alias for the quest

- Created a script and attached to the reference alias

 

Script:

 

Scriptname âArrowadd âextends ReferenceAlias

 

Actor property PlayerRef âAuto

Formlist property ArrowForm Auto

Keyword property VendorItemArrow Auto

Form property ArrowItem Auto

 

Event OnInit()

AddInventoryEventFilter(ArrowForm)

endEvent

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

if akBaseItem.HasKeyword(VendorItemArrow)

PlayerRef.AddItem(arrowitem, aiItemCount, true)

endif

endEvent

 

 

I know the quest and player alias are working correctly as I've added a test note to the Alias Inventory, which appears in the player's inventory. Otherwise, the script does not seem to recognize when I pick up an Iron Arrow at all. Any help would be much appreciated!

Link to comment
Share on other sites

1. The ArrowItem property should be Ammo rather than Form.

2. Is the arrow listed on the formlist used in the inventory event filter? If not, that would be a contributing factor.

3. Have you assigned the appropriate data to the properties in the Creation Kit? If not, that would be a contributing factor as well.

Link to comment
Share on other sites

1. The ArrowItem property should be Ammo rather than Form.

2. Is the arrow listed on the formlist used in the inventory event filter? If not, that would be a contributing factor.

3. Have you assigned the appropriate data to the properties in the Creation Kit? If not, that would be a contributing factor as well.

 

Thank you for your reply Ishara

1. Ok, I corrected the property - I'm using a MiscObject "BearPelt" just to test

2. Yes, the inventory event filter "arrowform" contains an Iron Arrow (only)

3. Properties are all assigned in the CK as you suggested

 

The script now appears as follows:

 

 

Scriptname Arrowadd extends ReferenceAlias

 

Actor property PlayerRef Auto

Formlist property ArrowForm Auto

Keyword property VendorItemArrow Auto

MiscObject property BearPelt Auto

 

Event OnInit()

AddInventoryEventFilter(ArrowForm)

endEvent

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

if akBaseItem.HasKeyword(VendorItemArrow)

PlayerRef.AddItem(BearPelt, aiItemCount, true)

endif

endEvent

Edited by Jarrek2002
Link to comment
Share on other sites

Does it work or not?

Make sure you are using the correct iron arrow. There are several entries of iron arrow in the ammo section. You should be using 0001397D.

 

Are you testing on a new game or a save that has not seen your mod before? Old information from your mod could be baked into the save and preventing the newly added stuff from working as intended.

Link to comment
Share on other sites

Does it work or not?

Make sure you are using the correct iron arrow. There are several entries of iron arrow in the ammo section. You should be using 0001397D.

 

Are you testing on a new game or a save that has not seen your mod before? Old information from your mod could be baked into the save and preventing the newly added stuff from working as intended.

 

It's working now!

 

​Thank you so much!

 

I believe the latest issue was that I was working on an existing save. Your help is much appreciated.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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