Skip to content

feat: add qbx_police event logging integration#24

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-qbx-police-logging-integration
Draft

feat: add qbx_police event logging integration#24
Copilot wants to merge 2 commits intomainfrom
copilot/add-qbx-police-logging-integration

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 2, 2026

Adds passive server-side event interception for qbx_police, logging police job actions through the SDK's ingest() pipeline — no changes to qbx_police required.

New file: features/logs/server/third-party/qbx-police.ts

Gated behind config.logs.qbxPoliceEvents.enabled. Intercepts 9 onNet events:

Event Log message
police:server:SetHandcuffStatus qbx_police.player.handcuffed / .unhandcuffed
police:server:JailPlayer qbx_police.player.jailed
police:server:BillPlayer qbx_police.player.billed
police:server:SeizeCash qbx_police.player.cashSeized
police:server:Impound qbx_police.vehicle.impounded / .sentToDepot
police:server:Radar qbx_police.player.radarFined
police:server:policeAlert qbx_police.alert.dispatched
police:server:FlaggedPlateTriggered qbx_police.vehicle.flaggedPlateDetected
police:server:SetTracker qbx_police.player.trackerUpdated

All handlers capture global.source and include resolved GetPlayerName() values alongside full event-specific metadata for dashboard filtering.

onNet("police:server:JailPlayer", (targetSrc: number, time: number) => {
    const playerSource = global.source;
    ingest(dataset, "info", "qbx_police.player.jailed", {
        playerSource,
        playerName: GetPlayerName(playerSource.toString()),
        targetSource: targetSrc,
        targetName: GetPlayerName(targetSrc.toString()),
        jailTimeMinutes: time,
    }, { _internal_RESOURCE: "qbx_police" });
});

Config changes

  • config.json: added qbxPoliceEvents: { enabled: false, dataset: "default" }
  • config.schema.json: added qbxPoliceEvents to properties.logs.properties and required
  • config.ts: added qbxPoliceEvents: EventConfigSchema to the valibot schema
  • logger.ts: added import './third-party/qbx-police'
Original prompt

Overview

Add a new third-party logging integration for qbx_police — the Qbox police job resource. This follows the exact same pattern as features/logs/server/third-party/ox-inventory.ts.

Files to create/modify

1. Create features/logs/server/third-party/qbx-police.ts

Intercepts server-side RegisterNetEvent and AddEventHandler events from qbx_police and logs them through the SDK's ingest() function.

Rules:

  • Gated behind config.logs.qbxPoliceEvents.enabled
  • Uses config.logs.qbxPoliceEvents.dataset
  • Uses _internal_RESOURCE: "qbx_police" in _internalOpts
  • Log messages are lowercase dot-notation (e.g. "qbx_police.player.handcuffed") — simple and searchable
  • Metadata is rich — include every contextually available field for dashboard filtering
  • Use global.source to capture source inside handlers
  • Import ingest from "../logger" and config from "~/utils/common/config"

Events to intercept (all via onNet since they are RegisterNetEvent in qbx_police):

police:server:SetHandcuffStatus — handler receives (isHandcuffed: boolean)

  • message: isHandcuffed ? "qbx_police.player.handcuffed" : "qbx_police.player.unhandcuffed"
  • metadata: { playerSource, playerName: GetPlayerName(source), isHandcuffed }

police:server:JailPlayer — handler receives (targetSrc: number, time: number)

  • message: "qbx_police.player.jailed"
  • metadata: { playerSource (officer), playerName: GetPlayerName(source), targetSource: targetSrc, targetName: GetPlayerName(targetSrc.toString()), jailTimeMinutes: time }

police:server:BillPlayer — handler receives (targetSrc: number, price: number)

  • message: "qbx_police.player.billed"
  • metadata: { playerSource (officer), playerName: GetPlayerName(source), targetSource: targetSrc, targetName: GetPlayerName(targetSrc.toString()), amount: price }

police:server:SeizeCash — handler receives (targetSrc: number)

  • message: "qbx_police.player.cashSeized"
  • metadata: { playerSource (officer), playerName: GetPlayerName(source), targetSource: targetSrc, targetName: GetPlayerName(targetSrc.toString()) }

police:server:Impound — handler receives (plate: string, fullImpound: boolean, price: number, body: number, engine: number, fuel: number)

  • message: fullImpound ? "qbx_police.vehicle.impounded" : "qbx_police.vehicle.sentToDepot"
  • metadata: { playerSource, playerName: GetPlayerName(source), plate, fullImpound, price: price ?? 0, bodyDamage: body, engineDamage: engine, fuelLevel: fuel }

police:server:Radar — handler receives (fine: number)

  • message: "qbx_police.player.radarFined"
  • metadata: { playerSource, playerName: GetPlayerName(source), fineIndex: fine }

police:server:policeAlert — handler receives (text: string, camId: number | undefined, playerSource: number | undefined)

  • message: "qbx_police.alert.dispatched"
  • metadata: { playerSource: playerSource ?? source, text, camId: camId ?? null }

police:server:FlaggedPlateTriggered — handler receives (radar: string, plate: string, street: string)

  • message: "qbx_police.vehicle.flaggedPlateDetected"
  • metadata: { playerSource: source, playerName: GetPlayerName(source.toString()), plate, street, radar }

police:server:SetTracker — handler receives (targetId: number)

  • message: "qbx_police.player.trackerUpdated"
  • metadata: { playerSource (officer), playerName: GetPlayerName(source), targetSource: targetId, targetName: GetPlayerName(targetId.toString()) }

2. Modify features/logs/server/logger.ts

Add the import after the existing third-party imports:

import './third-party/qbx-police'

3. Modify config.json

Add inside "logs":

"qbxPoliceEvents": {
    "enabled": false,
    "dataset": "default"
}

4. Modify config.schema.json

Add schema entry for qbxPoliceEvents following the same pattern as oxInventoryEvents. Add it to properties.logs.properties and to the required array in properties.logs.

"qbxPoliceEvents": {
    "description": "qbx_police job events configuration.",
    "type": "object",
    "properties": {
        "enabled": {
            "description": "Enable qbx_police events to be logged.",
            "type": "boolean",
            "default": false
        },
        "dataset": {
            "description": "Dataset to use for qbx_police events.",
            "type": "string",
            "default": "default"
        }
    },
    "default": { "enabled": false, "dataset": "default" }
}

Notes

  • onNet(eventName, cb) is the TypeScript equivalent of RegisterNetEvent Lua handlers
  • on(eventName, cb) is for server-only AddEventHandler
  • Do NOT import anything from qbx_police — only listen to events passively
  • All GetPlayerName calls should pass a string — use .toString() where needed
  • Follow the existing code style from ox-inventory.ts

The following is the prior conversation context from the use...

This pull request was created from Copilot chat.

Agent-Logs-Url: https://github.com/fivemanage/sdk/sessions/6aab40c2-12dd-4489-a75c-41c53173e1a5

Co-authored-by: itschip <59088889+itschip@users.noreply.github.com>
Copilot AI changed the title [WIP] Add third-party logging integration for qbx_police feat: add qbx_police event logging integration Apr 2, 2026
Copilot AI requested a review from itschip April 2, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants