Skip to content

Commit

Permalink
feat: added gang zone
Browse files Browse the repository at this point in the history
  • Loading branch information
dockfries committed Sep 13, 2022
1 parent 022edf5 commit 93e95ad
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 4 deletions.
119 changes: 119 additions & 0 deletions src/controllers/gangzone/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { LimitsEnum } from "@/enums";
import { IBaseGangZone } from "@/interfaces";
import { logger } from "@/logger";
import {
GangZoneCreate,
GangZoneDestroy,
GangZoneFlashForAll,
GangZoneFlashForPlayer,
GangZoneHideForAll,
GangZoneHideForPlayer,
GangZoneShowForAll,
GangZoneShowForPlayer,
GangZoneStopFlashForAll,
GangZoneStopFlashForPlayer,
} from "@/wrapper/functions";
import { BasePlayer } from "../player";

export abstract class BaseGangZone {
private _id = -1;
private static createdCount = 0;
public readonly sourceInfo: IBaseGangZone;
constructor(gangzone: IBaseGangZone) {
this.sourceInfo = gangzone;
}
public create(): void {
if (this.id !== -1)
return logger.warn("[BaseGangZone]: Unable to create the gangzone again");
if (BaseGangZone.createdCount === LimitsEnum.MAX_GANG_ZONES)
return logger.warn(
"[BaseGangZone]: Unable to continue to create gangzone, maximum allowable quantity has been reached"
);
const { minx, miny, maxx, maxy } = this.sourceInfo;
this._id = GangZoneCreate(minx, miny, maxx, maxy);
}

public destroy() {
if (this.id === -1)
return logger.warn(
"[BaseGangZone]: Unable to destroy the gangzone before create"
);
GangZoneDestroy(this.id);
BaseGangZone.createdCount--;
this._id = -1;
}

public showForAll(color: string): void | number {
if (this.id === -1)
return logger.warn(
"[BaseGangZone]: Unable to show the gangzone before create"
);
return GangZoneShowForAll(this.id, color);
}

public showForPlayer<P extends BasePlayer>(
player: P,
color: string
): void | number {
if (this.id === -1)
return logger.warn(
"[BaseGangZone]: Unable to show the gangzone before create"
);
return GangZoneShowForPlayer(player.id, this.id, color);
}

public hideForAll(): void | number {
if (this.id === -1)
return logger.warn(
"[BaseGangZone]: Unable to hide the gangzone before create"
);
return GangZoneHideForAll(this.id);
}

public hideForPlayer<P extends BasePlayer>(player: P): void | number {
if (this.id === -1)
return logger.warn(
"[BaseGangZone]: Unable to hide the gangzone before create"
);
return GangZoneHideForPlayer(player.id, this.id);
}

public flashForAll(flashcolor: string): void | number {
if (this.id === -1)
return logger.warn(
"[BaseGangZone]: Unable to flash the gangzone before create"
);
return GangZoneFlashForAll(this.id, flashcolor);
}

public flashForPlayer<P extends BasePlayer>(
player: P,
flashcolor: string
): void | number {
if (this.id === -1)
return logger.warn(
"[BaseGangZone]: Unable to flash the gangzone before create"
);
return GangZoneFlashForPlayer(player.id, this.id, flashcolor);
}

public StopFlashForAll(): void | number {
if (this.id === -1)
return logger.warn(
"[BaseGangZone]: Unable to stop flash the gangzone before create"
);
return GangZoneStopFlashForAll(this.id);
}

public StopFlashForPlayer<P extends BasePlayer>(player: P): void | number {
if (this.id === -1)
return logger.warn(
"[BaseGangZone]: Unable to stop flash the gangzone before create"
);
return GangZoneStopFlashForPlayer(player.id, this.id);
}

public get id() {
return this._id;
}
}
1 change: 1 addition & 0 deletions src/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from "./gamemode";
export * from "./netstats";
export * from "./gametext";
export * from "./menu";
export * from "./gangzone";
24 changes: 24 additions & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,27 @@ export interface IPlayerSettings {
locale: string;
charset: string;
}

export interface IVehicle {
modelid: number;
x: number;
y: number;
z: number;
z_angle: number;
color1: string;
color2: string;
respawn_delay?: number;
addsiren?: boolean;
}

export interface IAnimateInfo {
n: string;
d: number;
}

export interface IBaseGangZone {
minx: number;
miny: number;
maxx: number;
maxy: number;
}
5 changes: 1 addition & 4 deletions src/utils/animateUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
interface IAnimateInfo {
n: string;
d: number;
}
import { IAnimateInfo } from "@/interfaces";

const animateLib = new Map<string, Array<IAnimateInfo>>([
["AIRPORT", [{ n: "thrw_barl_thrw", d: 2.0 }]],
Expand Down

0 comments on commit 93e95ad

Please sign in to comment.