Jump to content

Teleport player on item pickup.


gob2

Recommended Posts

I would like to make a specific item that when picked up the player gets teleported to a particular place in a different cell and the item is removed. Looking for advice on how to do that. Thank you.

Link to comment
Share on other sites

Try attaching this script to your object. Not sure itll work mind you.

Scriptname item_teleport_script extends ObjectReference

itemtype property cursedobject auto const
Marker property BobsHouseMarker auto const

Event OnActivate(ObjectReference akActionRef)
	if akActionRef == Game.GetPlayer()
		Game.GetPlayer().MoveTo(BobsHouseMarker)
		Game.GetPlayer().RemoveItem(cursedobject)
	endif
EndEvent
Link to comment
Share on other sites

Try attaching this script to your object. Not sure itll work mind you.

Scriptname item_teleport_script extends ObjectReference

itemtype property cursedobject auto const
Marker property BobsHouseMarker auto const

Event OnActivate(ObjectReference akActionRef)
	if akActionRef == Game.GetPlayer()
		Game.GetPlayer().MoveTo(BobsHouseMarker)
		Game.GetPlayer().RemoveItem(cursedobject)
	endif
EndEvent

 

I think the more widely accepted method would be to remove self then teleport.

 

Scriptname item_teleport_script extends ObjectReference
 
Marker property BobsHouseMarker auto const
 
Event OnActivate(ObjectReference akActionRef)
    if akActionRef == Game.GetPlayer()
        ; since we already validated the activating ref is the player we can reuse it instead of wasting cycles re-calling Game.GetPlayer() again.
        akActionRef.RemoveItem(self)
        akActionRef.MoveTo(BobsHouseMarker)
    endif
EndEvent
Edited by BigAndFlabby
Link to comment
Share on other sites

I don't think onActivate is the best method to use for detecting when specific item is added to player, as it may is added from container or is just given to player. I recommend to use onContainerChanged. Like this (attach to your object):

 

ObjectReference Property mymarker auto

 

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

If akNewContainer == Game.getplayer()

Game.getplayer().removeitem(self,1,true)

Game.getplayer().Moveto(mymarker)

Endif

Endevent

 

 

Don't forget to fill mymarker property with the needed reference (it may be marker or any other reference)

Link to comment
Share on other sites

I don't think onActivate is the best method to use for detecting when specific item is added to player, as it may is added from container or is just given to player. I recommend to use onContainerChanged. Like this (attach to your object):

 

ObjectReference Property mymarker auto

 

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

If akNewContainer == Game.getplayer()

Game.getplayer().removeitem(self,1,true)

Game.getplayer().Moveto(mymarker)

Endif

Endevent

 

 

Don't forget to fill mymarker property with the needed reference (it may be marker or any other reference)

 

Well OP did say "picked up". Though you're right. The onContainerChanged will ensure that it enters the player inventory.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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