ItsMods

Full Version: Help with teleport code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using this snippet of code for adding teleport to a mod:

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?
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, 0 ) ), 0, self )[ "position" ];
        self SetOrigin( newLocation );
        self SetPlayerAngles( directionYaw );
        self endLocationSelection();
        self.selectingLocation = undefined;
    }
}

I think this should work.
Thanks, Big Grin

I'll give it a try and let you know.