Skip to content

feat: sync player data inv & loadout#1698

Merged
Kenshiin13 merged 4 commits into
devfrom
player-data
Aug 13, 2025
Merged

feat: sync player data inv & loadout#1698
Kenshiin13 merged 4 commits into
devfrom
player-data

Conversation

@Kenshiin13

Copy link
Copy Markdown
Contributor

Description

This PR ensures the ESX.PlayerData.inventory and ESX.PlayerData.loadout tables remain synchronized between client and server & importing resources. It listens for secure events (esx:addInventoryItem, esx:removeInventoryItem, esx:addLoadoutItem, esx:removeLoadoutItem) and updates the client-side data accordingly. This feature is only enabled when ESX.GetConfig("CustomInventory") is false, maintaining compatibility with custom inventory systems.


Motivation

The changes are necessary to maintain consistency between server-side inventory/loadout state and the client's ESX.PlayerData. As of now, you have to use ESX.GetPlayerData() just to get an updated state of the inventory. And the loadout is out of sync regardless.


Implementation Details

  • Listens to secure net events:
    • esx:addInventoryItem
    • esx:removeInventoryItem
    • esx:addLoadoutItem
    • esx:removeLoadoutItem
  • Updates the relevant fields in ESX.PlayerData only if CustomInventory is disabled.
  • Uses table.insert and table.remove to manage loadout, and directly modifies counts in inventory.

PR Checklist

  • My commit messages and PR title follow the Conventional Commits standard.
  • My changes have been tested locally and function as expected.
  • My PR does not introduce any breaking changes.
  • I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

Comment thread [core]/es_extended/imports.lua Outdated
@Kenshiin13 Kenshiin13 requested a review from Zykem August 13, 2025 15:26
@Kenshiin13 Kenshiin13 merged commit b1ecf2c into dev Aug 13, 2025
2 of 3 checks passed
@Kenshiin13 Kenshiin13 deleted the player-data branch August 13, 2025 15:30
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