From e94390ef50ca82329cfaee798dfd76d866c55e02 Mon Sep 17 00:00:00 2001 From: xshady Date: Sun, 14 Aug 2022 18:53:24 +0300 Subject: [PATCH] client: refactor tp to waypoint a little bit --- freeroam-extended/client/src/helpers.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/freeroam-extended/client/src/helpers.ts b/freeroam-extended/client/src/helpers.ts index d03c22c..0bebb59 100644 --- a/freeroam-extended/client/src/helpers.ts +++ b/freeroam-extended/client/src/helpers.ts @@ -192,10 +192,8 @@ export async function tpToWaypoint(): Promise { return } - const [x, y, z] = point - - native.setFocusPosAndVel(x, y, z, 0, 0, 0) - const startPos = new alt.Vector3(x, y, 1500) + alt.FocusData.overrideFocus(point) + const startPos = new alt.Vector3(point.x, point.y, 1500) let destPos = startPos let groundPos: alt.Vector3 | null = null @@ -222,7 +220,7 @@ export async function tpToWaypoint(): Promise { let foundZ: number | null = null try { await alt.Utils.waitFor(() => { - const [found, z] = native.getGroundZAndNormalFor3dCoord(x, y, 9999) + const [found, z] = native.getGroundZAndNormalFor3dCoord(point.x, point.y, 9999) if (!found) return false foundZ = z @@ -247,13 +245,11 @@ export async function tpToWaypoint(): Promise { alt.FocusData.clearFocus() } -function getWaypoint(sprite = 8): [number, number, number, number] | null { +function getWaypoint(sprite = 8): alt.Vector3 | null { const waypoint = native.getFirstBlipInfoId(sprite) - if (native.doesBlipExist(waypoint)) { - const coords = native.getBlipInfoIdCoord(waypoint) - return [coords.x, coords.y, coords.z, waypoint] - } + if (native.doesBlipExist(waypoint)) + return native.getBlipInfoIdCoord(waypoint) return null }