Skip to content

Commit

Permalink
client: improve tp to waypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
xxshady committed Aug 8, 2022
1 parent e6e1f52 commit fb1ba8b
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions freeroam-extended/client/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ import { playerData } from "./playerdata"
export const LOCAL_PLAYER = alt.Player.local
export const EMPTY_WEAPON_HASH = 0xA2719263

export const playerData = {
areWeaponsDisabled: true,
areNametagsVisible: true,
lastCommandTimestamp: Date.now() - 10000,
lastMessageTimestamp: Date.now() - 10000,
chatState: false,
commandTimestamp: 0,
}

export function displayAdvancedNotification(
message: string,
title = "Title",
Expand Down Expand Up @@ -264,10 +255,14 @@ export function mhint(head: string, msg: string, time = 5): void {

export async function tpToWaypoint(): Promise<void> {
const point = getWaypoint()
if (!point) return
if (!point) {
alt.log("no waypoint to tp")
return
}

const [x, y, z] = point

native.setFocusPosAndVel(x, y, z, 0, 0, 0)
native.setFocusPosAndVel(x, y, 99999, 0, 0, 0)

let foundZ: number | null = null
try {
Expand All @@ -284,7 +279,7 @@ export async function tpToWaypoint(): Promise<void> {
if (foundZ == null)
alt.logError("failed to get ground z for waypoint")

alt.emitServer("tp_to_waypoint", x, y, foundZ ?? 9999)
alt.emitServer("tp_to_waypoint", x, y, (foundZ ?? 9999) + 1.0)

native.clearFocus()
}
Expand Down

0 comments on commit fb1ba8b

Please sign in to comment.