Removing item from ground via script

Post » Tue Jun 19, 2012 6:56 pm

Hi.

I wanna know how to remove an item from the ground using a script that is already attached to the item.
I also want to add the same item to the players inventory after it has been removed from the ground. -Basically I want the player to pick up an item that normally can't be picked up.


EDIT: I tried doing this, but of course it doesn't work:

event OnActivate(objectReference TriggerRef)   RemoveItem(TriggerRef, 1, true)   Game.GetPlayer().AddItem(TriggerRef, 1, true)endEvent

-I thought "TriggerRef" would mean the object that is being activated (the one I want to pick up).
-I have no idea how to add the item to the player, I just tried something and the script compiled and saved so I thought I did it right by accident.


EDIT #2: The item I want to pick up is an activator - a Bear trap, to be exact.
User avatar
Monique Cameron
 
Posts: 3430
Joined: Fri Jun 23, 2006 6:30 am

Post » Tue Jun 19, 2012 8:09 pm

*bump*
User avatar
Dean
 
Posts: 3438
Joined: Fri Jul 27, 2007 4:58 pm

Post » Tue Jun 19, 2012 11:45 pm

er... the player can't pick it up, so I'm guessing it's an Activator or something. You might need to provide more details of what you are doing

scriptname MyImovableScript extends ObjectReferenceForm Property MiscImovable Auto ; This is some Misc Object, ie a normal inventory object.Event OnInit()  BlockActivation() ; Disable normal activation of this object type, force script to control itEndEventEvent OnActivate(ObjectReference akActionRef))  Actor player = Game.GetPlayer()  If akActionRef == player    If OkToPickUpNow()      player.AddItem(MiscImovable)      Delete()    EndIf  EndIfEndEventint Function OkToPickUpNow()  ; If you have conditions where the player should not get the item, test them here return 0  return 1 ; yes can have itEndFunction
User avatar
Joanne
 
Posts: 3357
Joined: Fri Oct 27, 2006 1:25 pm

Post » Tue Jun 19, 2012 4:54 pm

Looking at your script I found out that I needed "Delete()".
Now the activator (bear trap) is properly removed when I activate the trap.
Thanks.

Now I need to add a "dummy item" to the player's inventory that when I use it creates a bear trap on the floor in front of the player.

EDIT: How do I create an activator with a script?
User avatar
Mariaa EM.
 
Posts: 3347
Joined: Fri Aug 10, 2007 3:28 am


Return to V - Skyrim