Skip to content

Add ESX economy logging integration#29

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-esx-economy-logging-integration
Draft

Add ESX economy logging integration#29
Copilot wants to merge 2 commits intomainfrom
copilot/add-esx-economy-logging-integration

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 7, 2026

Adds a third-party logging integration for ESX economy resources, automatically capturing structured transaction logs from esx_banking, esx_billing, esx_society, esx_vehicleshop, and esx_weaponshop.

New file: features/logs/server/third-party/esx-economy.ts

  • Listens to 11 economy events via onNet(), gated by config.logs.esxEconomyEvents?.enabled
  • Each event resolves player names via GetPlayerName() and passes _internal_RESOURCE to attribute logs to the correct ESX resource
  • Covered events:
    • esx_banking: depositMoney, withdrawMoney, transferMoney
    • esx_billing: addBill, payBill
    • esx_society: pay, addMoney, removeMoney
    • esx_vehicleshop: buyVehicle
    • esx_weaponshop: buyWeapon, buyAmmo

Config & schema

  • config.json: adds esxEconomyEvents: { enabled: false, dataset: "default" } under logs
  • config.schema.json: adds corresponding schema entry and "esxEconomyEvents" to the required array
  • features/utils/common/config.ts: adds esxEconomyEvents: EventConfigSchema to ConfigSchema

Wiring

  • features/logs/server/logger.ts: imports ./third-party/esx-economy alongside the existing ox-inventory import

Example log entry for a bank transfer:

message: "player John transferred $5000 to Jane"
metadata: { playerSource: 1, playerName: "John", targetSource: 2, targetName: "Jane", amount: 5000, action: "transfer" }
resource: "esx_banking"
Original prompt

Add ESX Economy Logging Integration

Add a new third-party logging integration for ESX economy resources (esx_banking, esx_billing, esx_society, esx_vehicleshop, esx_weaponshop) that automatically sends structured logs to Fivemanage when economic transaction events fire.

Background

The SDK already has a pattern for third-party integrations (see features/logs/server/third-party/ox-inventory.ts). We need to follow the same pattern exactly: create a new file, gate it behind a config flag, and import it in logger.ts.

What to implement

1. Create features/logs/server/third-party/esx-economy.ts

Listen to the following events using onNet():

esx_banking:

  • esx_banking:depositMoney — args: (playerId: number, amount: number) — message: player ${playerName} deposited $${amount}, metadata: { playerSource, playerName, amount, action: "deposit" }, resource: "esx_banking"
  • esx_banking:withdrawMoney — args: (playerId: number, amount: number) — message: player ${playerName} withdrew $${amount}, metadata: { playerSource, playerName, amount, action: "withdraw" }, resource: "esx_banking"
  • esx_banking:transferMoney — args: (senderId: number, targetId: number, amount: number) — message: player ${senderName} transferred $${amount} to ${targetName}, metadata: { playerSource: senderId, playerName: senderName, targetSource: targetId, targetName, amount, action: "transfer" }, resource: "esx_banking"

esx_billing:

  • esx_billing:addBill — args: (targetId: number, senderId: number, societyName: string, label: string, amount: number) — message: player ${targetName} billed $${amount} for "${label}" by ${senderName}, metadata: { targetSource: targetId, targetName, playerSource: senderId, playerName: senderName, societyName, billLabel: label, amount }, resource: "esx_billing"
  • esx_billing:payBill — args: (playerId: number, billId: number, amount: number) — message: player ${playerName} paid bill #${billId} for $${amount}, metadata: { playerSource: playerId, playerName, billId, amount }, resource: "esx_billing"

esx_society:

  • esx_society:pay — args: (playerId: number, societyName: string, amount: number) — message: player ${playerName} paid $${amount} from society ${societyName}, metadata: { playerSource, playerName, societyName, amount, action: "pay" }, resource: "esx_society"
  • esx_society:addMoney — args: (societyName: string, amount: number) — message: society ${societyName} received $${amount}, metadata: { societyName, amount, action: "add" }, resource: "esx_society"
  • esx_society:removeMoney — args: (societyName: string, amount: number) — message: society ${societyName} lost $${amount}, metadata: { societyName, amount, action: "remove" }, resource: "esx_society"

esx_vehicleshop:

  • esx_vehicleshop:buyVehicle — args: (playerId: number, model: string, price: number, type: string) — message: player ${playerName} bought vehicle ${model} for $${price}, metadata: { playerSource, playerName, vehicleModel: model, vehicleType: type, price }, resource: "esx_vehicleshop"

esx_weaponshop:

  • esx_weaponshop:buyWeapon — args: (playerId: number, weaponName: string, price: number) — message: player ${playerName} bought weapon ${weaponName} for $${price}, metadata: { playerSource, playerName, weaponName, price }, resource: "esx_weaponshop"
  • esx_weaponshop:buyAmmo — args: (playerId: number, weaponName: string, ammoCount: number, price: number) — message: player ${playerName} bought ${ammoCount}x ammo for ${weaponName}, metadata: { playerSource, playerName, weaponName, ammoCount, price }, resource: "esx_weaponshop"

All events should:

  • Use onNet(...) to listen
  • Use GetPlayerName(id.toString()) to resolve player names where applicable
  • Pass { _internal_RESOURCE: "<resource-name>" } as the last _internalOpts argument to ingest()
  • Be gated by if (config.logs.esxEconomyEvents?.enabled)
  • Use config.logs.esxEconomyEvents.dataset as the dataset

2. Update config.json

Add inside "logs":

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

3. Update config.schema.json

Add the schema entry for esxEconomyEvents following the exact same structure as existing entries:

"esxEconomyEvents": {
    "description": "ESX economy events configuration (banking, billing, society, shops).",
    "type": "object",
    "properties": {
        "enabled": {
            "description": "Enable ESX economy events to be logged.",
            "type": "boolean",
            "default": false
        },
        "dataset": {
            "description": "Dataset to use for ESX economy events.",
            "type": "string",
            "default": "default"
        }
    },
    "default": { "enabled": false, "dataset": "default" }
}

Also add "esxEconomyEvents" to the required array.

4. Update features/logs/server/logger.ts

Add ...

This pull request was created from Copilot chat.

Agent-Logs-Url: https://github.com/fivemanage/sdk/sessions/cd999e33-30e4-4ec2-a7fb-c2930fb6788d

Co-authored-by: itschip <59088889+itschip@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ESX economy logging integration Add ESX economy logging integration Apr 7, 2026
Copilot AI requested a review from itschip April 7, 2026 21:24
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