Skip to content

Commit

Permalink
feat(core)!: remove deprecated pool size functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dockfries committed Jan 30, 2024
1 parent 8a79286 commit 32e864c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 23 deletions.
8 changes: 3 additions & 5 deletions packages/core/src/controllers/player/checker.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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();
});

Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/controllers/player/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/controllers/player/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
},
});
Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/controllers/vehicle/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 0 additions & 12 deletions packages/core/src/wrapper/native/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down

0 comments on commit 32e864c

Please sign in to comment.