diff --git a/src/main/server/controllers/markers.ts b/src/main/server/controllers/markers.ts index 4528da125..b13ff898b 100644 --- a/src/main/server/controllers/markers.ts +++ b/src/main/server/controllers/markers.ts @@ -1,7 +1,7 @@ -import * as alt from 'alt-server'; -import * as Utility from '@Shared/utility/index.js'; -import { Marker, MarkerType } from '@Shared/types/marker.js'; import { Events } from '@Shared/events/index.js'; +import { Marker, MarkerType } from '@Shared/types/marker.js'; +import * as Utility from '@Shared/utility/index.js'; +import * as alt from 'alt-server'; const GroupType = 'marker'; const MAX_MARKERS = 10; @@ -28,15 +28,13 @@ export function useMarkerGlobal(marker: Marker, maxDistance: number = 50) { marker.uid = Utility.uid.generate(); } - if (!marker.dimension) { - marker.dimension = 0; - } - let entity = new alt.VirtualEntity(markerGroup, new alt.Vector3(marker.pos), maxDistance, { type: GroupType, marker, }); + entity.dimension = marker.dimension ? marker.dimension : 0; + function destroy() { try { entity.destroy(); @@ -53,6 +51,10 @@ export function useMarkerGlobal(marker: Marker, maxDistance: number = 50) { type: GroupType, marker, }); + + if (newMarker.dimension !== entity.dimension) { + entity.dimension = newMarker.dimension ? newMarker.dimension : 0; + } } return { diff --git a/src/main/server/controllers/progressbar.ts b/src/main/server/controllers/progressbar.ts index d077d5e52..cd0515bcb 100644 --- a/src/main/server/controllers/progressbar.ts +++ b/src/main/server/controllers/progressbar.ts @@ -1,6 +1,6 @@ -import * as alt from 'alt-server'; -import * as Utility from '@Shared/utility/index.js'; import { Events } from '@Shared/events/index.js'; +import * as Utility from '@Shared/utility/index.js'; +import * as alt from 'alt-server'; import { ProgressBar } from '../../shared/types/progressBar.js'; const GroupType = 'progressbar'; @@ -29,10 +29,6 @@ export function useProgressbarGlobal(progressbar: ProgressBar, isTimer = false, progressbar.uid = Utility.uid.generate(); } - if (!progressbar.dimension) { - progressbar.dimension = 0; - } - if (isTimer) { interval = alt.setInterval(() => { updateProgress(progressbar.value + 1); @@ -45,6 +41,8 @@ export function useProgressbarGlobal(progressbar: ProgressBar, isTimer = false, progressbar, }); + entity.dimension = progressbar.dimension ? progressbar.dimension : 0; + function destroy() { try { entity.destroy(); diff --git a/src/main/server/controllers/textlabel.ts b/src/main/server/controllers/textlabel.ts index d221479c9..06b0dda2f 100644 --- a/src/main/server/controllers/textlabel.ts +++ b/src/main/server/controllers/textlabel.ts @@ -1,7 +1,7 @@ -import * as alt from 'alt-server'; -import * as Utility from '@Shared/utility/index.js'; -import { TextLabel } from '@Shared/types/textLabel.js'; import { Events } from '@Shared/events/index.js'; +import { TextLabel } from '@Shared/types/textLabel.js'; +import * as Utility from '@Shared/utility/index.js'; +import * as alt from 'alt-server'; const GroupType = 'textlabel'; const MAX_LABELS = 10; @@ -29,14 +29,16 @@ export function useTextLabelGlobal(label: TextLabel, maxDistance: number = 20) { textlabel: label, }); + entity.dimension = label.dimension ? label.dimension : 0; + function destroy() { try { entity.destroy(); } catch (err) {} } - function update(newMarker: Partial) { - label = Object.assign(label, newMarker); + function update(newTextLabel: Partial) { + label = Object.assign(label, newTextLabel); try { entity.destroy(); } catch (err) {} @@ -45,6 +47,10 @@ export function useTextLabelGlobal(label: TextLabel, maxDistance: number = 20) { type: GroupType, textlabel: label, }); + + if (newTextLabel.dimension !== entity.dimension) { + entity.dimension = newTextLabel.dimension ? newTextLabel.dimension : 0; + } } return {