Skip to content

Commit

Permalink
Dev (#25)
Browse files Browse the repository at this point in the history
* fix: getVariable return type in client-side (#24)

* chore: bump version to 1.0.2

---------

Co-authored-by: ghosty <[email protected]>
  • Loading branch information
Jengas and ghosty2004 authored Apr 25, 2024
1 parent bc4931b commit 1d50627
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bindings/src/client/entities/Colshape.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions bindings/src/client/entities/Object.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions bindings/src/client/entities/Ped.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions bindings/src/client/entities/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions bindings/src/client/entities/Vehicle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions bindings/src/client/entities/WorldObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions bindings/src/client/entities/label/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 1d50627

Please sign in to comment.