OnItemAdded issues on game start

Post » Wed Oct 15, 2014 1:27 pm

So I have a script set up:

Scriptname IQ02PlayerAliasScript extends ReferenceAlias{Governs all the functions and actions related to the player in Disrupted Service.}Message Property PackageAddedMes AutoMessage Property OpenConfirmationMes AutoReferenceAlias Property CourierNote AutoWeapon Property Cutlass AutoArmor Property Buckler AutoReferenceAlias Property PackageAlias AutoReferenceAlias Property FNVEasterEgg AutoReferenceAlias Property ForgedPapers AutoReferenceAlias Property DeadCourier AutoSpell Property ReanimateSpell AutoActor kRefActor dRefObjectReference cRefObjectReference pRefObjectReference fRefObjectReference fpRefEvent OnInit()    RegisterForSingleUpdate(0.5)EndEventEvent OnUpdate()    kRef = Self.GetActorReference()    dRef = DeadCourier.GetActorReference()    cRef = CourierNote.GetReference()    pRef = PackageAlias.GetReference()    fRef = FNVEasterEgg.GetReference()    fpRef = ForgedPapers.GetReference()    AddInventoryEventFilter(pRef.GetBaseObject())    AddInventoryEventFilter(fRef.GetBaseObject())    AddInventoryEventFilter(fpRef.GetBaseObject())    AddInventoryEventFilter(cRef.GetBaseObject())EndEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)    If akItemReference == pRef        GetOwningQuest().SetStage(10)        Utility.Wait(0.1)        Int iButton = PackageAddedMes.Show()        While iButton            If iButton == 1                If kRef.GetItemCount(cRef) == 0                                    kRef.AddItem(cRef, 1)                EndIf                cRef.Activate(kRef)                iButton = 0            ElseIf iButton == 2                iButton = OpenConfirmationMes.Show()                While iButton                    If iButton == 1                        kRef.RemoveItem(pRef, 1)                        GetOwningQuest().SetStage(200)                        kRef.AddItem(Cutlass, 1)                        kRef.AddItem(Buckler, 1)                        iButton = 0                    ElseIf iButton == 2                        If kRef.GetItemCount(cRef) == 0                                            kRef.AddItem(cRef, 1)                        EndIf                        cRef.Activate(kRef)                        iButton = 0                    EndIf                EndWhile            EndIf        EndWhile    ElseIf akItemReference == fRef        ReanimateSpell.Cast(dRef, dRef)        dRef.StartCombat(kRef)    ElseIf akItemReference == fpRef        GetOwningQuest().SetStage(70)    ElseIf akItemReference == cRef        If kRef.GetItemCount(cRef) > 1            kRef.RemoveItem(cRef, 1, true)        EndIf    EndIfEndEvent    Function CheckForPapers()    If kRef.GetItemCount(fpRef) >= 1        GetOwningQuest().SetStage(70)    EndIfEndFunction

However, every time I start a new game, or load a save (EVEN WHEN I DO NOT HAVE OR HAVE PICKED UP pRef (package), the messagebox dialogue for the package taking (OnItemAdded for pRef) shows up. Is there something wrong with my script or should I just use OnContainerChanged?

User avatar
Danii Brown
 
Posts: 3337
Joined: Tue Aug 22, 2006 7:13 am

Post » Wed Oct 15, 2014 9:35 pm

So I just tried this and it now works, but I preferred the other method for efficiency so do you know what the issue was?

Spoiler
Scriptname IQ02PlayerAliasScript extends ReferenceAlias{Governs all the functions and actions related to the player in Disrupted Service.}Message Property PackageAddedMes AutoMessage Property OpenConfirmationMes AutoReferenceAlias Property CourierNote AutoWeapon Property Cutlass AutoArmor Property Buckler AutoReferenceAlias Property PackageAlias AutoReferenceAlias Property FNVEasterEgg AutoReferenceAlias Property ForgedPapers AutoReferenceAlias Property DeadCourier AutoSpell Property ReanimateSpell AutoActor kRefActor dRefObjectReference cRef;ObjectReference pRefObjectReference fRefObjectReference fpRefEvent OnInit()    RegisterForSingleUpdate(0.5)EndEventEvent OnUpdate()    kRef = Self.GetActorReference()    dRef = DeadCourier.GetActorReference()    cRef = CourierNote.GetReference()    ;pRef = PackageAlias.GetReference()    fRef = FNVEasterEgg.GetReference()    fpRef = ForgedPapers.GetReference()    ;AddInventoryEventFilter(pRef.GetBaseObject())    AddInventoryEventFilter(PackageAlias.GetReference().GetBaseObject())    AddInventoryEventFilter(fRef.GetBaseObject())    AddInventoryEventFilter(fpRef.GetBaseObject())    AddInventoryEventFilter(cRef.GetBaseObject())EndEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)    If akItemReference == PackageAlias.GetReference()        GetOwningQuest().SetStage(10)        Utility.Wait(0.1)        Int iButton = PackageAddedMes.Show()        While iButton            If iButton == 1                If kRef.GetItemCount(cRef) == 0                                    kRef.AddItem(cRef, 1)                EndIf                cRef.Activate(kRef)                iButton = 0            ElseIf iButton == 2                iButton = OpenConfirmationMes.Show()                While iButton                    If iButton == 1                        kRef.RemoveItem(PackageAlias.GetReference(), 1)                        GetOwningQuest().SetStage(200)                        kRef.AddItem(Cutlass, 1)                        kRef.AddItem(Buckler, 1)                        iButton = 0                    ElseIf iButton == 2                        If kRef.GetItemCount(cRef) == 0                                            kRef.AddItem(cRef, 1)                        EndIf                        cRef.Activate(kRef)                        iButton = 0                    EndIf                EndWhile            EndIf        EndWhile    ElseIf akItemReference == fRef        ReanimateSpell.Cast(dRef, dRef)        dRef.StartCombat(kRef)    ElseIf akItemReference == fpRef        GetOwningQuest().SetStage(70)    ElseIf akItemReference == cRef        If kRef.GetItemCount(cRef) > 1            kRef.RemoveItem(cRef, 1, true)        EndIf    EndIfEndEvent    Function CheckForPapers()    If kRef.GetItemCount(fpRef) >= 1        GetOwningQuest().SetStage(70)    EndIfEndFunction 

Also, is there any way so I can make it so there aren't 2 notes in your inventory? cRef is a note, which is added to you by default when you choose a specific option in the messagebox. However, when you read the note and choose Take, it adds another. I had a bit of code in there that SHOULD have remedied that, but I still have two notes. Any idea why?

User avatar
mishionary
 
Posts: 3414
Joined: Tue Feb 20, 2007 6:19 am


Return to V - Skyrim