diff --git a/ReallifeGamemode.Client/core/rage-mp/entities.ts b/ReallifeGamemode.Client/core/rage-mp/entities.ts index 9073acc4..2a855054 100644 --- a/ReallifeGamemode.Client/core/rage-mp/entities.ts +++ b/ReallifeGamemode.Client/core/rage-mp/entities.ts @@ -147,7 +147,7 @@ class RageEntityAttachmentPool implements IEntityAttachmentPool { let e = new RageAttachments(entity, attachments, attachmentObjects); this.attachmentPool.push(e); - return e; + return e; } at(remoteId: any): IEntityAttachments { @@ -188,6 +188,10 @@ class RagePlayerPool implements IPlayerPool { fn(new RagePlayer(e)); }); } + + exists(entity: IPlayer): boolean { + return mp.players.exists(entity.id); + } } @@ -280,6 +284,10 @@ class RageVehiclePool implements IVehiclePool { fn(new RageVehicle(e)); }) } + + exists(entity: IVehicle): boolean { + return mp.vehicles.exists(entity.id); + } } export { @@ -290,5 +298,5 @@ export { RageEntityAttachmentPool, RageVehicle, RageVehiclePool, - + } \ No newline at end of file diff --git a/ReallifeGamemode.Client/core/rage-mp/game.ts b/ReallifeGamemode.Client/core/rage-mp/game.ts index dc4e1514..5094ba9f 100644 --- a/ReallifeGamemode.Client/core/rage-mp/game.ts +++ b/ReallifeGamemode.Client/core/rage-mp/game.ts @@ -10,8 +10,8 @@ export default class RageGame implements IGame { events: IEvents = new RageEvents; ui: IUi = new RageUi; - async wait(ms: number): Promise { - await mp.game.waitAsync(ms); + wait(ms: number): void { + mp.game.wait(ms); } disableDefaultEngineBehaviour(): void { diff --git a/ReallifeGamemode.Client/game.ts b/ReallifeGamemode.Client/game.ts index db02729b..c201e07d 100644 --- a/ReallifeGamemode.Client/game.ts +++ b/ReallifeGamemode.Client/game.ts @@ -1,5 +1,5 @@ interface IGame { - wait(ms: number): Promise; + wait(ms: number): void; events: IEvents; ui: IUi; @@ -75,6 +75,7 @@ interface IVehicle extends IEntity { interface IEntityPool { at(id: number): TEntity; forEach(fn: (entity: TEntity) => void): void; + exists(entity: TEntity): boolean; } diff --git a/ReallifeGamemode.Client/util/attachmentMngr.ts b/ReallifeGamemode.Client/util/attachmentMngr.ts index bb62ee5d..d46da114 100644 --- a/ReallifeGamemode.Client/util/attachmentMngr.ts +++ b/ReallifeGamemode.Client/util/attachmentMngr.ts @@ -15,7 +15,7 @@ export default function attachmentManager(game: IGame) { { attachments: {}, - addFor: async function (entity, id) { + addFor: function (entity, id) { if (this.attachments.hasOwnProperty(id)) { if (!entity.__attachmentObjects) { entity.__attachmentObjects = {}; diff --git a/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts b/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts index f7989e42..d30322da 100644 --- a/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts +++ b/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts @@ -10,9 +10,9 @@ game.events.add('SERVER:Vehicle:UpdateData', (vehId, dataStr) => { setVehicleData(vehicle, data); }); -game.events.onPlayerEnterVehicle(async (vehicle, seat) => { +game.events.onPlayerEnterVehicle((vehicle, seat) => { while (!game.players.local.inVehicle) { - await game.wait(0); + game.wait(0); } if (vehicle) { @@ -22,11 +22,11 @@ game.events.onPlayerEnterVehicle(async (vehicle, seat) => { } }); -game.events.onPlayerExitVehicle(async () => { +game.events.onPlayerExitVehicle(() => { var veh = game.players.local.vehicle; while (game.players.local.inVehicle) { - await game.wait(0); + game.wait(0); } if (veh) { @@ -51,7 +51,7 @@ game.events.onEntityStreamIn((entity: IEntity) => { }); function setVehicleData(veh: IVehicle, data: VehicleData): void { - if (!veh) { + if (!veh || !game.vehicles.exists(veh)) { return; }