Skip to content

Commit

Permalink
feat: added player animation functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dockfries committed Sep 11, 2022
1 parent b3c0bf1 commit 69d93d6
Show file tree
Hide file tree
Showing 5 changed files with 2,546 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/controllers/menu/menuBus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import EventBus from "@/utils/EventBus";
import EventBus from "@/utils/eventBus";

export enum menuHooks {
created = "OnMenuCreate",
Expand Down
31 changes: 31 additions & 0 deletions src/controllers/player/basePlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ import {
GetPlayerVehicleID,
GetPlayerVehicleSeat,
GetPlayerSurfingVehicleID,
ApplyAnimation,
ClearAnimations,
} from "@/wrapper/functions";
import logger from "@/logger";
import { BaseGameMode } from "../gamemode";
Expand All @@ -110,6 +112,7 @@ import {
import { BaseVehicle } from "../vehicle";
import { basePos } from "@/types";
import { GetPlayerWeather } from "omp-wrapper";
import { getAnimateDurationByLibName } from "@/utils/animateUtils";

export abstract class BasePlayer {
private _id: number;
Expand Down Expand Up @@ -598,4 +601,32 @@ export abstract class BasePlayer {
if (vehId === InvalidEnum.VEHICLE_ID) return undefined;
return vehicles.find((v) => v.id === vehId);
}
public applyAnimation(
animlib: string,
animname: string,
loop = false,
lockx = true,
locky = true,
freeze = false,
forcesync = false
): void {
const duration = getAnimateDurationByLibName(animlib, animname);
if (duration === undefined)
return logger.error("[BasePlayer]: Invalid anim library or name");
ApplyAnimation(
this.id,
animlib,
animname,
4.1,
loop,
lockx,
locky,
freeze,
loop ? 0 : duration,
forcesync
);
}
public clearAnimations(forcesync = false) {
ClearAnimations(this.id, forcesync);
}
}
2 changes: 1 addition & 1 deletion src/controllers/vehicle/vehicleBus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import EventBus from "@/utils/EventBus";
import EventBus from "@/utils/eventBus";

export enum vehicleHooks {
created = "OnVehicleCreate",
Expand Down
Loading

0 comments on commit 69d93d6

Please sign in to comment.