Jump to content

Detect Ownership OnItemAdded


MrBobDobalina

Recommended Posts

Hey guys,

 

I know this is my first post here and I'm already one of those needy scripters begging for some help. But, I've been scouring the web, including forums, faqs, official documentation, consulting the few modders I know, etc, and I can't seem to get an answer to this question. This worries me as it seems that no one knows how to accomplish this and it is crucial that I am able to implement this functionality in my mod.

 

SO, Can anyone tell me how I could detect if an object reference passed to an OnItemAdded Event is an item the active player owns? In other words, How can I determine if an item is a stolen item within a Papyrus Script?

 

If the answer is flat out "This can not be done with Papyrus, SKSE, or any other means of accessing game data", I might cry...

Link to comment
Share on other sites

This might work, no SKSE needed:

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
if (akItemReference.GetActorOwner() == Game.GetPlayer().GetActorBase())
	debug.messagebox("Item is owned by Player")
endif
EndEvent

Link to comment
Share on other sites

I don't see any type of way to retrieve that info, so the above code would be the work around. However... most things in game are not owned by the player, and might not be owned by anyone...

 

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
       if (akItemReference.GetActorOwner() != Game.GetPlayer().GetActorBase() && akItemReference.GetActorOwner() != null)
               ; since item is not owned by the player and is owned by someone ... we can assume it is stolen.
       endif
EndEvent

 

If this is possible, this would work.

Link to comment
Share on other sites

I don't see any type of way to retrieve that info, so the above code would be the work around. However... most things in game are not owned by the player, and might not be owned by anyone...

 

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
       if (akItemReference.GetActorOwner() != Game.GetPlayer().GetActorBase() && akItemReference.GetActorOwner() != null)
               ; since item is not owned by the player and is owned by someone ... we can assume it is stolen.
       endif
EndEvent

 

If this is possible, this would work.

 

Ghostifish and I have just come to the same conclusion over in the chat. I came across the GetActorOwner method earlier, but then saw it was a member of the cell script and was returning the owner of the current Cell. Somehow I must have over looked the same method in the ObjectReference script. Ish has been driving me up the wall all day. Thanks a lot for your time/replies!

Edited by MrBobDobalina
Link to comment
Share on other sites

  • Recently Browsing   0 members

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