diff --git a/bindings/src/client/entities/Colshape.js b/bindings/src/client/entities/Colshape.js index 9d42a20..1a300a0 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]; + return meta[key] ?? null; }, hasVariable(key) { return key in meta; diff --git a/bindings/src/client/entities/Object.js b/bindings/src/client/entities/Object.js index 4097105..ad41d38 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 undefined; - return toMp(this.alt.getMeta(key)); + if (!this.hasVariable(key)) return null; + return toMp(this.alt.getMeta(key)) ?? null; } hasVariable(key) { @@ -209,8 +209,8 @@ export class _NetworkObject extends _Object { } getVariable(key) { - if (!this.hasVariable(key)) return undefined; - return toMp(this.alt.getStreamSyncedMeta(key)); + if (!this.hasVariable(key)) return null; + return toMp(this.alt.getStreamSyncedMeta(key)) ?? null; } hasVariable(key) { diff --git a/bindings/src/client/entities/Ped.js b/bindings/src/client/entities/Ped.js index c642670..4b1e90b 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 undefined; - return toMp(this.alt.getMeta(key)); + if (!this.hasVariable(key)) return null; + return toMp(this.alt.getMeta(key)) ?? null; } setVariable(key, value) { diff --git a/bindings/src/client/entities/Player.js b/bindings/src/client/entities/Player.js index ca3b678..f4428c6 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 undefined; - if (this.alt === alt.Player.local && alt.hasLocalMeta(key)) return toMp(alt.getLocalMeta(key)); + if (!this.alt.valid) return null; + if (this.alt === alt.Player.local && alt.hasLocalMeta(key)) return toMp(alt.getLocalMeta(key)) ?? null; return super.getVariable(key); } diff --git a/bindings/src/client/entities/Vehicle.js b/bindings/src/client/entities/Vehicle.js index e79bb64..1ec07ba 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 undefined; - return toMp(this.alt.getMeta(key)); + if (!this.hasVariable(key)) return null; + return toMp(this.alt.getMeta(key)) ?? null; } setVariable(key, value) { diff --git a/bindings/src/client/entities/WorldObject.js b/bindings/src/client/entities/WorldObject.js index b5d7e7e..71cb45c 100644 --- a/bindings/src/client/entities/WorldObject.js +++ b/bindings/src/client/entities/WorldObject.js @@ -14,10 +14,10 @@ export class _WorldObject extends _BaseObject { } getVariable(key) { - if (!this.alt.valid) return undefined; - 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)); - return undefined; + 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; } hasVariable(key) { diff --git a/bindings/src/client/entities/label/Label.js b/bindings/src/client/entities/label/Label.js index 4f67f05..75c3ad1 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 undefined; - return toMp(this.alt.getStreamSyncedMeta(key)); + if (!this.alt.hasStreamSyncedMeta(key)) return null; + return toMp(this.alt.getStreamSyncedMeta(key)) ?? null; } - if (!this.alt.hasMeta(key)) return undefined; - return toMp(this.alt.getMeta(key)); + if (!this.alt.hasMeta(key)) return null; + return toMp(this.alt.getMeta(key)) ?? null; } setVariable(key, value) { diff --git a/bindings/src/server/entities/Colshape.js b/bindings/src/server/entities/Colshape.js index b2688df..cc575c3 100644 --- a/bindings/src/server/entities/Colshape.js +++ b/bindings/src/server/entities/Colshape.js @@ -45,8 +45,8 @@ export class _Colshape extends _WorldObject { } getVariable(key) { - if (!this.hasVariable(key)) return undefined; - return toMp(this.alt.getMeta(key)); + if (!this.hasVariable(key)) return null; + return toMp(this.alt.getMeta(key)) ?? null; } destroy() { diff --git a/bindings/src/server/entities/Dummy.js b/bindings/src/server/entities/Dummy.js index 0f63e82..db6c8d3 100644 --- a/bindings/src/server/entities/Dummy.js +++ b/bindings/src/server/entities/Dummy.js @@ -27,7 +27,7 @@ class _MpEntity { } getVariable(key) { - return toMp(this.#meta[key]); + return toMp(this.#meta[key]) ?? null; } hasVariable(key) { diff --git a/bindings/src/server/entities/Entity.js b/bindings/src/server/entities/Entity.js index 6f8eeca..9fa2130 100644 --- a/bindings/src/server/entities/Entity.js +++ b/bindings/src/server/entities/Entity.js @@ -33,9 +33,9 @@ export class _Entity extends _WorldObject { } getStreamVariable(key) { - if (!mp._shareVariablesBetweenResources) return this.#streamVariableCache.get(key); - if (!this.hasStreamVariable(key)) return undefined; - return toMp(this.#alt.getStreamSyncedMeta(key)); + if (!mp._shareVariablesBetweenResources) return this.#streamVariableCache.get(key) ?? null; + if (!this.hasStreamVariable(key)) return null; + return toMp(this.#alt.getStreamSyncedMeta(key)) ?? null; } hasStreamVariable(key) { diff --git a/bindings/src/server/entities/WorldObject.js b/bindings/src/server/entities/WorldObject.js index db76bcc..df205fb 100644 --- a/bindings/src/server/entities/WorldObject.js +++ b/bindings/src/server/entities/WorldObject.js @@ -53,17 +53,17 @@ export class _WorldObject extends _BaseObject { getVariable(key) { if (!mp._shareVariablesBetweenResources) - return this.#variableCache.get(key); + return this.#variableCache.get(key) ?? null; - if (!this.hasVariable(key)) return undefined; + if (!this.hasVariable(key)) return null; if (this.#alt.hasLocalMeta && this.#alt.hasLocalMeta(key)) - return toMp(this.#alt.getLocalMeta(key)); + return toMp(this.#alt.getLocalMeta(key)) ?? null; if (!mp._syncedMeta && this.#alt.getStreamSyncedMeta) - return toMp(this.#alt.getStreamSyncedMeta(key)); + return toMp(this.#alt.getStreamSyncedMeta(key)) ?? null; - return toMp(this.#alt.getSyncedMeta(key)); + return toMp(this.#alt.getSyncedMeta(key)) ?? null; } hasVariable(key) {