From 04538bddf2fa746e508379136bb79dd25473fae8 Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 11 May 2020 15:50:54 +0200 Subject: [PATCH] Attachment Sync: Fehlerbehebung bei Join --- ReallifeGamemode.Client/core/rage-mp/entities.ts | 6 +++--- ReallifeGamemode.Client/game.ts | 2 +- ReallifeGamemode.Client/util/attachmentMngr.ts | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ReallifeGamemode.Client/core/rage-mp/entities.ts b/ReallifeGamemode.Client/core/rage-mp/entities.ts index c40e5e00..654ce05e 100644 --- a/ReallifeGamemode.Client/core/rage-mp/entities.ts +++ b/ReallifeGamemode.Client/core/rage-mp/entities.ts @@ -8,7 +8,7 @@ class RageEntity implements IEntity { return this.entity.id; } - get remoteId(): any { + get remoteId(): number { return this.entity.remoteId; } @@ -79,10 +79,10 @@ class RageEntityAttachmentPool implements IEntityAttachmentPool { } find(entity: EntityMp): IEntityAttachments { - for (let i of this.attachmentPool.keys()) { + for (let i of this.attachmentPool.keys()) { let pool = this.attachmentPool[i]; for (let obj of pool.__attachmentObjects) { - if (entity == obj) { return pool;} + if (entity == obj) { return pool; } } } return null; diff --git a/ReallifeGamemode.Client/game.ts b/ReallifeGamemode.Client/game.ts index 6b32a90a..53b45caa 100644 --- a/ReallifeGamemode.Client/game.ts +++ b/ReallifeGamemode.Client/game.ts @@ -42,7 +42,7 @@ interface IBrowser { interface IEntity { id: number; - remoteId: any; + remoteId: number; type: EntityType; getSharedData(key: string): T; } diff --git a/ReallifeGamemode.Client/util/attachmentMngr.ts b/ReallifeGamemode.Client/util/attachmentMngr.ts index 79f54a6e..a7e85429 100644 --- a/ReallifeGamemode.Client/util/attachmentMngr.ts +++ b/ReallifeGamemode.Client/util/attachmentMngr.ts @@ -242,6 +242,11 @@ export default function attachmentManager(game: IGame) { function InitAttachmentsOnJoin() { game.players.forEach(_player => { let player = mp.players.at(_player.remoteId); + + if (!player) { + return; + } + let e = game.attachments.get(_player); if (e == null) { let __attachments = []; @@ -259,6 +264,11 @@ export default function attachmentManager(game: IGame) { game.vehicles.forEach(_veh => { let vehicle = mp.vehicles.at(_veh.remoteId); + + if (!vehicle) { + return; + } + let e = game.attachments.get(_veh); if (e == null) { let __attachments = [];