Skip to content

Commit

Permalink
fix: getStreetInfo, getZone should accept position as an argument (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
floydya authored Jul 12, 2024
1 parent 262b8c1 commit 4d1d386
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/client/system/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ function update() {
seat: alt.Player.local.vehicle ? alt.Player.local.seat : 0,
speed: alt.Player.local.vehicle ? native.getEntitySpeed(alt.Player.local.vehicle) : alt.Player.local.moveSpeed,
stamina: alt.Player.local.stamina,
street: getStreetInfo(alt.Player.local),
street: getStreetInfo(alt.Player.local.pos),
time: { hour, minute, second },
vehicleClass: alt.Player.local.vehicle ? native.getVehicleClass(alt.Player.local.vehicle) : -1,
vehicleHealth: alt.Player.local.vehicle ? native.getVehicleEngineHealth(alt.Player.local.vehicle) : 0,
weapon: alt.Player.local.currentWeapon,
weather: getPreviousWeatherType(),
zone: getZone(),
zone: getZone(alt.Player.local.pos),
};

view.emit(Events.localPlayer.stats.set, stats);
Expand Down
9 changes: 5 additions & 4 deletions src/main/client/utility/world/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export function getPreviousWeatherType() {
return WeatherHashes[native.getPrevWeatherTypeHashName()];
}

export function getStreetInfo(entity: alt.Player | alt.Vehicle) {
const [_, streetNameHash, crossingRoadHash] = native.getStreetNameAtCoord(entity.pos.x, entity.pos.y, entity.pos.z);

export function getStreetInfo(pos: alt.Vector3) {
const [_, streetNameHash, crossingRoadHash] = native.getStreetNameAtCoord(pos.x, pos.y, pos.z);

const streetName = native.getStreetNameFromHashKey(streetNameHash);
const crossingRoad = native.getStreetNameFromHashKey(crossingRoadHash);
Expand All @@ -38,6 +39,6 @@ export function getDirection(entity: alt.Player | alt.Vehicle) {
return directions[index];
}

export function getZone() {
return ZoneNames[native.getNameOfZone(alt.Player.local.pos.x, alt.Player.local.pos.y, alt.Player.local.pos.z)];
export function getZone(pos: alt.Vector3) {
return ZoneNames[native.getNameOfZone(pos.x, pos.y, pos.z)];
}

0 comments on commit 4d1d386

Please sign in to comment.