From f6199988ab24ae148f311be920b0e357098c09a8 Mon Sep 17 00:00:00 2001 From: yucarl77 Date: Sat, 10 Sep 2022 14:14:14 +0800 Subject: [PATCH] feat: added some player functions --- src/controllers/player/basePlayer.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/controllers/player/basePlayer.ts b/src/controllers/player/basePlayer.ts index eb34c13..fd428b2 100644 --- a/src/controllers/player/basePlayer.ts +++ b/src/controllers/player/basePlayer.ts @@ -91,6 +91,9 @@ import { GetMaxPlayers, IsPlayerConnected, DisableRemoteVehicleCollisions, + GetPlayerVehicleID, + GetPlayerVehicleSeat, + GetPlayerSurfingVehicleID, } from "@/wrapper/functions"; import logger from "@/logger"; import { BaseGameMode } from "../gamemode"; @@ -98,6 +101,7 @@ import { CameraCutStylesEnum, CameraModesEnum, FightingStylesEnum, + InvalidEnum, PlayerStateEnum, SpecialActionsEnum, SpectateModesEnum, @@ -579,4 +583,19 @@ export abstract class BasePlayer { public disableRemoteVehicleCollisions(disable: boolean) { return DisableRemoteVehicleCollisions(this.id, disable); } + public getVehicle(vehicles: Array): V | undefined { + if (!this.isInAnyVehicle()) return undefined; + const vehId: number = GetPlayerVehicleID(this.id); + return vehicles.find((v) => v.id === vehId); + } + public getVehicleSeat(): number { + return GetPlayerVehicleSeat(this.id); + } + public getSurfingVehicle( + vehicles: Array + ): V | undefined { + const vehId = GetPlayerSurfingVehicleID(this.id); + if (vehId === InvalidEnum.VEHICLE_ID) return undefined; + return vehicles.find((v) => v.id === vehId); + } }