diff --git a/src/controllers/player/playerEvent.ts b/src/controllers/player/playerEvent.ts index 9f69017..0fd62f4 100644 --- a/src/controllers/player/playerEvent.ts +++ b/src/controllers/player/playerEvent.ts @@ -17,6 +17,8 @@ import { OnPlayerUpdate, OnEnterExitModShop, OnPlayerInteriorChange, + OnPlayerFinishedDownloading, + OnPlayerRequestDownload, } from "@/wrapper/callbacks"; import { I18n } from "../i18n"; import { BasePlayer } from "./basePlayer"; @@ -108,6 +110,11 @@ abstract class AbstractPlayerEvent

{ ): 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< @@ -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); diff --git a/src/controllers/vehicle/baseVehicle.ts b/src/controllers/vehicle/baseVehicle.ts index 277fa96..c5c1974 100644 --- a/src/controllers/vehicle/baseVehicle.ts +++ b/src/controllers/vehicle/baseVehicle.ts @@ -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; } @@ -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; diff --git a/src/wrapper/callbacks/index.ts b/src/wrapper/callbacks/index.ts index a50e127..409230c 100644 --- a/src/wrapper/callbacks/index.ts +++ b/src/wrapper/callbacks/index.ts @@ -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 ) => { diff --git a/src/wrapper/functions/index.ts b/src/wrapper/functions/index.ts index 5570a24..381cc46 100644 --- a/src/wrapper/functions/index.ts +++ b/src/wrapper/functions/index.ts @@ -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 => { @@ -2797,8 +2797,8 @@ export const CreateVehicle = ( y, z, rotation, - color1, - color2, + rgba(color1), + rgba(color2), respawn_delay, addsiren ); @@ -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) ); }; @@ -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); +};