OnItemAdded Event Problem

Post » Mon Apr 28, 2014 3:48 pm

I am having an issue with the OnItemAdded event where it does wierd things if the player adds more than 1165 gold pieces (septims) at one time. It only seems to affect septims. All other items that I have tested work fine.

In the following code, if the player adds more than 1165 septims to the container, the aiItemCount comes back as 1. Then the game proceeds to fire off numerous OnItemAdded events up to the point where it finally reaches the amount the player put into the container.

Spoiler
Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)    If (akSourceContainer == Game.GetPlayer())        If (aiItemCount == 1)            If (GetItemCount(akBaseItem) > 1)                ; I added this check since, for some reason, if more than 1165                ; items are added at once, the game returns 1 for aiItemCount then                ; proceeds to add items 1 by 1 up to the actual item count, and it                ; generates OnItemAdded events for each one. This only seems to                ; happen with gold pieces (septims).                RemoveItem(akBaseItem, aiItemCount, False, PlayerRef)            Else                ; Do things here.            EndIf        Else            MessageCount.Show()            RemoveItem(akBaseItem, aiItemCount, False, PlayerRef)        EndIf    EndIfEndEvent

Has anyone here encountered this behavior before? It appears to me to be a bug in the game engine unless I am the only one having this issue.

I have worked around it by putting in the GetItemCount(akBaseItem) check in the above code so that the items are returned to the player but it still looks weird on the screen since you can see the item quantity counting up in the inventory until the game stops sending the OnItemAdded events. Since it only appears to happen when septims are added it is not too big a deal. But if anyone has any ideas for a more elegant workaround I would be grateful.

User avatar
Frank Firefly
 
Posts: 3429
Joined: Sun Aug 19, 2007 9:34 am

Return to V - Skyrim