Skip to content

Commit

Permalink
client: refactor tp to waypoint a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
xxshady committed Aug 14, 2022
1 parent 2789cdc commit e94390e
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions freeroam-extended/client/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,8 @@ export async function tpToWaypoint(): Promise<void> {
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

Expand All @@ -222,7 +220,7 @@ export async function tpToWaypoint(): Promise<void> {
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
Expand All @@ -247,13 +245,11 @@ export async function tpToWaypoint(): Promise<void> {
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
}
Expand Down

0 comments on commit e94390e

Please sign in to comment.