Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
"oxInventoryEvents": {
"enabled": true,
"dataset": "default"
},
"qbxCoreEvents": {
"enabled": false,
"dataset": "default"
}
}
}
20 changes: 19 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@
}
},
"default": { "enabled": false, "dataset": "default" }
},
"qbxCoreEvents": {
"description": "qbx_core framework events configuration.",
"type": "object",
"properties": {
"enabled": {
"description": "Enable qbx_core events to be logged.",
"type": "boolean",
"default": false
},
"dataset": {
"description": "Dataset to use for qbx_core events.",
"type": "string",
"default": "default"
}
},
"default": { "enabled": false, "dataset": "default" }
}
},
"required": [
Expand All @@ -144,7 +161,8 @@
"playerEvents",
"chatEvents",
"txAdminEvents",
"oxInventoryEvents"
"oxInventoryEvents",
"qbxCoreEvents"
]
}
},
Expand Down
1 change: 1 addition & 0 deletions features/logs/server/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import './chat';
import './txadmin'
import './baseevents'
import './third-party/ox-inventory'
import './third-party/qbx-core'

const levels = config.logs.levels.reduce<Record<string, number>>(
(acc, curr, idx) => {
Expand Down
71 changes: 71 additions & 0 deletions features/logs/server/third-party/qbx-core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { config } from "~/utils/common/config";
import { ingest } from "../logger";

if (config.logs.qbxCoreEvents.enabled) {
const dataset = config.logs.qbxCoreEvents.dataset;

onNet("QBCore:Server:OnPlayerLoaded", () => {
const playerSource = global.source
const playerName = GetPlayerName(playerSource.toString())

ingest(dataset, 'info', 'qbx_core.player.loaded', {
playerSource,
playerName,
}, {
_internal_RESOURCE: "qbx_core"
})
})

on("QBCore:Server:OnPlayerUnload", (playerSource: number) => {
const playerName = GetPlayerName(playerSource.toString())

ingest(dataset, 'info', 'qbx_core.player.unloaded', {
playerSource,
playerName,
}, {
_internal_RESOURCE: "qbx_core"
})
})

onNet("QBCore:ToggleDuty", () => {
const playerSource = global.source
const playerName = GetPlayerName(playerSource.toString())

ingest(dataset, 'info', 'qbx_core.player.dutyToggled', {
playerSource,
playerName,
}, {
_internal_RESOURCE: "qbx_core"
})
})

on("QBCore:Server:OnJobUpdate", (playerSource: number, job: unknown) => {
const playerName = GetPlayerName(playerSource.toString())

ingest(dataset, 'info', 'qbx_core.player.jobUpdated', {
playerSource,
playerName,
job,
}, {
_internal_RESOURCE: "qbx_core"
})
})

on("qbx_core:server:onJobUpdate", (jobName: string, job: unknown) => {
ingest(dataset, 'info', 'qbx_core.job.updated', {
jobName,
job,
}, {
_internal_RESOURCE: "qbx_core"
})
})

on("qbx_core:server:onGangUpdate", (gangName: string, gang: unknown) => {
ingest(dataset, 'info', 'qbx_core.gang.updated', {
gangName,
gang,
}, {
_internal_RESOURCE: "qbx_core"
})
})
}
1 change: 1 addition & 0 deletions features/utils/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const ConfigSchema = object({
chatEvents: EventConfigSchema,
txAdminEvents: EventConfigSchema,
oxInventoryEvents: EventConfigSchema,
qbxCoreEvents: EventConfigSchema,
}),
});

Expand Down
Loading