Skip to content

Commit

Permalink
feat: added 0.3dl download callback, perf vehicle color params
Browse files Browse the repository at this point in the history
  • Loading branch information
dockfries committed Sep 11, 2022
1 parent 8717ca4 commit 5835467
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
19 changes: 19 additions & 0 deletions src/controllers/player/playerEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
OnPlayerUpdate,
OnEnterExitModShop,
OnPlayerInteriorChange,
OnPlayerFinishedDownloading,
OnPlayerRequestDownload,
} from "@/wrapper/callbacks";
import { I18n } from "../i18n";
import { BasePlayer } from "./basePlayer";
Expand Down Expand Up @@ -108,6 +110,11 @@ abstract class AbstractPlayerEvent<P extends BasePlayer> {
): void;
protected abstract onPause(player: P): void;
protected abstract onResume(player: P): void;
protected abstract onRequestDownload(player: P, type: number, crc: any): void;
protected abstract onFinishedDownloading(
player: P,
virtualworld: number
): void;
}

export abstract class BasePlayerEvent<
Expand Down Expand Up @@ -307,6 +314,18 @@ export abstract class BasePlayerEvent<
this.onInteriorChange(p, newinteriorid, oldinteriorid);
}
);

OnPlayerRequestDownload((playerid: number, type: number, crc: any) => {
const p = this.findPlayerById(playerid);
if (!p) return;
this.onRequestDownload(p, type, crc);
});

OnPlayerFinishedDownloading((playerid: number, virtualworld: number) => {
const p = this.findPlayerById(playerid);
if (!p) return;
this.onFinishedDownloading(p, virtualworld);
});
}
public findPlayerIdxById(playerid: number) {
return this.players.findIndex((p) => p.id === playerid);
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/vehicle/baseVehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export interface IVehicle {
y: number;
z: number;
rotation: number;
color1: number;
color2: number;
color1: string;
color2: string;
respawn_delay?: number;
addsiren?: number;
}
Expand Down Expand Up @@ -189,7 +189,7 @@ export abstract class BaseVehicle {
public static getPoolSize(): number {
return GetVehiclePoolSize();
}
public changeColor(color1: number, color2: number): number {
public changeColor(color1: string, color2: string): number {
if (this.id === -1) return 0;
this.info.color1 = color1;
this.info.color2 = color2;
Expand Down
6 changes: 6 additions & 0 deletions src/wrapper/callbacks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ export const OnPlayerFinishedDownloading = (
samp.addEventListener("OnPlayerFinishedDownloading", func);
};

export const OnPlayerRequestDownload = (
func: (playerid: number, type: number, crc: any) => void
) => {
samp.addEventListener("OnPlayerRequestDownload", func);
};

export const OnPlayerClickPlayer = (
func: (playerid: number, clickedplayerid: number, source: number) => void
) => {
Expand Down
20 changes: 12 additions & 8 deletions src/wrapper/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2784,8 +2784,8 @@ export const CreateVehicle = (
y: number,
z: number,
rotation: number,
color1: number,
color2: number,
color1: string,
color2: string,
respawn_delay: number,
addsiren: number
): number => {
Expand All @@ -2797,8 +2797,8 @@ export const CreateVehicle = (
y,
z,
rotation,
color1,
color2,
rgba(color1),
rgba(color2),
respawn_delay,
addsiren
);
Expand Down Expand Up @@ -3029,15 +3029,15 @@ export const RemoveVehicleComponent = (

export const ChangeVehicleColor = (
vehicleid: number,
color1: number,
color2: number
color1: string,
color2: string
): number => {
return samp.callNative(
"ChangeVehicleColor",
"iii",
vehicleid,
color1,
color2
rgba(color1),
rgba(color2)
);
};

Expand Down Expand Up @@ -3221,3 +3221,7 @@ export const PauseRecordingPlayback = (): void => {
export const ResumeRecordingPlayback = (): void => {
return samp.callNative("ResumeRecordingPlayback", "");
};

export const GetPlayerCustomSkin = (playerid: number): number => {
return samp.callNative("GetPlayerCustomSkin", "i", playerid);
};

0 comments on commit 5835467

Please sign in to comment.