Jump to content

Help with key /container script


onson

Recommended Posts

Can someone give me an example of how to remove a key from the players inventory after it has been used on a specified container?

My objective is to make a Chest for specific NPC's that can only be opened with a key. The player would have to pickpocket the key to open the container, however after the key has been used I need it to return to the NPC inventory(so the player would have to pickpocket again after the chest contents respawn)

Link to comment
Share on other sites

You might try something sort of like this:

 

SCN AADisappearingKeySCRIPT

; Object script applied to Chest AAGoodyChest which opens only with AAGoodyChestKey.
; The NPC is a persistent reference with the reference ID "AAEasyVictimNPCref."
; When you open the chest, the key instantly goes back to the NPC's pocket. 

Begin OnActivate
    Player.RemoveItem AAGoodyChestKey 1
    AAEasyVictimNPCref.AddItem AAGoodyChestKey 1
    Activate
End

Link to comment
Share on other sites

Small problem, stole the key , opened container, but key was not removed from player. I have the script assigned to the key, I had it on the container, but it just kept adding keys to the npc, lol.

Im guessing when the key is activated its just unlocking the container, the script needs something else to remove the key? Any suggestions?

Link to comment
Share on other sites

I tested this setup on my computer and it works for me:

 

SCN AADisappearingKeySCRIPT

; Object script applied to Chest AAGoodyChest which opens only with AAGoodyChestKey.
; The NPC is a persistent reference with the reference ID "AAEasyVictimNPCref."
; When you open the chest, the key instantly goes back to the NPC's pocket. 

Begin OnActivate
If Player.GetItemCount AAGoodyChestKey >= 1
	Activate
    	        Player.RemoveItem 01000EEA 1  ;  Where 01000EEA == Base ID# of AAGoodyChestKey
   		AAEasyVictimNPCref.AddItem AAGoodyChestKey 1
Else
	Activate   	
EndIf
End
  

 

On my computer, even the old buggy script would remove my key. So I think you are experiencing the well-documented Oblivion bug where the computer will not remove items you tell it to remove. Sometimes you tell it to remove 10 items and it will only remove 6. Sometimes it won't remove any. You can often get it to work if you use Base ID Numbers instead of colloquial names.

 

Let me know if this script still isn't working for you.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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