Evtl. fix unerklärliche async client fehler
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -10,8 +10,8 @@ export default class RageGame implements IGame {
|
||||
events: IEvents = new RageEvents;
|
||||
ui: IUi = new RageUi;
|
||||
|
||||
async wait(ms: number): Promise<void> {
|
||||
await mp.game.waitAsync(ms);
|
||||
wait(ms: number): void {
|
||||
mp.game.wait(ms);
|
||||
}
|
||||
|
||||
disableDefaultEngineBehaviour(): void {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
interface IGame {
|
||||
wait(ms: number): Promise<void>;
|
||||
wait(ms: number): void;
|
||||
events: IEvents;
|
||||
ui: IUi;
|
||||
|
||||
@@ -75,6 +75,7 @@ interface IVehicle extends IEntity {
|
||||
interface IEntityPool<TEntity> {
|
||||
at(id: number): TEntity;
|
||||
forEach(fn: (entity: TEntity) => void): void;
|
||||
exists(entity: TEntity): boolean;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 = {};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user