Teleporting to variable positions in interior, and especially exterior locations is not trivial, there are issues with surrounding cells not loading properly (meaning part of the landscape may not be rendered) or crashes. One solution was suggested by Aftershock_81:
COE 0 0
Player->SetPos x xpos
Player->SetPos x ypos
Player->SetPos x zpos
FixMe
where FixMe is meant to reload the destination cell to avoid the problem where SetPos does not force the cell to load correctly.
I only ever managed to get Aftershock's method to work via a local script, when I tried using a global script, everything worked, but I got an “Function greater than index count” error. A good example of using setpos and fixme can be found in Dongle's Ranger Tent mod, available on Planet Elder Scrolls.
If you use FixMe, you may also want to use SetPos again, as fixMe will move the player. It depends on how accurately you want to place the player.
Example script, by Nigedo (based on the work of Aftershock_81 and JOG)
Note: This script must be a local script. Attach it to an activator or door: It will not work as a global script!
Begin script_PlacePC
;Global Float Start_PCX
;Global Float Start_PCY
;Global Float Start_PCZ
Float xpos
Float ypos
Float zpos
Float timer
Short step
If ( OnActivate )
Set step to 1
Endif
If ( step == 1 )
FadeOut 0.1
ToggleMenus
Set step to 2
Return
Elseif ( step == 2 )
Set timer to ( timer + GetSecondsPassed )
If ( timer > 0.2 )
Set timer to 0
Set step to 3
Endif
Return
Elseif ( step == 3 )
Set step to 0
Player->COE 0 0
Set xpos to Start_PCX
Set ypos to Start_PCY
Set zpos to Start_PCZ
ToggleMenus
MenuTest
MenuTest
Player->SetPos x xpos
Player->SetPos y ypos
Player->SetPos z zpos
FixMe
Player->SetPos x xpos
Player->SetPos y ypos
Player->SetPos z zpos
FadeIn 0.1
Endif
End
If it is not possible to simply attach the script to an activate-able item, one alternative is to have another script (global or local) place an item in the player's inventory temporarily, with a teleport script attached to the inventory item (thanks to Kaos_nyrb and Nigedo).