From 86a2cc14ea005d3b84249be4bfbd43d61a78f1d1 Mon Sep 17 00:00:00 2001 From: Jengas Date: Sat, 28 Dec 2024 21:43:30 +0400 Subject: [PATCH 1/2] update: add mp.nametags.returnRenderNametags(bool) option to disable nametags renderer --- bindings/src/client/statics/Nametags.js | 17 +++++++++++++++++ package.json | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bindings/src/client/statics/Nametags.js b/bindings/src/client/statics/Nametags.js index 0fc25f3..0b9888c 100644 --- a/bindings/src/client/statics/Nametags.js +++ b/bindings/src/client/statics/Nametags.js @@ -10,18 +10,23 @@ class _Nametags { #style; #healthStyle; #streamedPlayers = []; + #isNametagsProcessDisabled = false; constructor() { this.update(); alt.everyTick(this.#tick.bind(this)); alt.on('gameEntityCreate', (entity) => { + if (this.#isNametagsProcessDisabled) return; + if (entity && entity.type === BaseObjectType.Player) { this.#streamedPlayers.push(entity); } }); alt.on('gameEntityDestroy', (entity) => { + if (this.#isNametagsProcessDisabled) return; + if (entity && entity.type === BaseObjectType.Player) { const index = this.#streamedPlayers.indexOf(entity); if (index !== -1) this.#streamedPlayers.splice(index, 1); @@ -29,6 +34,8 @@ class _Nametags { }); alt.on('baseObjectRemove', (entity) => { + if (this.#isNametagsProcessDisabled) return; + if (entity && entity.type === BaseObjectType.Player) { const index = this.#streamedPlayers.indexOf(entity); if (index !== -1) this.#streamedPlayers.splice(index, 1); @@ -37,6 +44,8 @@ class _Nametags { } #tick() { + if (this.#isNametagsProcessDisabled) return mp.events.dispatchLocal('render'); + const correction = getRenderCorrection(); const res = alt.getScreenResolution(); const localPos = alt.Player.local.pos; @@ -127,6 +136,14 @@ class _Nametags { useScreen2dCoords = true; // todo orderByDistance // todo useScreen2dCoordss + + set returnRenderNametags(bool) { + this.#isNametagsProcessDisabled = !bool; + + if (this.#isNametagsProcessDisabled) { + this.#streamedPlayers = []; + } + } } mp.nametags = new _Nametags; diff --git a/package.json b/package.json index 18ba673..9c22843 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ragemp-altv-bridge", - "version": "1.0.13", + "version": "1.0.14", "description": "RAGE Multiplayer alt:V Bridge. This package provides a bridge between RAGE Multiplayer and alt:V. It allows you to use RAGEMP code in alt:V.", "keywords": [ "ragemp", From ba2d8252df489176dd2a077363f12277a179e0c6 Mon Sep 17 00:00:00 2001 From: Jengas Date: Sat, 28 Dec 2024 21:47:09 +0400 Subject: [PATCH 2/2] fix: typo fix update: add JSDoc to new parameter --- bindings/src/client/statics/Nametags.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bindings/src/client/statics/Nametags.js b/bindings/src/client/statics/Nametags.js index 0b9888c..a692371 100644 --- a/bindings/src/client/statics/Nametags.js +++ b/bindings/src/client/statics/Nametags.js @@ -44,7 +44,10 @@ class _Nametags { } #tick() { - if (this.#isNametagsProcessDisabled) return mp.events.dispatchLocal('render'); + if (this.#isNametagsProcessDisabled) { + mp.events.dispatchLocal('render'); + return; + } const correction = getRenderCorrection(); const res = alt.getScreenResolution(); @@ -137,6 +140,10 @@ class _Nametags { // todo orderByDistance // todo useScreen2dCoordss + /** + * Enables or disables the nametags rendering process. + * @param {boolean} bool - If true, enables the nametags rendering process; if false, disables it. + */ set returnRenderNametags(bool) { this.#isNametagsProcessDisabled = !bool;