TheWanderer001 Posted May 5, 2021 Share Posted May 5, 2021 (edited) Does anyone know of a way to detect in a script if an item is stolen ??? I've done this in Morrowind and Oblivion without any problems but for the life of me can't find a way in Skyrim :sad: I've tried: actorOwner = checkItem.GetActorOwner()but doesn't seem to work get the error - "GetActorOwner is not a function or does not exist" Edited May 5, 2021 by TheWanderer001 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 5, 2021 Share Posted May 5, 2021 Some questions:1. Have you extracted the source files from the Scripts.zip that came with the SSE Creation Kit? It should have asked to do that the first time you ran the CK.2. Have you changed where the papyrus compiler / Creation Kit look for source files? By default SSE uses "Data > Source > Scripts"3. Is checkItem an ObjectReference property or local variable? If not, is it something you could cast into ObjectReference prior to calling GetActorOwner? Link to comment Share on other sites More sharing options...
dylbill Posted May 5, 2021 Share Posted May 5, 2021 There's an SKSE function IsOffLimits() to check for stolen items, but it only works on object references. Here's a discussion on how to check for items in a container: https://forums.nexusmods.com/index.php?/topic/9557203-help-with-a-script-to-get-the-values-of-stolen-items/ Link to comment Share on other sites More sharing options...
TheWanderer001 Posted May 5, 2021 Author Share Posted May 5, 2021 (edited) Yes all source scripts extracted.Yes "Data > Source > Scripts" is used. I'm was using Form checkItem = PlayerRef.GetNthForm(0) so I guess that's why it's not workingwill change it and try again :smile: Not heard of isOffLimits() will have to check it out :) Edited May 5, 2021 by TheWanderer001 Link to comment Share on other sites More sharing options...
TheWanderer001 Posted May 5, 2021 Author Share Posted May 5, 2021 hmmm.... have tried both methods but can't get either to identify stolen :(going to take a break and try again tomorrow. Link to comment Share on other sites More sharing options...
TheWanderer001 Posted May 8, 2021 Author Share Posted May 8, 2021 After a lot of experimenting... still can't get either method to work :( If anyone has a working script for this I'd really love to know how :) Link to comment Share on other sites More sharing options...
dylbill Posted May 8, 2021 Share Posted May 8, 2021 Did you check the other thread I posted? Both methods only work for ObjectReferences, so the only way I know how to for containers, is drop the reference, check, then pick the reference back up. Like so: MiscObject Property IngotGold Auto Event OnInit() Int StolenGoldIngots = CountInventoryItemsStolen(Game.GetPlayer(), IngotGold) ;Count how many Gold Ingots are stolen in the players inventory. EndEvent Int Function CountInventoryItemsStolen(ObjectReference akContainer, Form akItem) Int ItemCount = akContainer.GetItemCount(akItem) Form[] DroppedObjects = Utility.CreateFormArray(ItemCount) ;create form array the same size as count Int StolenCount = 0 While ItemCount > 0 ItemCount -= 1 ;Subract 1 from item count DroppedObjects[ItemCount] = akContainer.DropObject(akItem, 1) ;drop 1 item from container and save in array (DroppedObjects[ItemCount] as ObjectReference).Disable() ;make invisible If (DroppedObjects[ItemCount] as ObjectReference).IsOffLimits() StolenCount += 1 ;add 1 to stolen count Endif Endwhile ItemCount = DroppedObjects.Length While ItemCount > 0 ItemCount -= 1 ;Subract 1 from item count (DroppedObjects[ItemCount] as ObjectReference).Enable() akContainer.AddItem(DroppedObjects[ItemCount], 1, true) ;add item back to container silently EndWhile Return StolenCount EndFunction Link to comment Share on other sites More sharing options...
TheWanderer001 Posted May 9, 2021 Author Share Posted May 9, 2021 (edited) Ah... now it make sense... well sort of :D I'll see if I can adjust the script to find all stolen items in a players inventory and move those to another container. o_O Having not used arrys before I've done a bit of a read up on them.It appears they are limited to 128 eliments... not sure if this will be an obstacle or not yet though ??? Edited May 9, 2021 by TheWanderer001 Link to comment Share on other sites More sharing options...
TheWanderer001 Posted May 9, 2021 Author Share Posted May 9, 2021 By way of a test I've added this into my scripts and it does run without erros but... at the end stolen count is stil 0There are a lot of stolen items in the players inventory. Can't see what I'm doing wrong though ???I think it might be 'checkItem' that is wrong type but don't know what it should be if it is. Int iCount = 99999 Int StolenCount = 0 Int ItemCount = 0 iCount = PlayerRef.GetNumItems() While iCount iCount -= 1 checkItem = PlayerRef.GetNthForm(iCount) as ObjectReference ItemCount = PlayerRef.GetItemCount(checkItem) Debug.Notification("item... " +iCount+" Stolen..."+StolenCount) Form[] DroppedObjects = Utility.CreateFormArray(ItemCount) ;create form array the same size as count While ItemCount > 0 ItemCount -= 1 ;Subract 1 from item count DroppedObjects[ItemCount] = PlayerRef.DropObject(checkItem, 1) ;drop 1 item from container and save in array (DroppedObjects[ItemCount] as ObjectReference).Disable() ;make invisible If (DroppedObjects[ItemCount] as ObjectReference).IsOffLimits() StolenCount += 1 ;add 1 to stolen count Endif Endwhile ItemCount = DroppedObjects.Length While ItemCount > 0 ItemCount -= 1 ;Subract 1 from item count (DroppedObjects[ItemCount] as ObjectReference).Enable() PlayerRef.AddItem(DroppedObjects[ItemCount], 1, true) ;add item back to container silently EndWhile EndWhile Link to comment Share on other sites More sharing options...
TheWanderer001 Posted May 9, 2021 Author Share Posted May 9, 2021 (edited) Okay did more testing trial'n'error... it seems my thought it was the 'checkitem' where the problem is was correct.Changed it to 'form' type and it now seems to work :smile: Although it seems that dropped items sometimes flash up... so can be a bit of a distraction. Edited May 9, 2021 by TheWanderer001 Link to comment Share on other sites More sharing options...
Recommended Posts