Skip to content

Commit

Permalink
Fix Street PlayerStat (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
MnkyArts authored Jun 10, 2024
1 parent 9ff6edf commit aa0a501
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions webview/composables/usePlayerStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { VehicleIndicatorLights } from 'alt-client';

const events = useEvents();

type StreetName = string;
type CrossingRoad = string;
type StreetData = {
streetName: string;
crossingRoad: string;
};

type Stats = {
health: number;
Expand All @@ -27,7 +29,7 @@ type Stats = {
ping: number;
isTalking: boolean;
time: [void, number, number, number, number, number, number];
street: [StreetName, CrossingRoad];
street: StreetData;
direction: string;
weather: string;
indicatorLights: VehicleIndicatorLights;
Expand All @@ -53,7 +55,7 @@ const data = ref<Stats>({
ping: 0,
isTalking: false,
time: [null, 0, 0, 0, 0, 0, 0],
street: ['', ''],
street: { streetName: '', crossingRoad: '' },
direction: '',
weather: '',
indicatorLights: 0,
Expand Down Expand Up @@ -101,10 +103,7 @@ export function usePlayerStats() {
(time: [void, number, number, number, number, number, number]) => (data.value.time = time),
);

events.on(
Events.localPlayer.stats.street,
(street: [StreetName, CrossingRoad]) => (data.value.street = street),
);
events.on(Events.localPlayer.stats.street, (street: StreetData) => (data.value.street = street));

events.on(Events.localPlayer.stats.direction, (direction: string) => (data.value.direction = direction));

Expand Down Expand Up @@ -166,14 +165,14 @@ export function usePlayerStats() {
return data.value.time;
}),
street: computed(() => {
return data.value.street[0];
return data.value.street.streetName;
}),
crossingRoad: computed(() => {
return data.value.street.crossingRoad;
}),
direction: computed(() => {
return data.value.direction;
}),
crossingRoad: computed(() => {
return data.value.street[1];
}),
weather: computed(() => {
return data.value.weather;
}),
Expand Down

0 comments on commit aa0a501

Please sign in to comment.