From 1d5062753a8b786e8f55717e0be9d9f0943c1722 Mon Sep 17 00:00:00 2001 From: Jengas Date: Thu, 25 Apr 2024 10:56:58 +0200 Subject: [PATCH] Dev (#25) * fix: getVariable return type in client-side (#24) * chore: bump version to 1.0.2 --------- Co-authored-by: ghosty --- bindings/src/client/entities/Colshape.js | 2 +- bindings/src/client/entities/Object.js | 8 ++++---- bindings/src/client/entities/Ped.js | 4 ++-- bindings/src/client/entities/Player.js | 4 ++-- bindings/src/client/entities/Vehicle.js | 4 ++-- bindings/src/client/entities/WorldObject.js | 7 +++---- bindings/src/client/entities/label/Label.js | 8 ++++---- package.json | 2 +- 8 files changed, 19 insertions(+), 20 deletions(-) diff --git a/bindings/src/client/entities/Colshape.js b/bindings/src/client/entities/Colshape.js index 1a300a0..9d42a20 100644 --- a/bindings/src/client/entities/Colshape.js +++ b/bindings/src/client/entities/Colshape.js @@ -131,7 +131,7 @@ function getServerColshape(id, position, dimension, type, meta) { remoteId: id, shapeType: type, getVariable(key) { - return meta[key] ?? null; + return meta[key]; }, hasVariable(key) { return key in meta; diff --git a/bindings/src/client/entities/Object.js b/bindings/src/client/entities/Object.js index ad41d38..3809319 100644 --- a/bindings/src/client/entities/Object.js +++ b/bindings/src/client/entities/Object.js @@ -36,8 +36,8 @@ export class _Object extends _Entity { type = 'object'; getVariable(key) { - if (!this.hasVariable(key)) return null; - return toMp(this.alt.getMeta(key)) ?? null; + if (!this.hasVariable(key)) return; + return toMp(this.alt.getMeta(key)); } hasVariable(key) { @@ -209,8 +209,8 @@ export class _NetworkObject extends _Object { } getVariable(key) { - if (!this.hasVariable(key)) return null; - return toMp(this.alt.getStreamSyncedMeta(key)) ?? null; + if (!this.hasVariable(key)) return; + return toMp(this.alt.getStreamSyncedMeta(key)); } hasVariable(key) { diff --git a/bindings/src/client/entities/Ped.js b/bindings/src/client/entities/Ped.js index 4b1e90b..6abd9fe 100644 --- a/bindings/src/client/entities/Ped.js +++ b/bindings/src/client/entities/Ped.js @@ -821,8 +821,8 @@ export class _LocalPed extends _Ped { } getVariable(key) { - if (!this.hasVariable(key)) return null; - return toMp(this.alt.getMeta(key)) ?? null; + if (!this.hasVariable(key)) return; + return toMp(this.alt.getMeta(key)); } setVariable(key, value) { diff --git a/bindings/src/client/entities/Player.js b/bindings/src/client/entities/Player.js index f4428c6..4d278ac 100644 --- a/bindings/src/client/entities/Player.js +++ b/bindings/src/client/entities/Player.js @@ -19,8 +19,8 @@ export class _Player extends _Entity { } getVariable(key) { - if (!this.alt.valid) return null; - if (this.alt === alt.Player.local && alt.hasLocalMeta(key)) return toMp(alt.getLocalMeta(key)) ?? null; + if (!this.alt.valid) return; + if (this.alt === alt.Player.local && alt.hasLocalMeta(key)) return toMp(alt.getLocalMeta(key)); return super.getVariable(key); } diff --git a/bindings/src/client/entities/Vehicle.js b/bindings/src/client/entities/Vehicle.js index 1ec07ba..d570c09 100644 --- a/bindings/src/client/entities/Vehicle.js +++ b/bindings/src/client/entities/Vehicle.js @@ -524,8 +524,8 @@ export class _LocalVehicle extends _Vehicle { // TODO: override natives to use pos setter getVariable(key) { - if (!this.hasVariable(key)) return null; - return toMp(this.alt.getMeta(key)) ?? null; + if (!this.hasVariable(key)) return; + return toMp(this.alt.getMeta(key)); } setVariable(key, value) { diff --git a/bindings/src/client/entities/WorldObject.js b/bindings/src/client/entities/WorldObject.js index 71cb45c..bf8e605 100644 --- a/bindings/src/client/entities/WorldObject.js +++ b/bindings/src/client/entities/WorldObject.js @@ -14,10 +14,9 @@ export class _WorldObject extends _BaseObject { } getVariable(key) { - if (!this.alt.valid) return null; - if (this.#alt.getStreamSyncedMeta && this.#alt.hasStreamSyncedMeta(key)) return toMp(this.#alt.getStreamSyncedMeta(key)) ?? null; - if (this.#alt.hasSyncedMeta(key)) return toMp(this.#alt.getSyncedMeta(key)) ?? null; - return null; + if (!this.alt.valid) return; + if (this.#alt.getStreamSyncedMeta && this.#alt.hasStreamSyncedMeta(key)) return toMp(this.#alt.getStreamSyncedMeta(key)); + if (this.#alt.hasSyncedMeta(key)) return toMp(this.#alt.getSyncedMeta(key)); } hasVariable(key) { diff --git a/bindings/src/client/entities/label/Label.js b/bindings/src/client/entities/label/Label.js index 75c3ad1..b3626b7 100644 --- a/bindings/src/client/entities/label/Label.js +++ b/bindings/src/client/entities/label/Label.js @@ -48,12 +48,12 @@ export class _Label extends _VirtualEntityBase { getVariable(key) { if (this.alt.isRemote) { - if (!this.alt.hasStreamSyncedMeta(key)) return null; - return toMp(this.alt.getStreamSyncedMeta(key)) ?? null; + if (!this.alt.hasStreamSyncedMeta(key)) return; + return toMp(this.alt.getStreamSyncedMeta(key)); } - if (!this.alt.hasMeta(key)) return null; - return toMp(this.alt.getMeta(key)) ?? null; + if (!this.alt.hasMeta(key)) return undefined; + return toMp(this.alt.getMeta(key)); } setVariable(key, value) { diff --git a/package.json b/package.json index 181bd6a..92eb51b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ragemp-altv-bridge", - "version": "1.0.1", + "version": "1.0.2", "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",