diff --git a/config.json b/config.json index dff7961..f32e5b6 100644 --- a/config.json +++ b/config.json @@ -27,6 +27,10 @@ "oxInventoryEvents": { "enabled": true, "dataset": "default" + }, + "esxPoliceEvents": { + "enabled": false, + "dataset": "default" } } } \ No newline at end of file diff --git a/config.schema.json b/config.schema.json index 654eedb..13e0206 100644 --- a/config.schema.json +++ b/config.schema.json @@ -132,6 +132,23 @@ } }, "default": { "enabled": false, "dataset": "default" } + }, + "esxPoliceEvents": { + "description": "ESX police job events configuration.", + "type": "object", + "properties": { + "enabled": { + "description": "Enable ESX police job events to be logged.", + "type": "boolean", + "default": false + }, + "dataset": { + "description": "Dataset to use for ESX police job events.", + "type": "string", + "default": "default" + } + }, + "default": { "enabled": false, "dataset": "default" } } }, "required": [ @@ -144,7 +161,8 @@ "playerEvents", "chatEvents", "txAdminEvents", - "oxInventoryEvents" + "oxInventoryEvents", + "esxPoliceEvents" ] } }, diff --git a/features/logs/server/logger.ts b/features/logs/server/logger.ts index e8fa588..0bf1b01 100644 --- a/features/logs/server/logger.ts +++ b/features/logs/server/logger.ts @@ -20,6 +20,7 @@ import './chat'; import './txadmin' import './baseevents' import './third-party/ox-inventory' +import './third-party/esx-policejob' const levels = config.logs.levels.reduce>( (acc, curr, idx) => { diff --git a/features/logs/server/third-party/esx-policejob.ts b/features/logs/server/third-party/esx-policejob.ts new file mode 100644 index 0000000..76e8446 --- /dev/null +++ b/features/logs/server/third-party/esx-policejob.ts @@ -0,0 +1,41 @@ +import { config } from "~/utils/common/config"; +import { ingest } from "../logger"; + +if (config.logs.esxPoliceEvents?.enabled) { + const dataset = config.logs.esxPoliceEvents.dataset; + + onNet("esx_policejob:jailPlayer", (targetId: number, time: number, officerId: number) => { + const targetName = GetPlayerName(targetId.toString()); + const officerName = GetPlayerName(officerId.toString()); + ingest(dataset, "info", `player ${targetName} jailed for ${time} minutes by ${officerName}`, { + targetSource: targetId, + targetName, + playerSource: officerId, + playerName: officerName, + jailTime: time, + }, { _internal_RESOURCE: "esx_policejob" }); + }); + + onNet("esx_policejob:handcuffed", (targetId: number, officerId: number) => { + const targetName = GetPlayerName(targetId.toString()); + const officerName = GetPlayerName(officerId.toString()); + ingest(dataset, "info", `player ${targetName} handcuffed by officer ${officerName}`, { + targetSource: targetId, + targetName, + playerSource: officerId, + playerName: officerName, + }, { _internal_RESOURCE: "esx_policejob" }); + }); + + onNet("esx_policejob:seizeWeapons", (targetId: number, officerId: number, weapons: unknown[]) => { + const targetName = GetPlayerName(targetId.toString()); + const officerName = GetPlayerName(officerId.toString()); + ingest(dataset, "info", `weapons seized from ${targetName} by officer ${officerName}`, { + targetSource: targetId, + targetName, + playerSource: officerId, + playerName: officerName, + weapons, + }, { _internal_RESOURCE: "esx_policejob" }); + }); +} diff --git a/features/utils/common/config.ts b/features/utils/common/config.ts index 2f2ceaf..e308857 100644 --- a/features/utils/common/config.ts +++ b/features/utils/common/config.ts @@ -29,6 +29,7 @@ const ConfigSchema = object({ chatEvents: EventConfigSchema, txAdminEvents: EventConfigSchema, oxInventoryEvents: EventConfigSchema, + esxPoliceEvents: EventConfigSchema, }), });