From 32e864c65cc8fb0c6dafed5bdef130dfcde20052 Mon Sep 17 00:00:00 2001 From: dockfries Date: Tue, 30 Jan 2024 19:42:02 +0800 Subject: [PATCH] feat(core)!: remove deprecated pool size functions --- packages/core/src/controllers/player/checker.ts | 8 +++----- packages/core/src/controllers/player/entity.ts | 3 --- packages/core/src/controllers/player/event.ts | 2 ++ packages/core/src/controllers/vehicle/entity.ts | 3 --- packages/core/src/wrapper/native/functions/index.ts | 12 ------------ 5 files changed, 5 insertions(+), 23 deletions(-) diff --git a/packages/core/src/controllers/player/checker.ts b/packages/core/src/controllers/player/checker.ts index b86627a..e15e71c 100644 --- a/packages/core/src/controllers/player/checker.ts +++ b/packages/core/src/controllers/player/checker.ts @@ -1,7 +1,6 @@ import { Player } from "./entity"; import { PlayerStateEnum } from "../../enums"; import { defineEvent } from "../bus"; -import { Dialog } from "./dialog"; import { onConnect, onDisconnect, onUpdate } from "./event"; let pauseChecker: null | NodeJS.Timeout = null; @@ -23,7 +22,7 @@ export const [onResume, triggerOnResume] = defineEvent({ }); onConnect(({ next }) => { - if (!pauseChecker && Player.getPoolSize() > -1) { + if (!pauseChecker && Player.getInstances().length) { pauseChecker = setInterval(() => { const activePlayers = Player.getInstances().filter((p) => { const activeState = p.getState() !== PlayerStateEnum.NONE; @@ -41,12 +40,11 @@ onConnect(({ next }) => { return next(); }); -onDisconnect(({ player, next }) => { - if (pauseChecker && Player.getPoolSize() <= 0) { +onDisconnect(({ next }) => { + if (pauseChecker && Player.getInstances().length <= 1) { clearInterval(pauseChecker); pauseChecker = null; } - Dialog.close(player); return next(); }); diff --git a/packages/core/src/controllers/player/entity.ts b/packages/core/src/controllers/player/entity.ts index 9ade59c..894b0be 100644 --- a/packages/core/src/controllers/player/entity.ts +++ b/packages/core/src/controllers/player/entity.ts @@ -418,9 +418,6 @@ export class Player { ): number { return f.PlayerPlaySound(this.id, soundid, relativeX, relativeY, relativeZ); } - static getPoolSize(): number { - return f.GetPlayerPoolSize(); - } static getMaxPlayers(): number { return f.GetMaxPlayers(); } diff --git a/packages/core/src/controllers/player/event.ts b/packages/core/src/controllers/player/event.ts index 167d816..8ca18e6 100644 --- a/packages/core/src/controllers/player/event.ts +++ b/packages/core/src/controllers/player/event.ts @@ -9,12 +9,14 @@ import type { WeaponEnum, } from "../../enums"; import { InvalidEnum } from "../../enums"; +import { Dialog } from "./dialog"; export const [onConnect] = defineEvent({ name: "OnPlayerConnect", beforeEach(id: number) { const player = new Player(id); Player.players.set(id, player); + Dialog.close(player); return { player }; }, }); diff --git a/packages/core/src/controllers/vehicle/entity.ts b/packages/core/src/controllers/vehicle/entity.ts index f101d47..0bdce62 100644 --- a/packages/core/src/controllers/vehicle/entity.ts +++ b/packages/core/src/controllers/vehicle/entity.ts @@ -179,9 +179,6 @@ export class Vehicle { } return v.SetVehicleNumberPlate(this.id, numberplate); } - static getPoolSize(): number { - return v.GetVehiclePoolSize(); - } changeColors(color1: string | number, color2: string | number): number { if (this.id === -1) return 0; return v.ChangeVehicleColors(this.id, color1, color2); diff --git a/packages/core/src/wrapper/native/functions/index.ts b/packages/core/src/wrapper/native/functions/index.ts index 737c2c9..fed0fd2 100644 --- a/packages/core/src/wrapper/native/functions/index.ts +++ b/packages/core/src/wrapper/native/functions/index.ts @@ -99,18 +99,6 @@ export const VectorSize = ( return callNativeFloat("VectorSize", "ffffff", x1, y1, z1, x2, y2, z2); }; -export const GetPlayerPoolSize = (): number => { - return callNative("GetPlayerPoolSize", ""); -}; - -export const GetVehiclePoolSize = (): number => { - return callNative("GetVehiclePoolSize", ""); -}; - -export const GetActorPoolSize = (): number => { - return callNative("GetActorPoolSize", ""); -}; - export const SetGameModeText = (string: string): number => { return callNative("SetGameModeText", "s", string); };