Skip to content

Commit

Permalink
feat: added some player functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dockfries committed Sep 10, 2022
1 parent 9a90359 commit f619998
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/controllers/player/basePlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@ import {
GetMaxPlayers,
IsPlayerConnected,
DisableRemoteVehicleCollisions,
GetPlayerVehicleID,
GetPlayerVehicleSeat,
GetPlayerSurfingVehicleID,
} from "@/wrapper/functions";
import logger from "@/logger";
import { BaseGameMode } from "../gamemode";
import {
CameraCutStylesEnum,
CameraModesEnum,
FightingStylesEnum,
InvalidEnum,
PlayerStateEnum,
SpecialActionsEnum,
SpectateModesEnum,
Expand Down Expand Up @@ -579,4 +583,19 @@ export abstract class BasePlayer {
public disableRemoteVehicleCollisions(disable: boolean) {
return DisableRemoteVehicleCollisions(this.id, disable);
}
public getVehicle<V extends BaseVehicle>(vehicles: Array<V>): 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<V extends BaseVehicle>(
vehicles: Array<V>
): V | undefined {
const vehId = GetPlayerSurfingVehicleID(this.id);
if (vehId === InvalidEnum.VEHICLE_ID) return undefined;
return vehicles.find((v) => v.id === vehId);
}
}

0 comments on commit f619998

Please sign in to comment.