05-28-2012, 15:13
I am using this snippet of code for adding teleport to a mod:
The problem is the destination height often teleports the player below the map. I tried changing the z coordinate to a higher number but this results in teleporting inside structures or players falling to their death.
Is their a way to get the players current z index and then just add 100? Or or their some better way to tackle this?
Code:
doTeleport()
{
self endon ( "disconnect" );
self endon ( "death" );
self notifyOnPlayerCommand("dpad_up", "+actionslot 1");
for(;;)
{
self waittill( "dpad_up" );
self beginLocationSelection( "map_artillery_selector", true, ( level.mapSize / 5.625 ) );
self.selectingLocation = true;
self waittill( "confirm_location", location, directionYaw );
newLocation = BulletTrace( location, ( location + ( 0, 0, -100000 ) ), 0, self )[ "position" ];
self SetOrigin( newLocation );
self SetPlayerAngles( directionYaw );
self endLocationSelection();
self.selectingLocation = undefined;
}
}
The problem is the destination height often teleports the player below the map. I tried changing the z coordinate to a higher number but this results in teleporting inside structures or players falling to their death.
Is their a way to get the players current z index and then just add 100? Or or their some better way to tackle this?