<-- Back to Snippets

Teleport to Waypoint

Description

Used to teleport to a waypoint a player has placed on their map.

Snippet

server-side

alt.emitClient(somePlayer, 'triggerTP');

client-side

alt.onServer('triggerTP', tpToWaypoint)

function tpToWaypoint() {
    var waypoint = native.getFirstBlipInfoId(8);

    if (native.doesBlipExist(waypoint)) {
        var coords = native.getBlipInfoIdCoord(waypoint);
        alt.Player.local.pos = coords;

        var res = native.getGroundZFor3dCoord(coords.x, coords.y, coords.z + 100, undefined, undefined);

        coords.z = res + 1;
        alt.emitServer('doTheTeleport', coords);
    }
}

Example

server-side

alt.onClient('doTheTeleport', (player, coords) => {
    player.pos = coords;
});

results matching ""

    No results matching ""