From db3a72097d44b923af89308c0fc54b954ec570b7 Mon Sep 17 00:00:00 2001 From: yucarl77 Date: Sun, 28 Aug 2022 15:20:43 +0800 Subject: [PATCH] feat: callbacks --- package.json | 1 + pnpm-lock.yaml | 6 + src/wrapper/callbacks/index.ts | 390 +++++++++++++++++++++++++++++++++ tsconfig.json | 1 + 4 files changed, 398 insertions(+) diff --git a/package.json b/package.json index dc57f64..602b353 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ }, "homepage": "https://github.com/YuCarl77/omp-node-lib#readme", "devDependencies": { + "omp-wrapper": "@latest", "typescript": "^4.7.4" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 38f671a..474ef87 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,13 +1,19 @@ lockfileVersion: 5.4 specifiers: + omp-wrapper: ^0.0.7 typescript: ^4.7.4 devDependencies: + omp-wrapper: 0.0.7 typescript: 4.7.4 packages: + /omp-wrapper/0.0.7: + resolution: {integrity: sha512-pnocKWtNdeSZ+wYRDTgEV7P/W7fmlUe6k/OYGXywlzw8Ew5GJ84qmuLeaA8rOtCK+GUYeCXd692nsIzUA5PgZw==} + dev: true + /typescript/4.7.4: resolution: {integrity: sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==} engines: {node: '>=4.2.0'} diff --git a/src/wrapper/callbacks/index.ts b/src/wrapper/callbacks/index.ts index e69de29..53219c6 100644 --- a/src/wrapper/callbacks/index.ts +++ b/src/wrapper/callbacks/index.ts @@ -0,0 +1,390 @@ +// Reference to Peter Szombati's samp-node-lib + +// built-in omp-wrapper +export * from "omp-wrapper"; + +export const OnGameModeInit = (func: () => void) => { + samp.addEventListener("OnGameModeInit", func); +}; + +export const OnGameModeExit = (func: () => void) => { + samp.addEventListener("OnGameModeExit", func); +}; + +export const OnFilterScriptInit = (func: () => void) => { + samp.addEventListener("OnFilterScriptInit", func); +}; + +export const OnFilterScriptExit = (func: () => void) => { + samp.addEventListener("OnFilterScriptExit", func); +}; + +export const OnPlayerConnect = (func: (playerid: number) => void) => { + samp.addEventListener("OnPlayerConnect", func); +}; + +export const OnPlayerDisconnect = ( + func: (playerid: number, reason: number) => void +) => { + samp.addEventListener("OnPlayerDisconnect", func); +}; + +export const OnPlayerSpawn = (func: (playerid: number) => void) => { + samp.addEventListener("OnPlayerSpawn", func); +}; + +export const OnPlayerDeath = ( + func: (playerid: number, killerid: number, reason: number) => void +) => { + samp.addEventListener("OnPlayerDeath", func); +}; + +export const OnVehicleSpawn = (func: (vehicleid: number) => void) => { + samp.addEventListener("OnVehicleSpawn", func); +}; + +export const OnVehicleDeath = ( + func: (vehicleid: number, killer: number) => void +) => { + samp.addEventListener("OnVehicleDeath", func); +}; + +export const OnPlayerText = ( + func: (playerid: number, text: string) => void +) => { + samp.addEventListener("OnPlayerText", func); +}; + +export const OnPlayerCommandText = ( + func: (playerid: number, cmdtext: string) => void +) => { + samp.addEventListener("OnPlayerCommandText", func); +}; + +export const OnPlayerRequestClass = ( + func: (playerid: number, classid: number) => void +) => { + samp.addEventListener("OnPlayerRequestClass", func); +}; + +export const OnPlayerEnterVehicle = ( + func: (playerid: number, vehicleid: number, ispassenger: number) => void +) => { + samp.addEventListener("OnPlayerEnterVehicle", func); +}; + +export const OnPlayerExitVehicle = ( + func: (playerid: number, vehicleid: number) => void +) => { + samp.addEventListener("OnPlayerExitVehicle", func); +}; + +export const OnPlayerStateChange = ( + func: (playerid: number, newstate: number, oldstate: number) => void +) => { + samp.addEventListener("OnPlayerStateChange", func); +}; + +export const OnPlayerEnterCheckpoint = (func: (playerid: number) => void) => { + samp.addEventListener("OnPlayerEnterCheckpoint", func); +}; + +export const OnPlayerLeaveCheckpoint = (func: (playerid: number) => void) => { + samp.addEventListener("OnPlayerLeaveCheckpoint", func); +}; + +export const OnPlayerEnterRaceCheckpoint = ( + func: (playerid: number) => void +) => { + samp.addEventListener("OnPlayerEnterRaceCheckpoint", func); +}; + +export const OnPlayerLeaveRaceCheckpoint = ( + func: (playerid: number) => void +) => { + samp.addEventListener("OnPlayerLeaveRaceCheckpoint", func); +}; + +export const OnRconCommand = (func: (cmd: string) => void) => { + samp.addEventListener("OnRconCommand", func); +}; + +export const OnPlayerRequestSpawn = (func: (playerid: number) => void) => { + samp.addEventListener("OnPlayerRequestSpawn", func); +}; + +export const OnObjectMoved = (func: (objectid: number) => void) => { + samp.addEventListener("OnObjectMoved", func); +}; + +export const OnPlayerObjectMoved = ( + func: (playerid: number, objectid: number) => void +) => { + samp.addEventListener("OnPlayerObjectMoved", func); +}; + +export const OnPlayerPickUpPickup = ( + func: (playerid: number, pickupid: number) => void +) => { + samp.addEventListener("OnPlayerPickUpPickup", func); +}; + +export const OnVehicleMod = ( + func: (playerid: number, vehicleid: number, componentid: number) => void +) => { + samp.addEventListener("OnVehicleMod", func); +}; + +export const OnEnterExitModShop = ( + func: (playerid: number, enterexit: number, interiorid: number) => void +) => { + samp.addEventListener("OnEnterExitModShop", func); +}; + +export const OnVehiclePaintjob = ( + func: (playerid: number, vehicleid: number, paintjobid: number) => void +) => { + samp.addEventListener("OnVehiclePaintjob", func); +}; + +export const OnVehicleRespray = ( + func: ( + playerid: number, + vehicleid: number, + color1: number, + color2: number + ) => void +) => { + samp.addEventListener("OnVehicleRespray", func); +}; + +export const OnVehicleDamageStatusUpdate = ( + func: (vehicleid: number, playerid: number) => void +) => { + samp.addEventListener("OnVehicleDamageStatusUpdate", func); +}; + +export const OnUnoccupiedVehicleUpdate = ( + func: ( + vehicleid: number, + playerid: number, + passenger_seat: number, + new_x: number, + new_y: number, + new_z: number, + vel_x: number, + vel_y: number, + vel_z: number + ) => void +) => { + samp.addEventListener("OnUnoccupiedVehicleUpdate", func); +}; + +export const OnPlayerSelectedMenuRow = ( + func: (playerid: number, row: number) => void +) => { + samp.addEventListener("OnPlayerSelectedMenuRow", func); +}; + +export const OnPlayerExitedMenu = (func: (playerid: number) => void) => { + samp.addEventListener("OnPlayerExitedMenu", func); +}; + +export const OnPlayerInteriorChange = ( + func: (playerid: number, newinteriorid: number, oldinteriorid: number) => void +) => { + samp.addEventListener("OnPlayerInteriorChange", func); +}; + +export const OnPlayerKeyStateChange = ( + func: (playerid: number, newkeys: number, oldkeys: number) => void +) => { + samp.addEventListener("OnPlayerKeyStateChange", func); +}; + +export const OnRconLoginAttempt = ( + func: (ip: string, password: string, success: number) => void +) => { + samp.addEventListener("OnRconLoginAttempt", func); +}; + +export const OnPlayerUpdate = (func: (playerid: number) => void) => { + samp.addEventListener("OnPlayerUpdate", func); +}; + +export const OnPlayerStreamIn = ( + func: (playerid: number, forplayerid: number) => void +) => { + samp.addEventListener("OnPlayerStreamIn", func); +}; + +export const OnPlayerStreamOut = ( + func: (playerid: number, forplayerid: number) => void +) => { + samp.addEventListener("OnPlayerStreamOut", func); +}; + +export const OnVehicleStreamIn = ( + func: (vehicleid: number, forplayerid: number) => void +) => { + samp.addEventListener("OnVehicleStreamIn", func); +}; + +export const OnVehicleStreamOut = ( + func: (vehicleid: number, forplayerid: number) => void +) => { + samp.addEventListener("OnVehicleStreamOut", func); +}; + +export const OnActorStreamIn = ( + func: (actorid: number, forplayerid: number) => void +) => { + samp.addEventListener("OnActorStreamIn", func); +}; + +export const OnActorStreamOut = ( + func: (actorid: number, forplayerid: number) => void +) => { + samp.addEventListener("OnActorStreamOut", func); +}; + +export const OnDialogResponse = ( + func: ( + playerid: number, + dialogid: number, + response: number, + listitem: number, + inputtext: string + ) => void +) => { + samp.addEventListener("OnDialogResponse", func); +}; + +export const OnPlayerTakeDamage = ( + func: ( + playerid: number, + issuer: number, + amount: number, + weaponid: number, + bodypart: number + ) => void +) => { + samp.addEventListener("OnPlayerTakeDamage", func); +}; + +export const OnPlayerGiveDamage = ( + func: ( + playerid: number, + damageid: number, + amount: number, + weaponid: number, + bodypart: number + ) => void +) => { + samp.addEventListener("OnPlayerGiveDamage", func); +}; + +export const OnPlayerGiveDamageActor = ( + func: ( + playerid: number, + damaged_actorid: number, + amount: number, + weaponid: number, + bodypart: number + ) => void +) => { + samp.addEventListener("OnPlayerGiveDamageActor", func); +}; + +export const OnPlayerClickMap = ( + func: (playerid: number, fX: number, fY: number, fZ: number) => void +) => { + samp.addEventListener("OnPlayerClickMap", func); +}; + +export const OnPlayerClickTextDraw = ( + func: (playerid: number, clickedid: number) => void +) => { + samp.addEventListener("OnPlayerClickTextDraw", func); +}; + +export const OnPlayerClickPlayerTextDraw = ( + func: (playerid: number, playertextid: number) => void +) => { + samp.addEventListener("OnPlayerClickPlayerTextDraw", func); +}; + +export const OnIncomingConnection = ( + func: (playerid: number, ip_address: string, port: number) => void +) => { + samp.addEventListener("OnIncomingConnection", func); +}; + +export const OnTrailerUpdate = ( + func: (playerid: number, vehicleid: number) => void +) => { + samp.addEventListener("OnTrailerUpdate", func); +}; + +export const OnVehicleSirenStateChange = ( + func: (playerid: number, vehicleid: number, newstate: number) => void +) => { + samp.addEventListener("OnVehicleSirenStateChange", func); +}; + +export const OnPlayerFinishedDownloading = ( + func: (playerid: number, virtualworld: number) => void +) => { + samp.addEventListener("OnPlayerFinishedDownloading", func); +}; + +export const OnPlayerClickPlayer = ( + func: (playerid: number, clickedplayerid: number, source: number) => void +) => { + samp.addEventListener("OnPlayerClickPlayer", func); +}; + +export const OnPlayerSelectObject = ( + func: ( + playerid: number, + type: number, + objectid: number, + modelid: number, + fX: number, + fY: number, + fZ: number + ) => void +) => { + samp.addEventListener("OnPlayerSelectObject", func); +}; + +export const OnPlayerWeaponShot = ( + func: ( + playerid: number, + weaponid: number, + hittype: number, + hitid: number, + fX: number, + fY: number, + fZ: number + ) => void +) => { + samp.addEventListener("OnPlayerWeaponShot", func); +}; + +export const OnClientCheckResponse = ( + func: ( + playerid: number, + actionid: number, + memaddr: number, + retndata: number + ) => void +) => { + samp.addEventListener("OnClientCheckResponse", func); +}; + +export const OnScriptCash = ( + func: (playerid: number, amount: number, source: number) => void +) => { + samp.addEventListener("OnScriptCash", func); +}; diff --git a/tsconfig.json b/tsconfig.json index 26e7aa0..610d8e3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "target": "ESNext", "module": "ESNext", + "moduleResolution": "Node", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": true,